mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-04 12:59:39 +08:00
modify redis_node class for redis.4.x.x
This commit is contained in:
parent
c2100129d3
commit
344d370715
@ -40,14 +40,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
redis_node& set_addr(const char* addr);
|
redis_node& set_addr(const char* addr);
|
||||||
|
|
||||||
/**
|
|
||||||
* 对于 redis.4.x.x,通过 CLUSTER NODES 返回的地址中会带有 @xxx
|
|
||||||
* for redis.4.x.x, the return addr of CLUSTER NODES has @xxx
|
|
||||||
* @param addr {const char*}
|
|
||||||
* @return {redis_node&}
|
|
||||||
*/
|
|
||||||
redis_node& set_at_addr(const char* addr);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置当前结点的类型
|
* 设置当前结点的类型
|
||||||
* set the current node's type
|
* set the current node's type
|
||||||
@ -245,19 +237,19 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* for redis.4.x.x:
|
* result of CLUSTER NODES for redis.4.x.x:
|
||||||
* d52ea3cb4cdf7294ac1fb61c696ae6483377bcfc 127.0.0.1:16385@116385 master - 0 1428410625374 73 connected 5461-10922
|
* d52ea3cb4cdf7294ac1fb61c696ae6483377bcfc 127.0.0.1:16385@116385 master - 0 1428410625374 73 connected 5461-10922
|
||||||
* @return return @116385 for redis.4.x.x
|
* @return return 127.0.0.1:16385@116385 for redis.4.x.x
|
||||||
*/
|
*/
|
||||||
const char* get_at_addr() const
|
const char* get_addr_info() const
|
||||||
{
|
{
|
||||||
return at_addr_.c_str();
|
return addr_info_.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string id_;
|
string id_;
|
||||||
string addr_;
|
string addr_;
|
||||||
string at_addr_;
|
string addr_info_;
|
||||||
string type_;
|
string type_;
|
||||||
bool myself_;
|
bool myself_;
|
||||||
bool handshaking_;
|
bool handshaking_;
|
||||||
|
@ -760,13 +760,7 @@ redis_node* redis_cluster::get_node(string& line)
|
|||||||
|
|
||||||
redis_node* node = NEW redis_node;
|
redis_node* node = NEW redis_node;
|
||||||
node->set_id(tokens[0].c_str());
|
node->set_id(tokens[0].c_str());
|
||||||
char *addr = tokens[1].c_str();
|
node->set_addr(tokens[1].c_str());
|
||||||
char *at = strchr(addr, '@');
|
|
||||||
if (at)
|
|
||||||
*at++ = 0;
|
|
||||||
node->set_addr(addr);
|
|
||||||
if (at && *at)
|
|
||||||
node->set_at_addr(at);
|
|
||||||
node->set_myself(myself);
|
node->set_myself(myself);
|
||||||
node->set_connected(strcasecmp(tokens[7].c_str(), "connected") == 0);
|
node->set_connected(strcasecmp(tokens[7].c_str(), "connected") == 0);
|
||||||
node->set_master_id(tokens[3].c_str());
|
node->set_master_id(tokens[3].c_str());
|
||||||
|
@ -28,14 +28,12 @@ redis_node& redis_node::set_id(const char* id)
|
|||||||
|
|
||||||
redis_node& redis_node::set_addr(const char* addr)
|
redis_node& redis_node::set_addr(const char* addr)
|
||||||
{
|
{
|
||||||
addr_ = addr;
|
addr_info_ = addr;
|
||||||
return *this;
|
int pos = addr_info_.find('@');
|
||||||
}
|
if (pos <= 0)
|
||||||
|
addr_ = addr_info_;
|
||||||
redis_node& redis_node::set_at_addr(const char* addr)
|
else
|
||||||
{
|
addr_.copy(addr_info_, pos);
|
||||||
if (addr && *addr)
|
|
||||||
at_addr_ = addr;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user