Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
0ba29322
Commit
0ba29322
authored
May 04, 2011
by
antirez
Browse files
CLUSTER SETSLOT implemented
parent
66f2517f
Changes
1
Show whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
0ba29322
...
...
@@ -115,7 +115,30 @@ int clusterLoadConfig(char *filename) {
for (j = 7; j < argc; j++) {
int start, stop;
if
((
p
=
strchr
(
argv
[
j
],
'-'
))
!=
NULL
)
{
if (argv[j][0] == '[') {
/* Here we handle migrating / importing slots */
int slot;
char direction;
clusterNode *cn;
p = strchr(argv[j],'-');
redisAssert(p != NULL);
*p = '\0';
direction = p[1]; /* Either '>' or '<' */
slot = atoi(argv[j]+1);
p += 3;
cn = clusterLookupNode(p);
if (!cn) {
cn = createClusterNode(p,0);
clusterAddNode(cn);
}
if (direction == '>') {
server.cluster.migrating_slots_to[slot] = cn;
} else {
server.cluster.importing_slots_from[slot] = cn;
}
continue;
} else if ((p = strchr(argv[j],'-')) != NULL) {
*p = '\0';
start = atoi(argv[j]);
stop = atoi(p+1);
...
...
@@ -1093,10 +1116,10 @@ sds clusterGenNodesDescription(void) {
if (node->flags & REDIS_NODE_MYSELF) {
for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) {
if (server.cluster.migrating_slots_to[j]) {
ci
=
sdscatprintf
(
ci
,
" [%d->%.40s]"
,
j
,
ci = sdscatprintf(ci," [%d->
-
%.40s]",j,
server.cluster.migrating_slots_to[j]->name);
} else if (server.cluster.importing_slots_from[j]) {
ci
=
sdscatprintf
(
ci
,
" [%d<-%.40s]"
,
j
,
ci = sdscatprintf(ci," [%d
-
<-%.40s]",j,
server.cluster.importing_slots_from[j]->name);
}
}
...
...
@@ -1221,6 +1244,7 @@ void clusterCommand(redisClient *c) {
} else {
addReplyError(c,"Invalid CLUSTER SETSLOT action or number of arguments");
}
clusterSaveConfigOrDie();
addReply(c,shared.ok);
} else if (!strcasecmp(c->argv[1]->ptr,"info") && c->argc == 2) {
char *statestr[] = {"ok","fail","needhelp"};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment