Skip to content

Commit

Permalink
Add and expose settings for SD find debounce as config options
Browse files Browse the repository at this point in the history
In this change a configurable initial debounce
interval for SD find as well as a configurable
number of initial debounces are introduced. This
implies that services requested in the initial
debounce phase will at most wait for an initial
debounce interval before being included in a SD
find debounce. After the initial debounce phase is
completed, all subsequent SD find debounces will
use the default debounce interval.

Added and exposed options:
* find_initial_debounce_reps
* find_initial_debounce_time
  • Loading branch information
Tommy Andersson authored and tommyhaley committed Dec 11, 2024
1 parent 6461369 commit 3d628a4
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 2 deletions.
2 changes: 2 additions & 0 deletions implementation/configuration/include/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ class configuration {
virtual ttl_t get_sd_ttl() const = 0;
virtual int32_t get_sd_cyclic_offer_delay() const = 0;
virtual int32_t get_sd_request_response_delay() const = 0;
virtual std::uint32_t get_sd_find_initial_debounce_reps() const = 0;
virtual std::uint32_t get_sd_find_initial_debounce_time() const = 0;
virtual std::uint32_t get_sd_offer_debounce_time() const = 0;
virtual std::uint32_t get_sd_find_debounce_time() const = 0;

Expand Down
8 changes: 7 additions & 1 deletion implementation/configuration/include/configuration_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ class configuration_impl:
VSOMEIP_EXPORT ttl_t get_sd_ttl() const;
VSOMEIP_EXPORT int32_t get_sd_cyclic_offer_delay() const;
VSOMEIP_EXPORT int32_t get_sd_request_response_delay() const;
VSOMEIP_EXPORT std::uint32_t get_sd_find_initial_debounce_reps() const;
VSOMEIP_EXPORT std::uint32_t get_sd_find_initial_debounce_time() const;
VSOMEIP_EXPORT std::uint32_t get_sd_offer_debounce_time() const;
VSOMEIP_EXPORT std::uint32_t get_sd_find_debounce_time() const;

Expand Down Expand Up @@ -537,6 +539,8 @@ class configuration_impl:
ttl_t sd_ttl_;
int32_t sd_cyclic_offer_delay_;
int32_t sd_request_response_delay_;
std::uint32_t sd_find_initial_debounce_reps_;
std::uint32_t sd_find_initial_debounce_time_;
std::uint32_t sd_offer_debounce_time_;
std::uint32_t sd_find_debounce_time_;

Expand Down Expand Up @@ -587,6 +591,8 @@ class configuration_impl:
ET_WATCHDOG_ALLOWED_MISSING_PONGS,
ET_TRACING_ENABLE,
ET_TRACING_SD_ENABLE,
ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_REPS,
ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_TIME,
ET_SERVICE_DISCOVERY_OFFER_DEBOUNCE_TIME,
ET_SERVICE_DISCOVERY_FIND_DEBOUNCE_TIME,
ET_SERVICE_DISCOVERY_TTL_FACTOR_OFFERS,
Expand All @@ -608,7 +614,7 @@ class configuration_impl:
ET_SECURITY_AUDIT_MODE,
ET_SECURITY_REMOTE_ACCESS,
ET_INITIAL_ROUTING_STATE,
ET_MAX = 47
ET_MAX = 49
};

bool is_configured_[ET_MAX];
Expand Down
43 changes: 43 additions & 0 deletions implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ configuration_impl::configuration_impl(const std::string& _path) :
sd_request_response_delay_ {VSOMEIP_SD_DEFAULT_REQUEST_RESPONSE_DELAY},
sd_offer_debounce_time_ {VSOMEIP_SD_DEFAULT_OFFER_DEBOUNCE_TIME},
sd_find_debounce_time_ {VSOMEIP_SD_DEFAULT_FIND_DEBOUNCE_TIME},
sd_find_initial_debounce_reps_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_REPS),
sd_find_initial_debounce_time_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_TIME),
max_configured_message_size_ {0}, max_local_message_size_ {0}, max_reliable_message_size_ {0},
max_unreliable_message_size_ {0},
buffer_shrink_threshold_ {VSOMEIP_DEFAULT_BUFFER_SHRINK_THRESHOLD},
Expand Down Expand Up @@ -154,6 +156,8 @@ configuration_impl::configuration_impl(const configuration_impl& _other) :
sd_ttl_ = _other.sd_ttl_;
sd_cyclic_offer_delay_= _other.sd_cyclic_offer_delay_;
sd_request_response_delay_= _other.sd_request_response_delay_;
sd_find_initial_debounce_reps_ = _other.sd_find_initial_debounce_reps_;
sd_find_initial_debounce_time_ = _other.sd_find_initial_debounce_time_;
sd_offer_debounce_time_ = _other.sd_offer_debounce_time_;
sd_find_debounce_time_ = _other.sd_find_debounce_time_;

