acl  3.5.3.0
acl::redis_cluster类 参考

#include <redis_cluster.hpp>

+ 类 acl::redis_cluster 继承关系图:
+ acl::redis_cluster 的协作图:

Public 成员函数

 redis_cluster (void)
 
 redis_cluster (redis_client *conn)
 
 redis_cluster (redis_client_cluster *cluster)
 
ACL_CPP_DEPRECATED redis_cluster (redis_client_cluster *cluster, size_t max_conns)
 
 redis_cluster (redis_client_pipeline *pipeline)
 
virtual ~redis_cluster (void)
 
bool cluster_addslots (int first,...)
 
bool cluster_addslots (const int slot_list[], size_t n)
 
bool cluster_addslots (const std::vector< int > &slot_list)
 
bool cluster_delslots (int first,...)
 
bool cluster_delslots (const int slot_list[], size_t n)
 
bool cluster_delslots (const std::vector< int > &slot_list)
 
int cluster_getkeysinslot (size_t slot, size_t max, std::list< string > &result)
 
bool cluster_meet (const char *ip, int port)
 
bool cluster_reset ()
 
bool cluster_reset_hard ()
 
bool cluster_reset_soft ()
 
bool cluster_setslot_importing (size_t slot, const char *src_node)
 
bool cluster_setslot_migrating (size_t slot, const char *dst_node)
 
bool cluster_setslot_stable (size_t slot)
 
bool cluster_setslot_node (size_t slot, const char *node)
 
int cluster_count_failure_reports (const char *node)
 
bool cluster_failover ()
 
bool cluster_failover_force ()
 
bool cluster_failover_takeover ()
 
bool cluster_info (std::map< string, string > &result)
 
bool cluster_saveconfig ()
 
int cluster_countkeysinslot (size_t slot)
 
bool cluster_forget (const char *node)
 
int cluster_keyslot (const char *key)
 
bool cluster_replicate (const char *node)
 
bool cluster_set_config_epoch (const char *epoch)
 
const std::vector< redis_slot * > * cluster_slots ()
 
const std::map< string, redis_node * > * cluster_nodes ()
 
const std::vector< redis_node * > * cluster_slaves (const char *node)
 
- Public 成员函数 继承自 acl::redis_command
 redis_command (void)
 
 redis_command (redis_client *conn)
 
 redis_command (redis_client_cluster *cluster)
 
ACL_CPP_DEPRECATED redis_command (redis_client_cluster *cluster, size_t max_conns)
 
 redis_command (redis_client_pipeline *pipeline)
 
virtual ~redis_command (void)
 
void set_check_addr (bool on)
 
void clear (bool save_slot=false)
 
void reset (bool save_slot=false)
 
void set_client (redis_client *conn)
 
redis_clientget_client (void) const
 
const char * get_client_addr (void) const
 
void set_cluster (redis_client_cluster *cluster)
 
ACL_CPP_DEPRECATED void set_cluster (redis_client_cluster *cluster, size_t max_conns)
 
redis_client_clusterget_cluster (void) const
 
void set_pipeline (redis_client_pipeline *pipeline, bool use_mbox=true)
 
redis_client_pipelineget_pipeline (void) const
 
dbuf_poolget_dbuf (void) const
 
redis_result_t result_type (void) const
 
const char * result_status (void) const
 
const char * result_error (void) const
 
size_t result_size (void) const
 
int result_number (bool *success=NULL) const
 
long long int result_number64 (bool *success=NULL) const
 
const char * get_result (size_t i, size_t *len=NULL) const
 
bool eof (void) const
 
const redis_resultget_result (void) const
 
const redis_resultresult_child (size_t i) const
 
const char * result_value (size_t i, size_t *len=NULL) const
 
void set_slice_request (bool on)
 
void set_slice_respond (bool on)
 
const redis_resultrequest (size_t argc, const char *argv[], size_t lens[], size_t nchild=0)
 
const redis_resultrequest (const std::vector< string > &args, size_t nchild=0)
 
const stringrequest_buf (void) const
 
