#pragma once #include class redis_util { public: redis_util(void); ~redis_util(void); // get the node's id of the given addr static bool get_node_id(const char* addr, acl::string& node_id, const char* passwd); // get the current node's ID static bool get_node_id(acl::redis& redis, acl::string& node_id); // get ip from the addr which format is ip:port static bool get_ip(const char* addr, acl::string& ip); static bool addr_split(const char* addr, acl::string& ip, int& port); // show the nodes's information, including master and slave static void print_nodes(int nested, const std::vector& nodes); // free all nodes nestly static void free_nodes(const std::vector& nodes); // sorting the givent redis_nodes by which machine ip static void sort(const std::map& in, std::map* >& out); // free vector holding redis_nodes static void clear_nodes_container( std::map* >& nodes); // get all the masters of cluster static const std::map* get_masters(acl::redis&); // get nodes formed bye one node maybe master or slave of the cluster static void get_nodes(acl::redis& redis, bool prefer_master, std::vector& nodes); private: static const std::map* get_masters2(acl::redis&); };