/** * Create a new instance using a new {@link HashedWheelTimer} and no {@link ThreadNameDeterminer} * * @param bossExecutor the Executor to use for server the {@link NioClientBoss} * @param bossCount the number of {@link NioClientBoss} instances this {@link NioClientBoss} will hold */ public NioClientBossPool(Executor bossExecutor, int bossCount) { this(bossExecutor, bossCount, new HashedWheelTimer(), null); stopTimer = true; }
@Override public void stop() { timer.stop(); } }
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 Timer newNettyTimer() { HashedWheelTimer timer = new HashedWheelTimer(); timer.start(); return timer; }
@Override public void start() { timer.start(); }
@Override public HashedWheelTimer get() { HashedWheelTimer timer = new HashedWheelTimer(); timer.start(); return timer; } });
@Override public void startService() { super.startService(); this.hashedWheelTimer.start(); }
@Deprecated // use createClient directly public static ClientBootstrap createBootstrap(Lifecycle lifecycle) { final Timer timer = new HashedWheelTimer(new ThreadFactoryBuilder().setDaemon(true).build()); return createBootstrap(lifecycle, timer); }
private Timer newNettyTimer() { HashedWheelTimer timer = new HashedWheelTimer(); timer.start(); return timer; }
@Override public void stopService() { this.hashedWheelTimer.stop(); super.stopService(); }
private void scheduleHandshake() { if (clientConfig.getPeriodicHandshakeIntervalMs() > 0) { periodicHandshakeTask = timer.newTimeout(this, clientConfig.getPeriodicHandshakeIntervalMs(), TimeUnit.MILLISECONDS); } }
public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } start(); // Add the timeout to the timeout queue which will be processed on the next tick. // During processing all the queued HashedWheelTimeouts will be added to the correct HashedWheelBucket. long deadline = System.nanoTime() + unit.toNanos(delay) - startTime; HashedWheelTimeout timeout = new HashedWheelTimeout(this, task, deadline); timeouts.add(timeout); return timeout; }
ConsistentHashRoutingService(ServerSetWatcher serverSetWatcher, int numReplicas, int blackoutSeconds, StatsReceiver statsReceiver) { super(serverSetWatcher); this.circle = new ConsistentHash(hashFunction, numReplicas, statsReceiver.scope("ring")); this.hashedWheelTimer = new HashedWheelTimer(new ThreadFactoryBuilder() .setNameFormat("ConsistentHashRoutingService-Timer-%d").build()); this.blackoutSeconds = blackoutSeconds; // stats this.statsReceiver = statsReceiver; this.numBlackoutHosts = new AtomicInteger(0); this.numBlackoutHostsGauge = this.statsReceiver.addGauge(gaugeName("num_blackout_hosts"), new Function0<Object>() { @Override public Object apply() { return (float) numBlackoutHosts.get(); } }); this.numHostsGauge = this.statsReceiver.addGauge(gaugeName("num_hosts"), new Function0<Object>() { @Override public Object apply() { return (float) address2ShardId.size(); } }); }
private Timer newNettyTimer() { HashedWheelTimer timer = new HashedWheelTimer(); timer.start(); return timer; }
public void close() { closeLock.writeLock().lock(); try { if (closed) { return; } closed = true; } finally { closeLock.writeLock().unlock(); } clientManager.close(); routingService.unregisterListener(this); routingService.stopService(); dlTimer.stop(); }
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; } }); }
@Override public void start() throws Exception { timer.start(); }
public void start() throws Exception { ServerBootstrap bootstrap = new ServerBootstrap(selector); // Timer is shared across entire factory and must be released separately timer = new HashedWheelTimer(); try { pipelineFact = new HttpPipelineFactory(conf, timer); } catch (Exception ex) { throw new RuntimeException(ex); } bootstrap.setPipelineFactory(pipelineFact); bootstrap.setOption("backlog", NetUtil.SOMAXCONN); port = conf.getInt(SHUFFLE_PORT_CONFIG_KEY, DEFAULT_SHUFFLE_PORT); Channel ch = bootstrap.bind(new InetSocketAddress(port)); accepted.add(ch); port = ((InetSocketAddress)ch.getLocalAddress()).getPort(); conf.set(SHUFFLE_PORT_CONFIG_KEY, Integer.toString(port)); pipelineFact.SHUFFLE.setPort(port); if (dirWatcher != null) { dirWatcher.start(); } LOG.info("LlapShuffleHandler" + " listening on port " + port + " (SOMAXCONN: " + bootstrap.getOption("backlog") + ")"); }
private Timer newNettyTimer() { HashedWheelTimer timer = new HashedWheelTimer(); timer.start(); return timer; }
requestTimer.stop(); LOG.info("Stopped request timer"); SchedulerUtils.shutdownScheduler(lockStateExecutor, 5000, TimeUnit.MILLISECONDS);