void build_request (size_t argc, const char *argv[], size_t lens[])
 
void hash_slot (const char *key)
 
void hash_slot (const char *key, size_t len)
 
int get_slot (void) const
 
bool is_check_addr (void) const
 
const char * get_addr (const char *info)
 
void set_client_addr (const char *addr)
 
void set_client_addr (redis_client &conn)
 
redis_request * get_request_obj (void) const
 
stringget_request_buf (void) const
 
bool is_slice_req (void) const
 
redis_pipeline_messageget_pipeline_message (void)
 

额外继承的成员函数

- 静态 Public 成员函数 继承自 acl::redis_command
static void build_request (size_t argc, const char *argv[], size_t lens[], string &out)
 
- Protected 成员函数 继承自 acl::redis_command
const redis_resultrun (size_t nchild=0, int *timeout=NULL)
 
void clear_request (void)
 
const redis_result ** scan_keys (const char *cmd, const char *key, int &cursor, size_t &size, const char *pattern, const size_t *count)
 
const redis_result ** scan_keys (const char *cmd, const char *key, size_t klen, int &cursor, size_t &size, const char *pattern, const size_t *count)
 
void build (const char *cmd, const char *key, const std::map< string, string > &attrs)
 
void build (const char *cmd, const char *key, size_t klen, const std::map< string, string > &attrs)
 
void build (const char *cmd, const char *key, const std::map< string, const char * > &attrs)
 
void build (const char *cmd, const char *key, const std::vector< string > &names, const std::vector< string > &values)
 
void build (const char *cmd, const char *key, size_t klen, const std::vector< string > &names, const std::vector< string > &values)
 
void build (const char *cmd, const char *key, const std::vector< const char * > &names, const std::vector< const char * > &values)
 
void build (const char *cmd, const char *key, const char *names[], const char *values[], size_t argc)
 
void build (const char *cmd, const char *key, const int names[], const char *values[], size_t argc)
 
void build (const char *cmd, const char *key, const char *names[], const size_t names_len[], const char *values[], const size_t values_len[], size_t argc)
 
void build (const char *cmd, const char *key, size_t klen, const char *names[], const size_t names_len[], const char *values[], const size_t values_len[], size_t argc)
 
void build (const char *cmd, const char *key, const std::vector< string > &names)
 
void build (const char *cmd, const char *key, size_t klen, const std::vector< string > &names)
 
void build (const char *cmd, const char *key, const std::vector< const char * > &names)
 
void build (const char *cmd, const char *key, const std::vector< int > &names)
 
void build (const char *cmd, const char *key, const char *names[], size_t argc)
 
void build (const char *cmd, const char *key, const char *names[], const size_t lens[], size_t argc)
 
void build (const char *cmd, const char *key, size_t klen, const char *names[], const size_t lens[], size_t argc)
 
void build (const char *cmd, const char *key, const int names[], size_t argc)
 
int get_number (bool *success=NULL)
 
long long int get_number64 (bool *success=NULL)
 
int get_number (std::vector< int > &out)
 
int get_number64 (std::vector< long long int > &out)
 
bool check_status (const char *success="OK")
 
int get_status (std::vector< bool > &out)
 
const char * get_status (void)
 
int get_string (string &buf)
 
int get_string (string *buf)
 
int get_string (char *buf, size_t size)
 
int get_strings (std::vector< string > &result)
 
int get_strings (std::vector< string > *result)
 
int get_strings (std::list< string > &result)
 
int get_strings (std::list< string > *result)
 
int get_strings (std::map< string, string > &result)
 
int get_strings (std::vector< string > &names, std::vector< string > &values)
 
int get_strings (std::vector< const char * > &names, std::vector< const char * > &values)
 
void argv_space (size_t n)
 
void build_request1 (size_t argc, const char *argv[], size_t lens[])
 
void build_request2 (size_t argc, const char *argv[], size_t lens[])
 
void logger_result (const redis_result *result)
 
- Protected 成员函数 继承自 acl::acl::noncopyable
 noncopyable ()
 
 ~noncopyable ()
 
