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
2593fb9c
Commit
2593fb9c
authored
Jan 17, 2019
by
artix
Browse files
Cluster Manager: code cleanup
parent
6e9864fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-cli.c
View file @
2593fb9c
...
@@ -3413,8 +3413,8 @@ cleanup:
...
@@ -3413,8 +3413,8 @@ cleanup:
/* Wait until the cluster configuration is consistent. */
/* Wait until the cluster configuration is consistent. */
static
void
clusterManagerWaitForClusterJoin
(
void
)
{
static
void
clusterManagerWaitForClusterJoin
(
void
)
{
printf
(
"Waiting for the cluster to join
\n
"
);
printf
(
"Waiting for the cluster to join
\n
"
);
int
counter
=
0
,
int
counter
=
0
,
check_after
=
CLUSTER_JOIN_CHECK_AFTER
+
check_after
=
CLUSTER_JOIN_CHECK_AFTER
+
(
int
)(
listLength
(
cluster_manager
.
nodes
)
*
0
.
15
f
);
(
int
)(
listLength
(
cluster_manager
.
nodes
)
*
0
.
15
f
);
while
(
!
clusterManagerIsConfigConsistent
())
{
while
(
!
clusterManagerIsConfigConsistent
())
{
printf
(
"."
);
printf
(
"."
);
...
@@ -3434,11 +3434,11 @@ static void clusterManagerWaitForClusterJoin(void) {
...
@@ -3434,11 +3434,11 @@ static void clusterManagerWaitForClusterJoin(void) {
char
*
node_ip
=
NULL
;
char
*
node_ip
=
NULL
;
int
node_port
=
0
,
node_bus_port
=
0
;
int
node_port
=
0
,
node_bus_port
=
0
;
list
*
from
=
(
list
*
)
dictGetVal
(
entry
);
list
*
from
=
(
list
*
)
dictGetVal
(
entry
);
if
(
parseClusterNodeAddress
(
nodeaddr
,
&
node_ip
,
if
(
parseClusterNodeAddress
(
nodeaddr
,
&
node_ip
,
&
node_port
,
&
node_bus_port
)
&&
node_bus_port
)
{
&
node_port
,
&
node_bus_port
)
&&
node_bus_port
)
{
clusterManagerLogErr
(
" - The port %d of node %s may "
clusterManagerLogErr
(
" - The port %d of node %s may "
"be unreachable from:
\n
"
,
"be unreachable from:
\n
"
,
node_bus_port
,
node_ip
);
node_bus_port
,
node_ip
);
}
else
{
}
else
{
clusterManagerLogErr
(
" - Node %s may be unreachable "
clusterManagerLogErr
(
" - Node %s may be unreachable "
"from:
\n
"
,
nodeaddr
);
"from:
\n
"
,
nodeaddr
);
...
@@ -3873,12 +3873,12 @@ static list *clusterManagerGetDisconnectedLinks(clusterManagerNode *node) {
...
@@ -3873,12 +3873,12 @@ static list *clusterManagerGetDisconnectedLinks(clusterManagerNode *node) {
char
*
lines
=
reply
->
str
,
*
p
,
*
line
;
char
*
lines
=
reply
->
str
,
*
p
,
*
line
;
while
((
p
=
strstr
(
lines
,
"
\n
"
))
!=
NULL
)
{
while
((
p
=
strstr
(
lines
,
"
\n
"
))
!=
NULL
)
{
int
i
=
0
;
int
i
=
0
;
*
p
=
'\0'
;
*
p
=
'\0'
;
line
=
lines
;
line
=
lines
;
lines
=
p
+
1
;
lines
=
p
+
1
;
char
*
nodename
=
NULL
,
*
addr
=
NULL
,
*
flags
=
NULL
,
*
link_status
=
NULL
;
char
*
nodename
=
NULL
,
*
addr
=
NULL
,
*
flags
=
NULL
,
*
link_status
=
NULL
;
while
((
p
=
strchr
(
line
,
' '
))
!=
NULL
)
{
while
((
p
=
strchr
(
line
,
' '
))
!=
NULL
)
{
*
p
=
'\0'
;
*
p
=
'\0'
;
char
*
token
=
line
;
char
*
token
=
line
;
line
=
p
+
1
;
line
=
p
+
1
;
if
(
i
==
0
)
nodename
=
token
;
if
(
i
==
0
)
nodename
=
token
;
...
@@ -3889,12 +3889,10 @@ static list *clusterManagerGetDisconnectedLinks(clusterManagerNode *node) {
...
@@ -3889,12 +3889,10 @@ static list *clusterManagerGetDisconnectedLinks(clusterManagerNode *node) {
i
++
;
i
++
;
}
}
if
(
i
==
7
)
link_status
=
line
;
if
(
i
==
7
)
link_status
=
line
;
if
(
nodename
==
NULL
||
addr
==
NULL
||
flags
==
NULL
||
if
(
nodename
==
NULL
||
addr
==
NULL
||
flags
==
NULL
||
link_status
==
NULL
)
continue
;
link_status
==
NULL
)
continue
;
if
(
strstr
(
flags
,
"myself"
)
!=
NULL
)
continue
;
if
(
strstr
(
flags
,
"myself"
)
!=
NULL
)
continue
;
int
disconnected
=
((
strstr
(
flags
,
"disconnected"
)
!=
NULL
)
||
int
disconnected
=
((
strstr
(
flags
,
"disconnected"
)
!=
NULL
)
||
(
strstr
(
link_status
,
"disconnected"
)));
(
strstr
(
link_status
,
"disconnected"
)));
int
handshaking
=
(
strstr
(
flags
,
"handshake"
)
!=
NULL
);
int
handshaking
=
(
strstr
(
flags
,
"handshake"
)
!=
NULL
);
if
(
disconnected
||
handshaking
)
{
if
(
disconnected
||
handshaking
)
{
...
...
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