Timer initialization fixed. #671

pull/673/head
Nikita 8 years ago
parent eca9682dc9
commit 047aa60dae

@ -74,6 +74,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
connectListener = new ClusterConnectionListener(cfg.getReadMode() != ReadMode.MASTER);
this.config = create(cfg);
initTimer(this.config);
init(this.config);
Throwable lastException = null;

@ -65,6 +65,7 @@ public class ElasticacheConnectionManager extends MasterSlaveConnectionManager {
super(config);
this.config = create(cfg);
initTimer(this.config);
for (URI addr : cfg.getNodeAddresses()) {
RedisConnection connection = connect(cfg, addr);

@ -155,6 +155,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
public MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config) {
this(config);
initTimer(cfg);
init(cfg);
}
@ -224,6 +225,17 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
protected void init(MasterSlaveServersConfig config) {
this.config = config;
connectionWatcher = new IdleConnectionWatcher(this, config);
try {
initEntry(config);
} catch (RuntimeException e) {
stopThreads();
throw e;
}
}
protected void initTimer(MasterSlaveServersConfig config) {
int[] timeouts = new int[]{config.getRetryInterval(), config.getTimeout(), config.getReconnectionTimeout()};
Arrays.sort(timeouts);
int minTimeout = timeouts[0];
@ -235,15 +247,6 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
minTimeout = 100;
}
timer = new HashedWheelTimer(minTimeout, TimeUnit.MILLISECONDS);
connectionWatcher = new IdleConnectionWatcher(this, config);
try {
initEntry(config);
} catch (RuntimeException e) {
stopThreads();
throw e;
}
}
public ConnectionInitializer getConnectListener() {

@ -114,6 +114,7 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
if (currentMaster.get() == null) {
throw new RedisConnectionException("Can't connect to servers!");
}
initTimer(c);
init(c);
List<RFuture<RedisPubSubConnection>> connectionFutures = new ArrayList<RFuture<RedisPubSubConnection>>(cfg.getSentinelAddresses().size());

Loading…
Cancel
Save