remove 'nalives' check and update strategy.

This commit is contained in:
XieHan
2022-01-17 22:56:05 +08:00
parent f7e18adb16
commit d1e721de05
3 changed files with 15 additions and 10 deletions
+3 -7
View File
@@ -167,11 +167,6 @@ bool UPSGroupPolicy::select(const ParsedURI& uri, WFNSTracing *tracing,
}
this->check_breaker();
if (this->nalives == 0)
{
pthread_rwlock_unlock(&this->rwlock);
return false;
}
// select_addr == NULL will only happened in consistent_hash
EndpointAddress *select_addr = this->first_strategy(uri, tracing);
@@ -510,9 +505,10 @@ EndpointAddress *UPSWeightedRandomPolicy::first_strategy(const ParsedURI& uri,
EndpointAddress *UPSWeightedRandomPolicy::another_strategy(const ParsedURI& uri,
WFNSTracing *tracing)
{
/* When all servers down, recover all. */
/* When all servers are down, recover all servers if any server
* reaches fusing timeout. */
if (this->available_weight == 0)
this->clear_breaker();
this->try_clear_breaker();
int temp_weight = this->available_weight;
if (temp_weight == 0)
+11 -2
View File
@@ -274,6 +274,8 @@ void WFServiceGovernance::check_breaker_locked(int64_t cur_time)
list_del(pos);
pos->next = NULL;
}
else
break;
}
}
@@ -285,10 +287,17 @@ void WFServiceGovernance::check_breaker()
pthread_mutex_unlock(&this->breaker_lock);
}
void WFServiceGovernance::clear_breaker()
void WFServiceGovernance::try_clear_breaker()
{
pthread_mutex_lock(&this->breaker_lock);
this->check_breaker_locked(INT64_MAX);
if (!list_empty(&this->breaker_list))
{
struct list_head *pos = this->breaker_list.next;
struct EndpointAddress::address_entry *entry;
entry = list_entry(pos, struct EndpointAddress::address_entry, list);
if (GET_CURRENT_SECOND >= entry->ptr->broken_timeout)
this->check_breaker_locked(INT64_MAX);
}
pthread_mutex_unlock(&this->breaker_lock);
}
+1 -1
View File
@@ -175,8 +175,8 @@ protected:
WFNSTracing *tracing);
virtual EndpointAddress *another_strategy(const ParsedURI& uri,
WFNSTracing *tracing);
void clear_breaker();
void check_breaker();
void try_clear_breaker();
void pre_delete_server(EndpointAddress *addr);
struct TracingData