Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
7112580c
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7112580c
编写于
10月 01, 2011
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed a few problems with redis-trib resharding.
上级
a0189bbe
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
10 deletion
+28
-10
src/redis-trib.rb
src/redis-trib.rb
+28
-10
未找到文件。
src/redis-trib.rb
浏览文件 @
7112580c
#!/usr/bin/env ruby
# TODO (temporary here, we'll move this into the Github issues once
redis-trib initial
# implementation is complted).
# TODO (temporary here, we'll move this into the Github issues once
#
redis-trib initial
implementation is complted).
#
# - Make sure that if the rehashing fails in the middle redis-trib will try to recover.
# - When redis-trib performs a cluster check, if it detects a slot move in progress it
# should prompt the user to continue the move from where it stopped.
# - Make sure that if the rehashing fails in the middle redis-trib will try
# to recover.
# - When redis-trib performs a cluster check, if it detects a slot move in
# progress it should prompt the user to continue the move from where it
# stopped.
# - Gracefully handle Ctrl+C in move_slot to prompt the user if really stop
# while rehashing, and performing the best cleanup possible if the user
# forces the quit.
# - When doing "fix" set a global Fix to true, and prompt the user to
# fix the problem if automatically fixable every time there is something
# to fix. For instance:
# 1) If there is a node that pretend to receive a slot, or to migrate a
# slot, but has no entries in that slot, fix it.
# 2) If there is a node having keys in slots that are not owned by it
# fix this condiiton moving the entries in the same node.
# 3) Perform more possibly slow tests about the state of the cluster.
# 4) When aborted slot migration is detected, fix it.
require
'rubygems'
require
'redis'
...
...
@@ -81,7 +95,9 @@ class ClusterNode
nodes
=
@r
.
cluster
(
"nodes"
).
split
(
"
\n
"
)
nodes
.
each
{
|
n
|
# name addr flags role ping_sent ping_recv link_status slots
name
,
addr
,
flags
,
role
,
ping_sent
,
ping_recv
,
link_status
,
slots
=
n
.
split
(
" "
)
split
=
n
.
split
name
,
addr
,
flags
,
role
,
ping_sent
,
ping_recv
,
link_status
=
split
[
0
..
6
]
slots
=
split
[
7
..-
1
]
info
=
{
:name
=>
name
,
:addr
=>
addr
,
...
...
@@ -94,8 +110,10 @@ class ClusterNode
if
info
[
:flags
].
index
(
"myself"
)
@info
=
@info
.
merge
(
info
)
@info
[
:slots
]
=
{}
slots
.
split
(
","
).
each
{
|
s
|
if
s
.
index
(
"-"
)
slots
.
each
{
|
s
|
if
s
[
0
..
0
]
==
'['
# Fixme: for now skipping migration entries
elsif
s
.
index
(
"-"
)
start
,
stop
=
s
.
split
(
"-"
)
self
.
add_slots
((
start
.
to_i
)
..
(
stop
.
to_i
))
else
...
...
@@ -171,7 +189,7 @@ class ClusterNode
x
.
count
==
1
?
x
.
first
.
to_s
:
"
#{
x
.
first
}
-
#{
x
.
last
}
"
}.
join
(
","
)
"[
#{
@info
[
:cluster_state
].
upcase
}
]
#{
self
.
info
[
:name
]
}
#{
self
.
to_s
.
ljust
(
25
)
}
slots:
#{
slots
}
"
"[
#{
@info
[
:cluster_state
].
upcase
}
]
#{
self
.
info
[
:name
]
}
#{
self
.
to_s
}
slots:
#{
slots
}
(
#{
self
.
slots
.
length
}
slots)
"
end
def
info
...
...
@@ -330,7 +348,7 @@ class RedisTrib
# and the slot as migrating in the target host. Note that the order of
# the operations is important, as otherwise a client may be redirected to
# the target node that does not yet know it is importing this slot.
print
"Moving slot
#{
slot
}
: "
;
STDOUT
.
flush
print
"Moving slot
#{
slot
}
from
#{
source
.
info_string
}
: "
;
STDOUT
.
flush
target
.
r
.
cluster
(
"setslot"
,
slot
,
"importing"
,
source
.
info
[
:name
])
source
.
r
.
cluster
(
"setslot"
,
slot
,
"migrating"
,
source
.
info
[
:name
])
# Migrate all the keys from source to target using the MIGRATE command
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录