mirror of
https://github.com/sogou/workflow.git
synced 2026-02-08 01:33:17 +08:00
consistent_hash_with_group() skips tracing
This commit is contained in:
@@ -10,10 +10,10 @@ using timer_callback_t = std::function<void (WFTimerTask *)>;
|
||||
|
||||
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);
|
||||
};
|
||||
~~~
|
||||
|
||||
@@ -11,7 +11,7 @@ using timer_callback_t = std::function<void (WFTimerTask *)>;
|
||||
|
||||
class WFTaskFactory
|
||||
{
|
||||
...
|
||||
...
|
||||
static WFTimerTask *create_timer_task(unsigned int microseconds,
|
||||
timer_callback_t callback);
|
||||
static WFTimerTask *create_timer_task(time_t seconds, long nanoseconds,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<UPSAddrParams *>(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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user