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
813d7cbd
Commit
813d7cbd
authored
Mar 22, 2013
by
antirez
Browse files
redis-trib: added cluster_error method to add errors.
parent
d7eae8d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-trib.rb
View file @
813d7cbd
...
@@ -250,6 +250,11 @@ class RedisTrib
...
@@ -250,6 +250,11 @@ class RedisTrib
@nodes
<<
node
@nodes
<<
node
end
end
def
cluster_error
(
msg
)
@errors
<<
msg
puts
msg
end
def
get_node_by_name
(
name
)
def
get_node_by_name
(
name
)
@nodes
.
each
{
|
n
|
@nodes
.
each
{
|
n
|
return
n
if
n
.
info
[
:name
]
==
name
.
downcase
return
n
if
n
.
info
[
:name
]
==
name
.
downcase
...
@@ -281,9 +286,8 @@ class RedisTrib
...
@@ -281,9 +286,8 @@ class RedisTrib
if
slots
.
length
==
ClusterHashSlots
if
slots
.
length
==
ClusterHashSlots
puts
"[OK] All
#{
ClusterHashSlots
}
slots covered."
puts
"[OK] All
#{
ClusterHashSlots
}
slots covered."
else
else
@
error
s
<<
cluster_
error
\
"[ERR] Not all
#{
ClusterHashSlots
}
slots are covered by nodes."
"[ERR] Not all
#{
ClusterHashSlots
}
slots are covered by nodes."
puts
@errors
[
-
1
]
fix_slots_coverage
if
@fix
fix_slots_coverage
if
@fix
end
end
end
end
...
@@ -293,10 +297,12 @@ class RedisTrib
...
@@ -293,10 +297,12 @@ class RedisTrib
open_slots
=
[]
open_slots
=
[]
@nodes
.
each
{
|
n
|
@nodes
.
each
{
|
n
|
if
n
.
info
[
:migrating
].
size
>
0
if
n
.
info
[
:migrating
].
size
>
0
puts
"[WARNING] Node
#{
n
}
has slots in migrating state."
cluster_error
\
"[WARNING] Node
#{
n
}
has slots in migrating state."
open_slots
+=
n
.
info
[
:migrating
].
keys
open_slots
+=
n
.
info
[
:migrating
].
keys
elsif
n
.
info
[
:importing
].
size
>
0
elsif
n
.
info
[
:importing
].
size
>
0
puts
"[WARNING] Node
#{
n
}
has slots in importing state."
cluster_error
\
"[WARNING] Node
#{
n
}
has slots in importing state."
open_slots
+=
n
.
info
[
:importing
].
keys
open_slots
+=
n
.
info
[
:importing
].
keys
end
end
}
}
...
@@ -566,7 +572,7 @@ class RedisTrib
...
@@ -566,7 +572,7 @@ class RedisTrib
load_cluster_info_from_node
(
ARGV
[
1
])
load_cluster_info_from_node
(
ARGV
[
1
])
check_cluster
check_cluster
if
@errors
.
length
!=
0
if
@errors
.
length
!=
0
puts
"Please fix your cluster problems before resharding
.
"
puts
"
\n
---
Please fix your cluster problems before resharding
---
"
exit
1
exit
1
end
end
numslots
=
0
numslots
=
0
...
...
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