private void removeHostInternal(SocketAddress host, Optional<Throwable> reason) { synchronized (shardId2Address) { Integer shardId = address2ShardId.remove(host); if (null != shardId) { SocketAddress curHost = shardId2Address.get(shardId); if (null != curHost && curHost.equals(host)) { shardId2Address.remove(shardId); } circle.remove(shardId, host); if (reason.isPresent()) { if (reason.get() instanceof ChannelException) { logger.info("Shard {} ({}) left due to ChannelException, black it out for {} seconds (message = {})", new Object[] { shardId, host, blackoutSeconds, reason.get().toString() }); BlackoutHost blackoutHost = new BlackoutHost(shardId, host); hashedWheelTimer.newTimeout(blackoutHost, blackoutSeconds, TimeUnit.SECONDS); } else { logger.info("Shard {} ({}) left due to exception {}", new Object[] { shardId, host, reason.get().toString() }); } } else { logger.info("Shard {} ({}) left after server set change", shardId, host); } } else if (reason.isPresent()) { logger.info("Node {} left due to exception {}", host, reason.get().toString()); } else { logger.info("Node {} left after server set change", host); } } }
private void scheduleHandshake() { if (clientConfig.getPeriodicHandshakeIntervalMs() > 0) { periodicHandshakeTask = timer.newTimeout(this, clientConfig.getPeriodicHandshakeIntervalMs(), TimeUnit.MILLISECONDS); } }
void scheduleTimeout(final StreamOp op) { final Timeout timeout = requestTimer.newTimeout(new TimerTask() { @Override public void run(Timeout timeout) throws Exception { if (!timeout.isCancelled()) { serviceTimeout.inc(); handleServiceTimeout("Operation " + op.getClass().getName() + " timeout"); } } }, serviceTimeoutMs, TimeUnit.MILLISECONDS); op.responseHeader().ensure(new Function0<BoxedUnit>() { @Override public BoxedUnit apply() { timeout.cancel(); return null; } }); }
private void scheduleDumpOwnershipCache() { if (clientConfig.isPeriodicDumpOwnershipCacheEnabled() && clientConfig.getPeriodicDumpOwnershipCacheIntervalMs() > 0) { timer.newTimeout(this, clientConfig.getPeriodicDumpOwnershipCacheIntervalMs(), TimeUnit.MILLISECONDS); } }
void send(SocketAddress address) { long elapsedMs = stopwatch.elapsed(TimeUnit.MILLISECONDS); if (clientConfig.getMaxRedirects() > 0 && tries.get() >= clientConfig.getMaxRedirects()) { fail(address, new RequestTimeoutException(Duration.fromMilliseconds(elapsedMs), "Exhausted max redirects in " + elapsedMs + " ms")); return; } else if (clientConfig.getRequestTimeoutMs() > 0 && elapsedMs >= clientConfig.getRequestTimeoutMs()) { fail(address, new RequestTimeoutException(Duration.fromMilliseconds(elapsedMs), "Exhausted max request timeout " + clientConfig.getRequestTimeoutMs() + " in " + elapsedMs + " ms")); return; } synchronized (this) { String addrStr = address.toString(); if (ctx.isSetTriedHosts() && ctx.getTriedHosts().contains(addrStr)) { nextAddressToSend = address; dlTimer.newTimeout(this, Math.min(clientConfig.getRedirectBackoffMaxMs(), tries.get() * clientConfig.getRedirectBackoffStartMs()), TimeUnit.MILLISECONDS); } else { doSend(address); } } }
private Timeout newTimeout(final Event timeoutEvent) { if (requestTimeoutMs > 0) { return timeoutExecutor.newTimeout(new TimerTask() { @Override public void run(Timeout timeout) { fsm.sendEvent(timeoutEvent); } }, requestTimeoutMs, TimeUnit.MILLISECONDS); } else { return null; } }
private Timeout newTimeout() { if (requestTimeoutInMs > 0) { return timeoutExecutor.newTimeout(new TimerTask() { @Override public void run(Timeout timeout) { fsm.sendEvent(new HandshakeTimeoutEvent()); } }, 30, TimeUnit.SECONDS); } else { return null; } }
private Timeout newTimeout() { if (requestTimeoutInMs > 0) { return timeoutExecutor.newTimeout(new TimerTask() { @Override public void run(Timeout timeout) { fsm.sendEvent(new HandshakeTimeoutEvent()); } }, 30, TimeUnit.SECONDS); } else { return null; } }
private Timeout newTimeout(final StateMachine.Event timeoutEvent) { if (requestTimeoutInMs > 0) { return timeoutExecutor.newTimeout(new TimerTask() { @Override public void run(Timeout timeout) { fsm.sendEvent(timeoutEvent); } }, requestTimeoutInMs, TimeUnit.MILLISECONDS); } else { return null; } }
private Timeout newTimeout(final StateMachine.Event timeoutEvent) { if (requestTimeoutInMs > 0) { return timeoutExecutor.newTimeout(new TimerTask() { @Override public void run(Timeout timeout) { fsm.sendEvent(timeoutEvent); } }, requestTimeoutInMs, TimeUnit.MILLISECONDS); } else { return null; } }
/** * Starts the collector. */ public synchronized void start() { log.info("Starting Tunnel Stats collection thread for {}", pcepTunnelId); stopped = false; timeout = timer.newTimeout(this, 1, TimeUnit.SECONDS); }
ConnectionFailedState(final StateMachine.Fsm fsm, final Throwable exception) { super(fsm); LOG.debug("NEW STATE: CONNECTION FAILED [RE-CONNECTION BACKOFF]"); this.exception = exception; reconnectionTimeoutExecutor.newTimeout(new TimerTask() { @Override public void run(Timeout timeout) { fsm.sendEvent(new ReconnectEvent()); } }, tsoReconnectionDelayInSecs, TimeUnit.SECONDS); }
ConnectionFailedState(final StateMachine.Fsm fsm, final Throwable exception) { super(fsm); LOG.debug("NEW STATE: CONNECTION FAILED [RE-CONNECTION BACKOFF]"); this.exception = exception; reconnectionTimeoutExecutor.newTimeout(new TimerTask() { @Override public void run(Timeout timeout) { fsm.sendEvent(new ReconnectEvent()); } }, tsoReconnectionDelayInSecs, TimeUnit.SECONDS); }
/** * Starts the collector. */ public synchronized void start() { log.info("Starting Port Stats collection thread for {}", sw.getStringId()); stopped = false; timeout = timer.newTimeout(this, 1, TimeUnit.SECONDS); }
/** * Starts the collector. */ public void start() { log.info("Starting Group Stats collection thread for {}", sw.getStringId()); timeout = timer.newTimeout(this, 1, TimeUnit.SECONDS); }
private void scheduleHandshake() { if (clientConfig.getPeriodicHandshakeIntervalMs() > 0) { periodicHandshakeTask = timer.newTimeout(this, clientConfig.getPeriodicHandshakeIntervalMs(), TimeUnit.MILLISECONDS); } }
@Override public void run(Timeout to) throws Exception { for (DeviceId devId : flowTable.keySet()) { providerService.pushFlowMetrics(devId, flowTable .getOrDefault(devId, Collections.emptySet())); } timeout = timer.newTimeout(to.getTask(), 5, TimeUnit.SECONDS); } }
private void scheduleHandshake() { if (clientConfig.getPeriodicHandshakeIntervalMs() > 0) { periodicHandshakeTask = timer.newTimeout(this, clientConfig.getPeriodicHandshakeIntervalMs(), TimeUnit.MILLISECONDS); } }
public ResponseHandler(Connection connection, ResponseCallback callback) throws BusyConnectionException { this.connection = connection; this.streamId = connection.dispatcher.streamIdHandler.next(); this.callback = callback; long timeoutMs = connection.factory.getReadTimeoutMillis(); this.timeout = timeoutMs <= 0 ? null : connection.factory.timer.newTimeout(onTimeoutTask(), timeoutMs, TimeUnit.MILLISECONDS); this.startTime = System.nanoTime(); }
@Activate public void activate(ComponentContext context) { providerService = providerRegistry.register(this); timeout = timer.newTimeout(new StatisticTask(), 5, TimeUnit.SECONDS); applyRule(); modified(context); log.info("Started"); }