Expand Down Expand Up @@ -1800,6 +1804,33 @@ void configuration_impl::load_service_discovery(
its_converter >> sd_request_response_delay_;
is_configured_[ET_SERVICE_DISCOVERY_REQUEST_RESPONSE_DELAY] = true;
}
} else if (its_key == "find_initial_debounce_reps") {
if (!is_overlay_ && is_configured_[ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_REPS]) {
VSOMEIP_WARNING << "Multiple definitions for service_discovery.find_initial_debounce_reps."
" Ignoring definition from " << _element.name_;
} else {
its_converter << its_value;
its_converter >> sd_find_initial_debounce_reps_;
is_configured_[ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_REPS] = true;
}
} else if (its_key == "find_initial_debounce_time") {
if (!is_overlay_ && is_configured_[ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_TIME]) {
VSOMEIP_WARNING << "Multiple definitions for service_discovery.find_initial_debounce_time."
" Ignoring definition from " << _element.name_;
} else {
its_converter << its_value;
its_converter >> sd_find_initial_debounce_time_;
is_configured_[ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_TIME] = true;
}
} else if (its_key == "find_debounce_time") {
if (!is_overlay_ && is_configured_[ET_SERVICE_DISCOVERY_FIND_DEBOUNCE_TIME]) {
VSOMEIP_WARNING << "Multiple definitions for service_discovery.find_debounce_time."
" Ignoring definition from " << _element.name_;
} else {
its_converter << its_value;
its_converter >> sd_find_debounce_time_;
is_configured_[ET_SERVICE_DISCOVERY_FIND_DEBOUNCE_TIME] = true;
}
} else if (its_key == "offer_debounce_time") {
if (is_configured_[ET_SERVICE_DISCOVERY_OFFER_DEBOUNCE_TIME]) {
VSOMEIP_WARNING << "Multiple definitions for service_discovery.offer_debounce."
Expand Down Expand Up @@ -3677,6 +3708,18 @@ int32_t configuration_impl::get_sd_request_response_delay() const {
return sd_request_response_delay_;
}

std::uint32_t configuration_impl::get_sd_find_initial_debounce_reps() const {
return sd_find_initial_debounce_reps_;
}

std::uint32_t configuration_impl::get_sd_find_initial_debounce_time() const {
return sd_find_initial_debounce_time_;
}

std::uint32_t configuration_impl::get_sd_find_debounce_time() const {
return sd_find_debounce_time_;
}

std::uint32_t configuration_impl::get_sd_offer_debounce_time() const {
return sd_offer_debounce_time_;
}
Expand Down
3 changes: 2 additions & 1 deletion implementation/service_discovery/include/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#define VSOMEIP_SD_DEFAULT_REQUEST_RESPONSE_DELAY 2000
#define VSOMEIP_SD_DEFAULT_OFFER_DEBOUNCE_TIME 500
#define VSOMEIP_SD_DEFAULT_FIND_DEBOUNCE_TIME 500

#define VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_TIME 200
#define VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_REPS 0

#endif // VSOMEIP_SD_DEFINES_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ class service_discovery_impl: public service_discovery,
std::mutex collected_offers_mutex_;
services_t collected_offers_;

// configurable debounce time for a configuarble number of inital debounce repetitions
std::uint32_t find_initial_debounce_reps_;
std::chrono::milliseconds find_initial_debounce_time_;
// counter of remaining find initial debounce repetitions
std::uint32_t remaining_find_initial_debounce_reps_;

std::chrono::milliseconds find_debounce_time_;
std::mutex find_debounce_timer_mutex_;
boost::asio::steady_timer find_debounce_timer_;
Expand Down
19 changes: 19 additions & 0 deletions implementation/service_discovery/src/service_discovery_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ service_discovery_impl::init() {
repetitions_max_ = configuration_->get_sd_repetitions_max();
cyclic_offer_delay_ = std::chrono::milliseconds(
configuration_->get_sd_cyclic_offer_delay());
remaining_find_initial_debounce_reps_ = 0;
find_initial_debounce_reps_ = configuration_->get_sd_find_initial_debounce_reps();
find_initial_debounce_time_ = std::chrono::milliseconds(
configuration_->get_sd_find_initial_debounce_time());
find_debounce_time_ = std::chrono::milliseconds(
configuration_->get_sd_find_debounce_time());
offer_debounce_time_ = std::chrono::milliseconds(
configuration_->get_sd_offer_debounce_time());
ttl_timer_runtime_ = cyclic_offer_delay_ / 2;
Expand Down Expand Up @@ -2879,13 +2885,26 @@ service_discovery_impl::start_find_debounce_timer(bool _first_start) {
boost::system::error_code ec;
if (_first_start) {
find_debounce_timer_.expires_from_now(initial_delay_, ec);
} else if (remaining_find_initial_debounce_reps_ > 0) {
find_debounce_timer_.expires_from_now(find_initial_debounce_time_, ec);
} else {
find_debounce_timer_.expires_from_now(find_debounce_time_, ec);
}
if (ec) {
VSOMEIP_ERROR<< "service_discovery_impl::start_find_debounce_timer "
"setting expiry time of timer failed: " << ec.message();
}

if (_first_start) {
// Reset the number of remaining initial debounce cycles for find
remaining_find_initial_debounce_reps_ = find_initial_debounce_reps_;
} else {
if (remaining_find_initial_debounce_reps_ > 0) {
// Decrement the number of remaining initial debounce cycles for find
remaining_find_initial_debounce_reps_--;
}
}

find_debounce_timer_.async_wait(
std::bind(
&service_discovery_impl::on_find_debounce_timer_expired,
Expand Down

0 comments on commit 3d628a4

Please sign in to comment.