- Protected 属性 继承自 acl::redis_command
dbuf_pooldbuf_
 
bool check_addr_
 
char addr_ [32]
 
redis_clientconn_
 
redis_client_clustercluster_
 
redis_client_pipelinepipeline_
 
bool pipe_use_mbox_
 
int slot_
 
int redirect_max_
 
int redirect_sleep_
 
bool slice_req_
 
stringrequest_buf_
 
redis_request * request_obj_
 
size_t argv_size_
 
const char ** argv_
 
size_t * argv_lens_
 
size_t argc_
 
bool slice_res_
 
redis_pipeline_messagepipe_msg_
 
const redis_resultresult_
 

详细描述

在文件 redis_cluster.hpp18 行定义.

构造及析构函数说明

◆ redis_cluster() [1/5]

acl::redis_cluster::redis_cluster ( void  )

◆ redis_cluster() [2/5]

acl::redis_cluster::redis_cluster ( redis_client conn)

◆ redis_cluster() [3/5]

acl::redis_cluster::redis_cluster ( redis_client_cluster cluster)

◆ redis_cluster() [4/5]

ACL_CPP_DEPRECATED acl::redis_cluster::redis_cluster ( redis_client_cluster cluster,
size_t  max_conns 
)

◆ redis_cluster() [5/5]

acl::redis_cluster::redis_cluster ( redis_client_pipeline pipeline)

◆ ~redis_cluster()

virtual acl::redis_cluster::~redis_cluster ( void  )
virtual

成员函数说明

◆ cluster_addslots() [1/3]

bool acl::redis_cluster::cluster_addslots ( int  first,
  ... 
)

批量添加可用的哈希槽,最后必须以小于 0 的哈希槽值表示结束 add some hash-slots, the last slot value must be < 0 indicating the end of the slots array

参数
first{int} 第一个哈希槽,该值必须 >= 0 才有效 the first hash-slot which must be >= 0 param slot_list {const int[]} 要添加的哈希槽的列表 the hash-slots array to be added param n {size_t} the count of the hash-slots list param slot_list {const std::vector<init>&} 要添加的哈希槽的列表 the hash-slots list to be added
返回
{bool} 是否成功 return true if successful

◆ cluster_addslots() [2/3]

bool acl::redis_cluster::cluster_addslots ( const int  slot_list[],
size_t  n 
)

◆ cluster_addslots() [3/3]

bool acl::redis_cluster::cluster_addslots ( const std::vector< int > &  slot_list)

◆ cluster_count_failure_reports()

int acl::redis_cluster::cluster_count_failure_reports ( const char *  node)

获得某个指定 redis 结点报错的数量 get the count of the failure resports by one redis node

参数
node{const char*} 指定的某个 redis 结点
返回
{int} 结点报错的数量,正常情况下 >= 0,如果返回值 -1 表明操作出错 return the failure count reporting by the specified redis node, return value >= 0 if successful, or -1 for error happened

◆ cluster_countkeysinslot()

int acl::redis_cluster::cluster_countkeysinslot ( size_t  slot)

获得某个哈希槽中的对象总数量 get all the keys's count in one hash-slot

参数
slot{size_t} 指定哈希槽 the specified hash-slot
返回
{int} 返回哈希槽中的对象数量,-1 表示出错  return the keys's count in the hash-slot, return -1 if error

◆ cluster_delslots() [1/3]

bool acl::redis_cluster::cluster_delslots ( int  first,
  ... 
)

批量删除哈希槽,最后必须以小于 0 的哈希槽表示结束 remove some hash-slots, the last slot value must be < 0 indicating the end of the slots array

参数
first{int} 第一个哈希槽,该值必须 >= 0 才有效 the first hash-slot which must be >= 0 param slot_list {const int[]} 要删除的哈希槽的列表 the hash-slots array to be removed param n {size_t} the count of the hash-slots list param slot_list {const std::vector<init>&} 要删除的哈希槽的列表 the hash-slots array to be removed
返回
{bool} 是否成功 return true if successful

◆ cluster_delslots() [2/3]

