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
2f52dac9
Commit
2f52dac9
authored
Apr 29, 2011
by
antirez
Browse files
CLUSTER subcommands to set slots in migrating or importing state. Still a work in progress...
parent
484354ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
2f52dac9
...
...
@@ -1168,6 +1168,44 @@ void clusterCommand(redisClient *c) {
clusterUpdateState
();
clusterSaveConfigOrDie
();
addReply
(
c
,
shared
.
ok
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"setslot"
)
&&
c
->
argc
>=
4
)
{
/* SETSLOT 10 MIGRATING <instance ID> */
/* SETSLOT 10 IMPORTING <instance ID> */
/* SETSLOT 10 STABLE */
long
long
aux
;
unsigned
int
slot
;
clusterNode
*
n
;
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
aux
,
NULL
)
!=
REDIS_OK
)
return
;
if
(
aux
<
0
||
aux
>=
REDIS_CLUSTER_SLOTS
)
{
addReplyError
(
c
,
"Slot out of range"
);
return
;
}
slot
=
(
unsigned
int
)
aux
;
if
(
server
.
cluster
.
slots
[
slot
]
!=
server
.
cluster
.
myself
)
{
addReplyErrorFormat
(
c
,
"I'm not the owner of hash slot %u"
,
slot
);
return
;
}
if
(
!
strcasecmp
(
c
->
argv
[
3
]
->
ptr
,
"migrating"
)
&&
c
->
argc
==
5
)
{
if
((
n
=
clusterLookupNode
(
c
->
argv
[
4
]
->
ptr
))
==
NULL
)
{
addReplyErrorFormat
(
c
,
"I don't know about node %s"
,
(
char
*
)
c
->
argv
[
4
]
->
ptr
);
return
;
}
server
.
cluster
.
migrating_slots_to
[
slot
]
=
n
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
3
]
->
ptr
,
"importing"
)
&&
c
->
argc
==
5
)
{
if
((
n
=
clusterLookupNode
(
c
->
argv
[
4
]
->
ptr
))
==
NULL
)
{
addReplyErrorFormat
(
c
,
"I don't know about node %s"
,
(
char
*
)
c
->
argv
[
3
]
->
ptr
);
return
;
}
server
.
cluster
.
importing_slots_from
[
slot
]
=
n
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
3
]
->
ptr
,
"stable"
)
&&
c
->
argc
==
4
)
{
server
.
cluster
.
importing_slots_from
[
slot
]
=
NULL
;
}
else
{
addReplyError
(
c
,
"Invalid CLUSTER SETSLOT action or number of arguments"
);
}
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"info"
)
&&
c
->
argc
==
2
)
{
char
*
statestr
[]
=
{
"ok"
,
"fail"
,
"needhelp"
};
int
slots_assigned
=
0
,
slots_ok
=
0
,
slots_pfail
=
0
,
slots_fail
=
0
;
...
...
@@ -1211,8 +1249,7 @@ void clusterCommand(redisClient *c) {
addReplyLongLong
(
c
,
keyHashSlot
(
key
,
sdslen
(
key
)));
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"getkeysinslot"
)
&&
c
->
argc
==
4
)
{
long
long
maxkeys
,
slot
;
unsigned
int
numkeys
;
int
j
;
unsigned
int
numkeys
,
j
;
robj
**
keys
;
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
slot
,
NULL
)
!=
REDIS_OK
)
...
...
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