Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_57962205
redisson
提交
dc7036c9
R
redisson
项目概览
weixin_57962205
/
redisson
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redisson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc7036c9
编写于
11月 30, 2018
作者:
N
Nikita Koksharov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed - Master node shouldn't be shutdown on slave down event in Sentinel mode. #1746
上级
9e3e9fe5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
8 deletion
+12
-8
redisson/src/main/java/org/redisson/connection/SentinelConnectionManager.java
...va/org/redisson/connection/SentinelConnectionManager.java
+12
-8
未找到文件。
redisson/src/main/java/org/redisson/connection/SentinelConnectionManager.java
浏览文件 @
dc7036c9
...
...
@@ -19,7 +19,6 @@ import java.net.InetSocketAddress;
import
java.net.URI
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
...
...
@@ -39,7 +38,6 @@ import org.redisson.client.RedisConnection;
import
org.redisson.client.RedisConnectionException
;
import
org.redisson.client.codec.StringCodec
;
import
org.redisson.client.protocol.RedisCommands
;
import
org.redisson.cluster.ClusterSlotRange
;
import
org.redisson.config.BaseMasterSlaveServersConfig
;
import
org.redisson.config.Config
;
import
org.redisson.config.MasterSlaveServersConfig
;
...
...
@@ -69,7 +67,6 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
private
final
ConcurrentMap
<
String
,
RedisClient
>
sentinels
=
PlatformDependent
.
newConcurrentHashMap
();
private
final
AtomicReference
<
String
>
currentMaster
=
new
AtomicReference
<
String
>();
private
final
Set
<
String
>
slaves
=
Collections
.
newSetFromMap
(
PlatformDependent
.<
String
,
Boolean
>
newConcurrentHashMap
());
private
final
Set
<
URI
>
disconnectedSlaves
=
new
HashSet
<
URI
>();
private
ScheduledFuture
<?>
monitorFuture
;
...
...
@@ -100,7 +97,6 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
this
.
config
.
setMasterAddress
(
masterHost
);
currentMaster
.
set
(
masterHost
);
log
.
info
(
"master: {} added"
,
masterHost
);
slaves
.
add
(
masterHost
);
List
<
Map
<
String
,
String
>>
sentinelSlaves
=
connection
.
sync
(
StringCodec
.
INSTANCE
,
RedisCommands
.
SENTINEL_SLAVES
,
cfg
.
getMasterName
());
for
(
Map
<
String
,
String
>
map
:
sentinelSlaves
)
{
...
...
@@ -115,7 +111,6 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
String
host
=
createAddress
(
ip
,
port
);
this
.
config
.
addSlaveAddress
(
host
);
slaves
.
add
(
host
);
log
.
debug
(
"slave {} state: {}"
,
host
,
map
);
log
.
info
(
"slave: {} added"
,
host
);
...
...
@@ -368,9 +363,19 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
CountableListener
<
Void
>
listener
=
new
CountableListener
<
Void
>()
{
@Override
protected
void
onSuccess
(
Void
value
)
{
Set
<
String
>
removedSlaves
=
new
HashSet
<
String
>(
slaves
);
MasterSlaveEntry
entry
=
getEntry
(
singleSlotRange
.
getStartSlot
());
Set
<
String
>
removedSlaves
=
new
HashSet
<
String
>();
for
(
ClientConnectionsEntry
e
:
entry
.
getAllEntries
())
{
InetSocketAddress
addr
=
e
.
getClient
().
getAddr
();
String
slaveAddr
=
createAddress
(
addr
.
getAddress
().
getHostAddress
(),
addr
.
getPort
());
removedSlaves
.
add
(
slaveAddr
);
}
removedSlaves
.
removeAll
(
currentSlaves
);
for
(
String
slave
:
removedSlaves
)
{
if
(
slave
.
equals
(
currentMaster
.
get
()))
{
continue
;
}
String
hostPort
=
slave
.
replace
(
"redis://"
,
""
);
int
lastColonIdx
=
hostPort
.
lastIndexOf
(
":"
);
String
host
=
hostPort
.
substring
(
0
,
lastColonIdx
);
...
...
@@ -462,13 +467,12 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
// to avoid addition twice
final
MasterSlaveEntry
entry
=
getEntry
(
singleSlotRange
.
getStartSlot
());
final
URI
uri
=
convert
(
ip
,
port
);
if
(
slaves
.
add
(
slaveAddr
)
&&
!
config
.
checkSkipSlavesInit
())
{
if
(
!
entry
.
hasSlave
(
uri
)
&&
!
config
.
checkSkipSlavesInit
())
{
RFuture
<
Void
>
future
=
entry
.
addSlave
(
URIBuilder
.
create
(
slaveAddr
));
future
.
addListener
(
new
FutureListener
<
Void
>()
{
@Override
public
void
operationComplete
(
Future
<
Void
>
future
)
throws
Exception
{
if
(!
future
.
isSuccess
())
{
slaves
.
remove
(
slaveAddr
);
result
.
tryFailure
(
future
.
cause
());
log
.
error
(
"Can't add slave: "
+
slaveAddr
,
future
.
cause
());
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录