bool acl::redis_cluster::cluster_delslots ( const int  slot_list[],
size_t  n 
)

◆ cluster_delslots() [3/3]

bool acl::redis_cluster::cluster_delslots ( const std::vector< int > &  slot_list)

◆ cluster_failover()

bool acl::redis_cluster::cluster_failover ( )

该命令操作只能发送给一个从结点,用来对主结点进行故障转移,使当前的从结点 做为主结点,需要与它的主结点进行协商,同时需要获得其它主结点的认可 this command can only be sent to one slave node for failover of the master node, make the current slave to be the master

返回
{bool} 操作是否成功 if the operation is successful

◆ cluster_failover_force()

bool acl::redis_cluster::cluster_failover_force ( )

强制性将一个从结点变为主结点,该操作不必与原来的主结点进行协商,但仍需得到 集群中大多数主结点的同意 force a slave to be the master, not handshake with it's master, but still need get agreement by majority of the masters in cluster

返回
{bool} 操作是否成功 if the operation is successful

◆ cluster_failover_takeover()

bool acl::redis_cluster::cluster_failover_takeover ( )

强制性将一个从结点变为主结点,该操作不必与原来的主结点和集群中的其它主结点 进行协商 force a slave to be the master, not handshake with it's master, and also no need get agreement by the other masters in cluster

返回
{bool} 操作是否成功 if the operation is successful

◆ cluster_forget()

bool acl::redis_cluster::cluster_forget ( const char *  node)

将指定结点从当前的结点中移除 remove the specified node from the current node

参数
node{const char*} 指定的要被移除的结点 the speicied node to be removed
返回
{bool} 操作是否成功 if this operation is successful

◆ cluster_getkeysinslot()

int acl::redis_cluster::cluster_getkeysinslot ( size_t  slot,
size_t  max,
std::list< string > &  result 
)

获得某个哈希槽当前所存储对象的键名集合 get keys array stored in one specified hash-slot

参数
slot{size_t} 哈希槽值 the specified hash-slot
max{size_t} 限制的结果集数量 limit the max results count
result{std::list<acl::string>&} 存储结果集 stored the results
返回
{int} 查询结果集的个数,-1 表示出错 >= 0 if OK, -1 if error

◆ cluster_info()

bool acl::redis_cluster::cluster_info ( std::map< string, string > &  result)

获得当前集群的一些概述信息 get running informantion about the redis cluster

参数
result{std::map<acl::string, acl::string>&} 存储结果 store the result of this operation
返回
{bool} 操作是否成功 if this operation is successful

◆ cluster_keyslot()

int acl::redis_cluster::cluster_keyslot ( const char *  key)

获得某个键所属的哈希槽 get the hash-slot wich the key belongs to

参数
key{const char*} 键值 the key string
返回
{int} 哈希槽值,>= 0 表示成功,-1 表示操作失败 return the key's hash-slot, >= 0 if successful, -1 on error

◆ cluster_meet()

bool acl::redis_cluster::cluster_meet ( const char *  ip,
int  port 
)

在建立 redis 集群时,可以使用此命令让一个 redis 结点是连接别的结点 let one redis node to link to the other redis node when buiding the redis cluster

参数
ip{const char*} 被连接的其它一个 redis 结点的 IP 地址 the other redis node's ip to be linked
port{int} 被连接的其它一个 redis 结点的 port 端口 the other redis node's port to be linked
返回
{bool} 连接是否成功 if the linking is successful

◆ cluster_nodes()

const std::map<string, redis_node*>* acl::redis_cluster::cluster_nodes ( )

获得当前集群中所有结点的主结点,主结点的所有从结点可以通过 redis_node::get_slaves 获得 get all the masters of the cluster, and master's slave nodes can be got by redis_node::get_slaves

返回
{const std::map<string, redis_node*>*} 返回 NULL 表示出错 return NULL if error happened, the return value needn't be freed because it can be freed internal

◆ cluster_replicate()

bool acl::redis_cluster::cluster_replicate ( const char *  node)

