@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } long pendingTimeoutsCount = pendingTimeouts.incrementAndGet(); if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) { pendingTimeouts.decrementAndGet(); throw new RejectedExecutionException("Number of pending timeouts (" + pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending " + "timeouts (" + maxPendingTimeouts + ")"); } 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; // Guard against overflow. if (delay > 0 && deadline < 0) { deadline = Long.MAX_VALUE; } HashedWheelTimeout timeout = new HashedWheelTimeout(this, task, deadline); timeouts.add(timeout); return timeout; }
public PullMessageProcessor(final DynamicConfig config, final ActorSystem actorSystem, final MessageStoreWrapper messageStoreWrapper, final SubscriberStatusChecker subscriberStatusChecker) { this.config = config; this.actorSystem = actorSystem; this.subscriberStatusChecker = subscriberStatusChecker; this.pullMessageWorker = new PullMessageWorker(messageStoreWrapper, actorSystem); this.timer.start(); }
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } long pendingTimeoutsCount = pendingTimeouts.incrementAndGet(); if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) { pendingTimeouts.decrementAndGet(); throw new RejectedExecutionException("Number of pending timeouts (" + pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending " + "timeouts (" + maxPendingTimeouts + ")"); } 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; // Guard against overflow. if (delay > 0 && deadline < 0) { deadline = Long.MAX_VALUE; } HashedWheelTimeout timeout = new HashedWheelTimeout(this, task, deadline); timeouts.add(timeout); return timeout; }
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } long pendingTimeoutsCount = pendingTimeouts.incrementAndGet(); if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) { pendingTimeouts.decrementAndGet(); throw new RejectedExecutionException("Number of pending timeouts (" + pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending " + "timeouts (" + maxPendingTimeouts + ")"); } 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; // Guard against overflow. if (delay > 0 && deadline < 0) { deadline = Long.MAX_VALUE; } HashedWheelTimeout timeout = new HashedWheelTimeout(this, task, deadline); timeouts.add(timeout); return timeout; }
public HeartbeatManager() { this.timeouts = new ConcurrentHashMap<>(); this.timer = new HashedWheelTimer(new NamedThreadFactory("qmq-heartbeat")); this.timer.start(); }
private Timer newNettyTimer(AsyncHttpClientConfig config) { ThreadFactory threadFactory = config.getThreadFactory() != null ? config.getThreadFactory() : new DefaultThreadFactory(config.getThreadPoolName() + "-timer"); HashedWheelTimer timer = new HashedWheelTimer(threadFactory); timer.start(); return timer; }
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } long pendingTimeoutsCount = pendingTimeouts.incrementAndGet(); if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) { pendingTimeouts.decrementAndGet(); throw new RejectedExecutionException("Number of pending timeouts (" + pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending " + "timeouts (" + maxPendingTimeouts + ")"); } 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; // Guard against overflow. if (delay > 0 && deadline < 0) { deadline = Long.MAX_VALUE; } HashedWheelTimeout timeout = new HashedWheelTimeout(this, task, deadline); timeouts.add(timeout); return timeout; }
/** * Start the ping manager. This method starts the hashed wheel timer. */ @Override protected void doStart() { hashedWheelTimer.start(); notifyStarted(); }
private Timer newNettyTimer() { HashedWheelTimer timer = new HashedWheelTimer(); timer.start(); return timer; }
private Timer newNettyTimer() { HashedWheelTimer timer = new HashedWheelTimer(); timer.start(); return timer; }
@Override public HashedWheelTimer create() { HashedWheelTimer timer = new HashedWheelTimer( new ThreadFactoryBuilder() .setNameFormat(name + "-%d") .build(), 200, TimeUnit.MILLISECONDS, 512, true); timer.start(); return timer; }
public void start(SipStackImpl sipStack, Properties configurationProperties) { sipStackImpl= sipStack; // TODO have a param in the stack properties to set the number of thread for the timer executor hashedWheelSipTimer.start(); started.set(true); if(logger.isLoggingEnabled(StackLogger.TRACE_INFO)) { logger.logInfo("the sip stack timer " + this.getClass().getName() + " has been started"); } } /*
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { final long currentTime = System.currentTimeMillis(); if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } if (!workerThread.isAlive()) { start(); } delay = unit.toMillis(delay); HashedWheelTimeout timeout = new HashedWheelTimeout(task, currentTime + delay); scheduleTimeout(timeout, delay); return timeout; }
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } long pendingTimeoutsCount = pendingTimeouts.incrementAndGet(); if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) { pendingTimeouts.decrementAndGet(); throw new RejectedExecutionException("Number of pending timeouts (" + pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending " + "timeouts (" + maxPendingTimeouts + ")"); } 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; // Guard against overflow. if (delay > 0 && deadline < 0) { deadline = Long.MAX_VALUE; } HashedWheelTimeout timeout = new HashedWheelTimeout(this, task, deadline); timeouts.add(timeout); return timeout; }
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } long pendingTimeoutsCount = pendingTimeouts.incrementAndGet(); if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) { pendingTimeouts.decrementAndGet(); throw new RejectedExecutionException("Number of pending timeouts (" + pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending " + "timeouts (" + maxPendingTimeouts + ")"); } 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; // Guard against overflow. if (delay > 0 && deadline < 0) { deadline = Long.MAX_VALUE; } HashedWheelTimeout timeout = new HashedWheelTimeout(this, task, deadline); timeouts.add(timeout); return timeout; }
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } long pendingTimeoutsCount = pendingTimeouts.incrementAndGet(); if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) { pendingTimeouts.decrementAndGet(); throw new RejectedExecutionException("Number of pending timeouts (" + pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending " + "timeouts (" + maxPendingTimeouts + ")"); } 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; // Guard against overflow. if (delay > 0 && deadline < 0) { deadline = Long.MAX_VALUE; } HashedWheelTimeout timeout = new HashedWheelTimeout(this, task, deadline); timeouts.add(timeout); return timeout; }
@Setup public void setup() { timer = new HashedWheelTimer(10L, TimeUnit.MILLISECONDS); timer.start(); }
/** * Function called when the activator starts just after some * initializations are done by the * ComponentActivatorAbstractBase. * */ @Override public void init() { openDoveGC = new OpenDoveGC(); scheduler = new HashedWheelTimer(1000, TimeUnit.MILLISECONDS); openDoveGC.setTimer(scheduler); scheduler.newTimeout(openDoveGC, 5000, TimeUnit.MILLISECONDS); scheduler.start(); }
/** * Starts Socket.IO server with current configuration settings. * * @throws IllegalStateException * if server already started */ public synchronized void start() { if (isStarted()) { throw new IllegalStateException("Failed to start Socket.IO server: server already started"); } log.info("Socket.IO server starting"); // Configure heartbeat scheduler timer = new HashedWheelTimer(); timer.start(); SocketIOHeartbeatScheduler.setHashedWheelTimer(timer); SocketIOHeartbeatScheduler.setHeartbeatInterval(configuration.getHeartbeatInterval()); SocketIOHeartbeatScheduler.setHeartbeatTimeout(configuration.getHeartbeatTimeout()); // Configure and bind server ServerBootstrapFactory bootstrapFactory = serverBootstrapFactory != null ? serverBootstrapFactory : new DefaultServerBootstrapFactory(configuration); bootstrap = bootstrapFactory.createServerBootstrap(); bootstrap.childHandler(new SocketIOChannelInitializer(configuration, listener, pipelineModifier)); bootstrap.bind(configuration.getPort()).syncUninterruptibly(); state = State.STARTED; log.info("Socket.IO server started: {}", configuration); }