refactoring

pull/3806/head
Nikita Koksharov 3 years ago
parent 9153a69509
commit 2bb23815db

@ -38,10 +38,7 @@ import org.redisson.connection.ConnectionManager;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.connection.pool.PubSubConnectionPool; import org.redisson.connection.pool.PubSubConnectionPool;
import org.redisson.connection.pool.SlaveConnectionPool; import org.redisson.connection.pool.SlaveConnectionPool;
import org.redisson.misc.CountableListener; import org.redisson.misc.*;
import org.redisson.misc.RPromise;
import org.redisson.misc.RedisURI;
import org.redisson.misc.RedissonPromise;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -142,19 +139,18 @@ public class LoadBalancerManager {
|| entry.getFreezeReason() == FreezeReason.RECONNECT) { || entry.getFreezeReason() == FreezeReason.RECONNECT) {
if (!entry.isInitialized()) { if (!entry.isInitialized()) {
entry.setInitialized(true); entry.setInitialized(true);
CountableListener<Void> listener = new CountableListener<Void>() {
@Override AsyncCountDownLatch latch = new AsyncCountDownLatch();
protected void onSuccess(Void value) { latch.latch(() -> {
entry.setFreezeReason(null); entry.setFreezeReason(null);
} }, 2);
};
listener.setCounter(2);
BiConsumer<Void, Throwable> initCallBack = new BiConsumer<Void, Throwable>() { BiConsumer<Void, Throwable> initCallBack = new BiConsumer<Void, Throwable>() {
private AtomicBoolean initConnError = new AtomicBoolean(false); private final AtomicBoolean initConnError = new AtomicBoolean(false);
@Override @Override
public void accept(Void r, Throwable ex) { public void accept(Void r, Throwable ex) {
if (ex == null) { if (ex == null) {
listener.decCounter(); latch.countDown();
} else { } else {
if (!initConnError.compareAndSet(false, true)) { if (!initConnError.compareAndSet(false, true)) {
return; return;

Loading…
Cancel
Save