def _ensure_cluster_status_set(t):
m = t.talk_raw(CMD_INFO)
logging.debug('Ask `info` Rsp %s', m)
cluster_enabled = PAT_CLUSTER_ENABLED.findall(m)
if len(cluster_enabled) == 0 or int(cluster_enabled[0]) == 0:
raise hiredis.ProtocolError(
'Node %s:%d is not cluster enabled' % (t.host, t.port))
m = t.talk_raw(CMD_CLUSTER_INFO)
logging.debug('Ask `cluster info` Rsp %s', m)
cluster_state = PAT_CLUSTER_STATE.findall(m)
cluster_slot_assigned = PAT_CLUSTER_SLOT_ASSIGNED.findall(m)
if cluster_state[0] != 'ok' and int(cluster_slot_assigned[0]) == 0:
raise hiredis.ProtocolError(
'Node %s:%d is not in a cluster' % (t.host, t.port))
# Redis instance responses to clients BEFORE changing its 'cluster_state'
# just retry some times, it should become OK
评论列表
文章目录