代码拉取完成,页面将自动刷新
#ifndef consistent_hash_hpp
#define consistent_hash_hpp
#include <stdio.h>
#include <set>
#include <string>
#include <map>
class ConsistentHash {
private:
std::map<uint32_t, std::string> hashRing; // {key: hashVal, value: real ip}
int virtualNodeCount; // count of virtual nodes for physical node
public:
ConsistentHash(int vnc) : virtualNodeCount(vnc) {};
~ConsistentHash() {
hashRing.clear();
};
static uint32_t HashHandler(std::string key);
void RegisterNode(const std::string &node);
void ComposeElementToRing(const std::string &node, const std::string &key);
void DelElementFromRing(const std::string &key);
void RemoveNode(const std::string &node);
std::string ChooseNode(const std::string &key);
};
#endif /* consistent_hash_hpp */
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。