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
70091a2f
Commit
70091a2f
authored
Mar 25, 2013
by
antirez
Browse files
redis-trib: wait cluster join after cluster creation.
parent
34c1871e
Changes
1
Show whitespace changes
Inline
Side-by-side
src/redis-trib.rb
View file @
70091a2f
...
@@ -431,15 +431,29 @@ class RedisTrib
...
@@ -431,15 +431,29 @@ class RedisTrib
# Check if all the nodes agree about the cluster configuration
# Check if all the nodes agree about the cluster configuration
def
check_config_consistency
def
check_config_consistency
if
!
is_config_consistent?
cluster_error
"[ERR] Nodes don't agree about configuration!"
else
xputs
"[OK] All nodes agree about slots configuration."
end
end
def
is_config_consistent?
signatures
=
[]
signatures
=
[]
@nodes
.
each
{
|
n
|
@nodes
.
each
{
|
n
|
signatures
<<
n
.
get_config_signature
signatures
<<
n
.
get_config_signature
}
}
if
signatures
.
uniq
.
length
!=
1
return
signatures
.
uniq
.
length
==
1
cluster_error
"[ERR] Nodes don't agree about configuration!"
end
else
xputs
"[OK] All nodes agree about slots configuration."
def
wait_cluster_join
print
"Waiting for the cluster to join"
while
!
is_config_consistent?
print
"."
STDOUT
.
flush
sleep
1
end
end
print
"
\n
"
end
end
def
alloc_slots
def
alloc_slots
...
@@ -668,6 +682,11 @@ class RedisTrib
...
@@ -668,6 +682,11 @@ class RedisTrib
xputs
">>> Nodes configuration updated"
xputs
">>> Nodes configuration updated"
xputs
">>> Sending CLUSTER MEET messages to join the cluster"
xputs
">>> Sending CLUSTER MEET messages to join the cluster"
join_cluster
join_cluster
# Give one second for the join to start, in order to avoid that
# wait_cluster_join will find all the nodes agree about the config as
# they are still empty with unassigned slots.
sleep
1
wait_cluster_join
check_cluster
check_cluster
end
end
...
...
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