Signed-off-by: xujie <mikawudi@qq.com>
pull/3455/head
mika 4 years ago committed by xujie
parent 088006169e
commit 3619e434df

@ -259,6 +259,24 @@ public class ClientConnectionsEntry {
freeSubscribeConnectionsCounter.release();
}
public void closeAllConnections() {
synchronized (this) {
for (RedisConnection connection : this.getAllConnections()) {
if (!connection.isClosed()) {
connection.closeAsync();
}
}
this.getAllConnections().clear();
for (RedisConnection connection : this.getAllSubscribeConnections()) {
if (!connection.isClosed()) {
connection.closeAsync();
}
}
this.getAllSubscribeConnections().clear();
}
}
@Override
public String toString() {
return "[freeSubscribeConnectionsAmount=" + freeSubscribeConnections.size()

@ -153,28 +153,14 @@ public class LoadBalancerManager {
private AtomicBoolean initConnError = new AtomicBoolean(false);
@Override
public void accept(Void r, Throwable ex) {
synchronized (this) {
if (ex == null) {
listener.decCounter();
} else {
if (!initConnError.compareAndSet(false, true)) {
return;
}
for (RedisConnection connection : entry.getAllConnections()) {
if (!connection.isClosed()) {
connection.closeAsync();
}
}
entry.getAllConnections().clear();
for (RedisConnection connection : entry.getAllSubscribeConnections()) {
if (!connection.isClosed()) {
connection.closeAsync();
}
}
entry.getAllSubscribeConnections().clear();
entry.setInitialized(false);
if (ex == null) {
listener.decCounter();
} else {
if (!initConnError.compareAndSet(false, true)) {
return;
}
entry.closeAllConnections();
entry.setInitialized(false);
}
}
};
@ -187,7 +173,7 @@ public class LoadBalancerManager {
}
return false;
}
public ClientConnectionsEntry freeze(RedisURI address, FreezeReason freezeReason) {
ClientConnectionsEntry connectionEntry = getEntry(address);
return freeze(connectionEntry, freezeReason);

@ -131,21 +131,9 @@ abstract class ConnectionPool<T extends RedisConnection> {
if (initPromise.isDone()) {
return;
}
for (RedisConnection connection : entry.getAllConnections()) {
if (!connection.isClosed()) {
connection.closeAsync();
}
}
entry.getAllConnections().clear();
for (RedisConnection connection : entry.getAllSubscribeConnections()) {
if (!connection.isClosed()) {
connection.closeAsync();
}
}
entry.getAllSubscribeConnections().clear();
entry.closeAllConnections();
int totalInitializedConnections = minimumIdleSize - initializedConnections.get();
String errorMsg;
if (totalInitializedConnections == 0) {

Loading…
Cancel
Save