fix: add initing status in entry, and set entry freezed status null when all connection inited

Signed-off-by: xujie <mikawudi@qq.com>
pull/3295/head
xujie 4 years ago
parent bf76f30c2a
commit b7cfd1ff0f

@ -56,6 +56,8 @@ public class ClientConnectionsEntry {
private final AtomicLong firstFailTime = new AtomicLong(0);
private volatile boolean initing = false;
public ClientConnectionsEntry(RedisClient client, int poolMinSize, int poolMaxSize, int subscribePoolMinSize, int subscribePoolMaxSize,
ConnectionManager connectionManager, NodeType nodeType) {
this.client = client;
@ -81,10 +83,19 @@ public class ClientConnectionsEntry {
&& connectionManager.getConfig().getReadMode() == ReadMode.MASTER_SLAVE
&& getNodeType() == NodeType.MASTER;
}
public boolean isIniting() {
return this.initing;
}
public void setIniting(boolean isIniting) {
this.initing = isIniting;
}
public void setNodeType(NodeType nodeType) {
this.nodeType = nodeType;
}
public NodeType getNodeType() {
return nodeType;
}

@ -138,12 +138,18 @@ public class LoadBalancerManager {
if (freezeReason != FreezeReason.RECONNECT
|| entry.getFreezeReason() == FreezeReason.RECONNECT) {
entry.resetFirstFail();
entry.setFreezeReason(null);
slaveConnectionPool.initConnections(entry);
pubSubConnectionPool.initConnections(entry);
return true;
if (!entry.isIniting()) {
entry.setIniting(true);
entry.resetFirstFail();
slaveConnectionPool.initConnections(entry).onComplete((r, ex) -> {
entry.setIniting(false);
if (ex == null) {
entry.setFreezeReason(null);
}
});
pubSubConnectionPool.initConnections(entry);
return true;
}
}
}
return false;

Loading…
Cancel
Save