private <T> T executeWithSession(SessionCallable<T> sessionCallable) { ReconnectionPolicy reconnectionPolicy = cluster.getConfiguration().getPolicies().getReconnectionPolicy(); ReconnectionSchedule schedule = reconnectionPolicy.newSchedule(); long deadline = System.currentTimeMillis() + noHostAvailableRetryTimeout.toMillis(); while (true) { try { return sessionCallable.executeWithSession(session.get()); } catch (NoHostAvailableException e) { long timeLeft = deadline - System.currentTimeMillis(); if (timeLeft <= 0) { throw e; } else { long delay = Math.min(schedule.nextDelayMs(), timeLeft); log.warn(e.getCustomMessage(10, true, true)); log.warn("Reconnecting in %dms", delay); try { Thread.sleep(delay); } catch (InterruptedException interrupted) { Thread.currentThread().interrupt(); throw new RuntimeException("interrupted", interrupted); } } } } }
@Override public void close() { childPolicy.close(); } }
reconnectionPolicy().init(Cluster.this); configuration.getPolicies().getAddressTranslator().init(Cluster.this); for (LatencyTracker tracker : latencyTrackers) tracker.onRegister(Cluster.this);
reconnectionPolicy().init(Cluster.this); configuration.getPolicies().getAddressTranslator().init(Cluster.this); for (LatencyTracker tracker : latencyTrackers)
private synchronized void updateReconnectionTime() { long now = System.nanoTime(); if (nextReconnectionTime > now) // Someone else updated the time before us return; if (reconnectionSchedule == null) reconnectionSchedule = reconnectionPolicy.newSchedule(); long nextDelayMs = reconnectionSchedule.nextDelayMs(); Host.statesLogger.debug( "[{}] preventing new connections for the next {} ms", host, nextDelayMs); nextReconnectionTime = now + NANOSECONDS.convert(nextDelayMs, MILLISECONDS); }
speculativeExecutionPolicy().close(); configuration.getPolicies().getRetryPolicy().close(); reconnectionPolicy().close(); configuration.getPolicies().getAddressTranslator().close(); for (LatencyTracker tracker : latencyTrackers) tracker.onUnregister(Cluster.this);
reconnectionPolicy().init(Cluster.this); configuration.getPolicies().getAddressTranslator().init(Cluster.this); for (LatencyTracker tracker : latencyTrackers)
@Override public ReconnectionSchedule newSchedule() { return new CountingSchedule(childPolicy.newSchedule()); }
@Override public void close() { childPolicy.close(); } }
reconnectionPolicy().init(Cluster.this); configuration.getPolicies().getAddressTranslator().init(Cluster.this); for (LatencyTracker tracker : latencyTrackers)
"Control connection", cluster.reconnectionExecutor, cluster.reconnectionPolicy().newSchedule(), reconnectionAttempt, initialDelayMs) {
speculativeExecutionPolicy().close(); configuration.getPolicies().getRetryPolicy().close(); reconnectionPolicy().close(); configuration.getPolicies().getAddressTranslator().close(); for (LatencyTracker tracker : latencyTrackers)
host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(), host.reconnectionAttempt) {
speculativeExecutionPolicy().close(); configuration.getPolicies().getRetryPolicy().close(); reconnectionPolicy().close(); configuration.getPolicies().getAddressTranslator().close(); for (LatencyTracker tracker : latencyTrackers)
host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(), host.reconnectionAttempt, 0) {
speculativeExecutionPolicy().close(); configuration.getPolicies().getRetryPolicy().close(); reconnectionPolicy().close(); configuration.getPolicies().getAddressTranslator().close(); for (LatencyTracker tracker : latencyTrackers)
private synchronized void updateReconnectionTime() { long now = System.nanoTime(); if (nextReconnectionTime > now) // Someone else updated the time before us return; if (reconnectionSchedule == null) reconnectionSchedule = reconnectionPolicy.newSchedule(); long nextDelayMs = reconnectionSchedule.nextDelayMs(); Host.statesLogger.debug("[{}] preventing new connections for the next {} ms", host, nextDelayMs); nextReconnectionTime = now + NANOSECONDS.convert(nextDelayMs, MILLISECONDS); }
private synchronized void updateReconnectionTime() { long now = System.nanoTime(); if (nextReconnectionTime > now) // Someone else updated the time before us return; if (reconnectionSchedule == null) reconnectionSchedule = reconnectionPolicy.newSchedule(); long nextDelayMs = reconnectionSchedule.nextDelayMs(); Host.statesLogger.debug("[{}] preventing new connections for the next {} ms", host, nextDelayMs); nextReconnectionTime = now + NANOSECONDS.convert(nextDelayMs, MILLISECONDS); }
private synchronized void updateReconnectionTime() { long now = System.nanoTime(); if (nextReconnectionTime > now) // Someone else updated the time before us return; if (reconnectionSchedule == null) reconnectionSchedule = reconnectionPolicy.newSchedule(); long nextDelayMs = reconnectionSchedule.nextDelayMs(); Host.statesLogger.debug("[{}] preventing new connections for the next {} ms", host, nextDelayMs); nextReconnectionTime = now + NANOSECONDS.convert(nextDelayMs, MILLISECONDS); }
@Override public ReconnectionSchedule newSchedule() { return new CountingSchedule(childPolicy.newSchedule()); }