mirror of
https://github.com/sogou/workflow.git
synced 2026-02-08 01:33:17 +08:00
@@ -603,18 +603,17 @@ void UPSWeightedRandomPolicy::fuse_one_server(const EndpointAddress *addr)
|
||||
EndpointAddress *UPSVNSWRRPolicy::first_strategy(const ParsedURI& uri,
|
||||
WFNSTracing *tracing)
|
||||
{
|
||||
int idx = this->cur_idx;
|
||||
for (int i = 0; i < this->total_weight; i++)
|
||||
int idx = this->cur_idx.fetch_add(1);
|
||||
int pos = 0;
|
||||
for (int i = 0; i < this->total_weight; i++, idx++)
|
||||
{
|
||||
idx = (this->cur_idx + i) % this->pre_generated_vec.size();
|
||||
int pos = this->pre_generated_vec[idx];
|
||||
pos = this->pre_generated_vec[idx % this->pre_generated_vec.size()];
|
||||
if (WFServiceGovernance::in_select_history(tracing, this->servers[pos]))
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
this->cur_idx = idx + 1;
|
||||
return this->servers[idx];
|
||||
return this->servers[pos];
|
||||
}
|
||||
|
||||
void UPSVNSWRRPolicy::init_virtual_nodes()
|
||||
|
||||
@@ -160,7 +160,7 @@ private:
|
||||
void init_virtual_nodes();
|
||||
std::vector<size_t> pre_generated_vec;
|
||||
std::vector<int> current_weight_vec;
|
||||
size_t cur_idx;
|
||||
std::atomic<size_t> cur_idx;
|
||||
};
|
||||
|
||||
class UPSConsistentHashPolicy : public UPSGroupPolicy
|
||||
|
||||
Reference in New Issue
Block a user