ConsistentHashPolicy: change std_hash to rand.

This commit is contained in:
liyingxin
2022-02-17 17:59:25 +08:00
parent 6840b4b895
commit cf4f26fa3f
2 changed files with 2 additions and 3 deletions

View File

@@ -56,9 +56,8 @@ UPSAddrParams::UPSAddrParams(const struct AddressParams *params,
const std::string& address) :
PolicyAddrParams(params)
{
static std::hash<std::string> std_hash;
for (int i = 0; i < VIRTUAL_GROUP_SIZE; i++)
this->consistent_hash[i] = std_hash(address + "|v" + std::to_string(i));
this->consistent_hash[i] = rand();
this->weight = params->weight;
this->server_type = params->server_type;

View File

@@ -61,7 +61,7 @@ void register_upstream_hosts()
UpstreamManager::upstream_create_consistent_hash(
"hash",
[](const char *path, const char *query, const char *fragment) -> unsigned int {
return 1;
return 1315634022;
});
UpstreamManager::upstream_add_server("hash", "127.0.0.1:8001");
UpstreamManager::upstream_add_server("hash", "127.0.0.1:8002");