Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
9a38df87
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
9a38df87
编写于
9月 30, 2011
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
redis-trib: actual slot migration work in progress, more work needed.
上级
c5954c19
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
19 addition
and
2 deletion
+19
-2
src/redis-trib.rb
src/redis-trib.rb
+19
-2
未找到文件。
src/redis-trib.rb
浏览文件 @
9a38df87
...
@@ -314,10 +314,20 @@ class RedisTrib
...
@@ -314,10 +314,20 @@ class RedisTrib
def
show_reshard_table
(
table
)
def
show_reshard_table
(
table
)
table
.
each
{
|
e
|
table
.
each
{
|
e
|
puts
"Moving slot
#{
e
[
:slot
]
}
from
#{
e
[
:source
].
info
[
:name
]
}
"
puts
"
Moving slot
#{
e
[
:slot
]
}
from
#{
e
[
:source
].
info
[
:name
]
}
"
}
}
end
end
def
move_slot
(
source
,
target
,
slot
)
# We start marking the slot as importing in the destination node,
# 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.
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
end
# redis-trib subcommands implementations
# redis-trib subcommands implementations
def
check_cluster_cmd
def
check_cluster_cmd
...
@@ -334,7 +344,7 @@ class RedisTrib
...
@@ -334,7 +344,7 @@ class RedisTrib
end
end
numslots
=
0
numslots
=
0
while
numslots
<=
0
or
numslots
>
4096
while
numslots
<=
0
or
numslots
>
4096
print
"How many slots do you want to move (from 1 to 4096)?"
print
"How many slots do you want to move (from 1 to 4096)?
"
numslots
=
STDIN
.
gets
.
to_i
numslots
=
STDIN
.
gets
.
to_i
end
end
target
=
nil
target
=
nil
...
@@ -380,7 +390,14 @@ class RedisTrib
...
@@ -380,7 +390,14 @@ class RedisTrib
puts
" Destination node:"
puts
" Destination node:"
puts
"
#{
target
.
info_string
}
"
puts
"
#{
target
.
info_string
}
"
reshard_table
=
compute_reshard_table
(
sources
,
numslots
)
reshard_table
=
compute_reshard_table
(
sources
,
numslots
)
puts
" Resharding plan:"
show_reshard_table
(
reshard_table
)
show_reshard_table
(
reshard_table
)
print
"Do you want to proceed with the proposed reshard plan (yes/no)? "
yesno
=
STDIN
.
gets
.
chop
exit
(
1
)
if
(
yesno
!=
"yes"
)
reshard_table
.
each
{
|
e
|
move_slot
(
e
[
:source
],
target
,
e
[
:slot
])
}
end
end
def
create_cluster_cmd
def
create_cluster_cmd
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录