diff --git a/docs/about-timer.md b/docs/about-timer.md index ffa99a93..bea28129 100644 --- a/docs/about-timer.md +++ b/docs/about-timer.md @@ -10,10 +10,10 @@ using timer_callback_t = std::function; class WFTaskFactory { -... + ... static WFTimerTask *create_timer_task(unsigned int microseconds, timer_callback_t callback); - static WFTimerTask *create_timer_task(time_t seconds, long nanoseconds, + static WFTimerTask *create_timer_task(time_t seconds, long nanoseconds, timer_callback_t callback); }; ~~~ diff --git a/docs/en/about-timer.md b/docs/en/about-timer.md index b6a705bb..4e4c4a1c 100644 --- a/docs/en/about-timer.md +++ b/docs/en/about-timer.md @@ -11,7 +11,7 @@ using timer_callback_t = std::function; class WFTaskFactory { -... + ... static WFTimerTask *create_timer_task(unsigned int microseconds, timer_callback_t callback); static WFTimerTask *create_timer_task(time_t seconds, long nanoseconds, diff --git a/src/manager/UpstreamManager.h b/src/manager/UpstreamManager.h index d1e4290a..aef93df2 100644 --- a/src/manager/UpstreamManager.h +++ b/src/manager/UpstreamManager.h @@ -44,7 +44,7 @@ * - Additional, we support Main-backup & Group for server and working well in any mode. * * @code{.cc} - upstream_create_weighted_random("abc.sogou", true); //UPSTREAM_WIGHTED_RANDOM + upstream_create_weighted_random("abc.sogou", true); //UPSTREAM_WEIGHTED_RANDOM upstream_add_server("abc.sogou", "192.168.2.100:8081"); //weight=1, max_fails=200 upstream_add_server("abc.sogou", "192.168.2.100:9090"); //weight=1, max_fails=200 AddressParams params = ADDRESS_PARAMS_DEFAULT; diff --git a/src/nameservice/UpstreamPolicies.cc b/src/nameservice/UpstreamPolicies.cc index 0d3959f3..55de99f2 100644 --- a/src/nameservice/UpstreamPolicies.cc +++ b/src/nameservice/UpstreamPolicies.cc @@ -194,17 +194,17 @@ bool UPSGroupPolicy::select(const ParsedURI& uri, WFNSTracing *tracing, } /* - * flag true : return an available one. If not exists, return NULL. - * false: means addr maybe group-alive. - * If addr is not available, get one from addr->group. + * addr_failed true: return an available one. If not exists, return NULL. + * false: means addr maybe group-alive. + * If addr is not available, get one from addr->group. */ EndpointAddress *UPSGroupPolicy::check_and_get(EndpointAddress *addr, - bool flag, + bool addr_failed, WFNSTracing *tracing) { UPSAddrParams *params = static_cast(addr->params); - if (flag == true) // && addr->fail_count >= addr->params->max_fails + if (addr_failed == true) // means fail_count >= max_fails { if (params->group_id == -1) return NULL; @@ -397,7 +397,8 @@ int UPSGroupPolicy::remove_server_locked(const std::string& address) return ret; } -EndpointAddress *UPSGroupPolicy::consistent_hash_with_group(unsigned int hash) +EndpointAddress *UPSGroupPolicy::consistent_hash_with_group(unsigned int hash, + WFNSTracing *tracing) { const UPSAddrParams *params; EndpointAddress *addr = NULL; @@ -427,7 +428,7 @@ EndpointAddress *UPSGroupPolicy::consistent_hash_with_group(unsigned int hash) if (!addr) return NULL; - return this->check_and_get(addr, false, NULL); + return this->check_and_get(addr, false, tracing); } void UPSWeightedRandomPolicy::add_server_locked(EndpointAddress *addr) @@ -636,7 +637,7 @@ EndpointAddress *UPSConsistentHashPolicy::first_strategy(const ParsedURI& uri, uri.path ? uri.path : "", uri.query ? uri.query : "", uri.fragment ? uri.fragment : ""); - return this->consistent_hash_with_group(hash_value); + return this->consistent_hash_with_group(hash_value, tracing); } EndpointAddress *UPSManualPolicy::first_strategy(const ParsedURI& uri, @@ -659,6 +660,6 @@ EndpointAddress *UPSManualPolicy::another_strategy(const ParsedURI& uri, uri.path ? uri.path : "", uri.query ? uri.query : "", uri.fragment ? uri.fragment : ""); - return this->consistent_hash_with_group(hash_value); + return this->consistent_hash_with_group(hash_value, tracing); } diff --git a/src/nameservice/UpstreamPolicies.h b/src/nameservice/UpstreamPolicies.h index ab7b2bf5..75a4df2c 100644 --- a/src/nameservice/UpstreamPolicies.h +++ b/src/nameservice/UpstreamPolicies.h @@ -71,9 +71,10 @@ protected: virtual void add_server_locked(EndpointAddress *addr); virtual int remove_server_locked(const std::string& address); - EndpointAddress *consistent_hash_with_group(unsigned int hash); + EndpointAddress *consistent_hash_with_group(unsigned int hash, + WFNSTracing *tracing); EndpointAddress *check_and_get(EndpointAddress *addr, - bool flag, WFNSTracing *tracing); + bool addr_failed, WFNSTracing *tracing); bool is_alive(const EndpointAddress *addr) const; };