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
7c29c9ee
Commit
7c29c9ee
authored
Apr 29, 2020
by
antirez
Browse files
redis-cli: simplify cluster nodes coverage display.
parent
86a1386d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-cli.c
View file @
7c29c9ee
...
@@ -4295,17 +4295,18 @@ static int clusterManagerGetCoveredSlots(char *all_slots) {
...
@@ -4295,17 +4295,18 @@ static int clusterManagerGetCoveredSlots(char *all_slots) {
}
}
static
void
clusterManagerPrintSlotsList
(
list
*
slots
)
{
static
void
clusterManagerPrintSlotsList
(
list
*
slots
)
{
clusterManagerNode
n
=
{
0
};
listIter
li
;
listIter
li
;
listNode
*
ln
;
listNode
*
ln
;
listRewind
(
slots
,
&
li
);
listRewind
(
slots
,
&
li
);
sds
first
=
NULL
;
while
((
ln
=
listNext
(
&
li
))
!=
NULL
)
{
while
((
ln
=
listNext
(
&
li
))
!=
NULL
)
{
sds
slot
=
ln
->
value
;
int
slot
=
atoi
(
ln
->
value
);
if
(
!
first
)
first
=
slot
;
if
(
slot
>=
0
&&
slot
<
CLUSTER_MANAGER_SLOTS
)
else
printf
(
", "
);
n
.
slots
[
slot
]
=
1
;
printf
(
"%s"
,
slot
);
}
}
printf
(
"
\n
"
);
sds
nodeslist
=
clusterManagerNodeSlotsString
(
&
n
);
printf
(
"%s
\n
"
,
nodeslist
);
sdsfree
(
nodeslist
);
}
}
/* Return the node, among 'nodes' with the greatest number of keys
/* Return the node, among 'nodes' with the greatest number of keys
...
@@ -4398,15 +4399,10 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
...
@@ -4398,15 +4399,10 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
int
i
,
fixed
=
0
;
int
i
,
fixed
=
0
;
list
*
none
=
NULL
,
*
single
=
NULL
,
*
multi
=
NULL
;
list
*
none
=
NULL
,
*
single
=
NULL
,
*
multi
=
NULL
;
clusterManagerLogInfo
(
">>> Fixing slots coverage...
\n
"
);
clusterManagerLogInfo
(
">>> Fixing slots coverage...
\n
"
);
printf
(
"List of not covered slots:
\n
"
);
int
uncovered_count
=
0
;
sds
log
=
sdsempty
();
for
(
i
=
0
;
i
<
CLUSTER_MANAGER_SLOTS
;
i
++
)
{
for
(
i
=
0
;
i
<
CLUSTER_MANAGER_SLOTS
;
i
++
)
{
int
covered
=
all_slots
[
i
];
int
covered
=
all_slots
[
i
];
if
(
!
covered
)
{
if
(
!
covered
)
{
sds
key
=
sdsfromlonglong
((
long
long
)
i
);
sds
slot
=
sdsfromlonglong
((
long
long
)
i
);
if
(
uncovered_count
++
>
0
)
printf
(
","
);
printf
(
"%s"
,
(
char
*
)
key
);
list
*
slot_nodes
=
listCreate
();
list
*
slot_nodes
=
listCreate
();
sds
slot_nodes_str
=
sdsempty
();
sds
slot_nodes_str
=
sdsempty
();
listIter
li
;
listIter
li
;
...
@@ -4433,13 +4429,11 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
...
@@ -4433,13 +4429,11 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
}
}
freeReplyObject
(
reply
);
freeReplyObject
(
reply
);
}
}
log
=
sdscatfmt
(
log
,
"
\n
Slot %S has keys in %u nodes: %S"
,
key
,
listLength
(
slot_nodes
),
slot_nodes_str
);
sdsfree
(
slot_nodes_str
);
sdsfree
(
slot_nodes_str
);
dictAdd
(
clusterManagerUncoveredSlots
,
key
,
slot_nodes
);
dictAdd
(
clusterManagerUncoveredSlots
,
slot
,
slot_nodes
);
}
}
}
}
printf
(
"
\n
%s
\n
"
,
log
);
/* For every slot, take action depending on the actual condition:
/* For every slot, take action depending on the actual condition:
* 1) No node has keys for this slot.
* 1) No node has keys for this slot.
* 2) A single node has keys for this slot.
* 2) A single node has keys for this slot.
...
@@ -4581,7 +4575,6 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
...
@@ -4581,7 +4575,6 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
}
}
}
}
cleanup:
cleanup:
sdsfree
(
log
);
if
(
none
)
listRelease
(
none
);
if
(
none
)
listRelease
(
none
);
if
(
single
)
listRelease
(
single
);
if
(
single
)
listRelease
(
single
);
if
(
multi
)
listRelease
(
multi
);
if
(
multi
)
listRelease
(
multi
);
...
...
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