将指定结点设置为从结点,如果该结点原来为从结点,则也会返回成功 set the specified node to be a slave node

参数
node{const char*} 指定结点标识符 the specified node
返回
{bool} 操作是否成功 if this operation is successful

◆ cluster_reset()

bool acl::redis_cluster::cluster_reset ( )

重置一个 redis 结点的状态,使之从集群结点中脱离,清除哈希槽-结点的对应关系, 该方法等同于 reset_soft reset one redis node's status, escaping from the other nodes of the redis cluster, and clearing slot-to-nodes mapping; same as reset_soft

返回
{bool} 操作是否成功 if the operation is successful

◆ cluster_reset_hard()

bool acl::redis_cluster::cluster_reset_hard ( )

◆ cluster_reset_soft()

bool acl::redis_cluster::cluster_reset_soft ( )

◆ cluster_saveconfig()

bool acl::redis_cluster::cluster_saveconfig ( )

让当前 redis 结点将配置信息保存至磁盘的 nodes.conf 中 let the current node to save the cluster information in nodes.conf

返回
{bool} 操作是否成功 if this operation is successful

◆ cluster_set_config_epoch()

bool acl::redis_cluster::cluster_set_config_epoch ( const char *  epoch)

◆ cluster_setslot_importing()

bool acl::redis_cluster::cluster_setslot_importing ( size_t  slot,
const char *  src_node 
)

设定某个哈希槽在当前 redis 结点上正处于导入状态 set the hash-slot in importing status from the other node to the current node

参数
slot{size_t} 哈希槽值 the hash-slot value
src_node{const char*} 该哈希槽的 redis 源结点 the source redis-node of the hash-slot importing from
返回
{boo} 设置状态是否成功 if success for setting the slot's status

◆ cluster_setslot_migrating()

bool acl::redis_cluster::cluster_setslot_migrating ( size_t  slot,
const char *  dst_node 
)

设定某个哈希槽在当前 redis 结点上正处于迁移状态 set the hash-slot in migrating status to the other node from the current node

参数
slot{size_t} 哈希槽值 the hash-slot value
dst_node{const char*} 该哈希槽的 redis 迁移目标结点 the target redis-node of the hash-slot migrating to
返回
{boo} 设置状态是否成功 if success for setting the slot's status

◆ cluster_setslot_node()

bool acl::redis_cluster::cluster_setslot_node ( size_t  slot,
const char *  node 
)

设置指定的哈希槽至指定的某个 redis 结点,该指令有较为复杂的行为特征,具体 请参见官方在线文档 set one hash-slot to one redis node, for more help see online doc

参数
slot{size_t} 哈希槽值 the hash-slot to be set
node{const char*} 接收该哈希槽的 redis 结点 the redis node to be holding the hash-slot
返回
{bool} 操作是否成功 if the operation is successful

◆ cluster_setslot_stable()

bool acl::redis_cluster::cluster_setslot_stable ( size_t  slot)

当导入/迁移哈希槽完成后使用此操作指定该哈希槽为稳定状态 set the hash-slot stable after importing or migrating

参数
slot{size_t} 哈希槽值 the hash-slot value
返回
{bool} 设置状态是否成功 if success for setting the slot's status

◆ cluster_slaves()

const std::vector<redis_node*>* acl::redis_cluster::cluster_slaves ( const char *  node)

获得指定主结点的所有从结点 get all slave nodes of the specified master node

返回
node {const char*} 主结点标识符,返回 NULL 表示出错,该 返回结果不需要释放,内部自动维护 one of the master node, NULL if error, and the return value needn't be freed because it can be freed internal

◆ cluster_slots()

const std::vector<redis_slot*>* acl::redis_cluster::cluster_slots ( )

获得所有哈希槽在集群中各个 redis 结点的分布情况 get all nodes with all slots

返回
{const std::vector<redis_slot*>*} 返回存储哈希槽信息 的所有主结点集合,返回 NULL 表示出错 return all the master nodes with all hash-slots in them, and NULL will be returned if error happened, and the return value needn't be freed because it can be freed internal

该类的文档由以下文件生成: