cluster import/export of hash slots implemented in the query redirection engine

This commit is contained in:
antirez
2011-05-05 11:13:21 +02:00
parent a5dce40726
commit eda827f8b7
3 changed files with 59 additions and 22 deletions

View File

@ -1096,13 +1096,15 @@ int processCommand(redisClient *c) {
addReplyError(c,"The cluster is down. Check with CLUSTER INFO for more information");
return REDIS_OK;
} else {
clusterNode *n = getNodeByQuery(c,cmd,c->argv,c->argc,&hashslot);
int ask;
clusterNode *n = getNodeByQuery(c,cmd,c->argv,c->argc,&hashslot,&ask);
if (n == NULL) {
addReplyError(c,"Invalid cross-node request");
addReplyError(c,"Multi keys request invalid in cluster");
return REDIS_OK;
} else if (n != server.cluster.myself) {
addReplySds(c,sdscatprintf(sdsempty(),
"-MOVED %d %s:%d\r\n",hashslot,n->ip,n->port));
"-%s %d %s:%d\r\n", ask ? "ASK" : "MOVED",
hashslot,n->ip,n->port));
return REDIS_OK;
}
}