@Override public long getDelay(TimeUnit unit) { return scheduledDelegate.getDelay(unit); }
@Override protected String pendingToString() { ListenableFuture<? extends V> localInputFuture = delegateRef; ScheduledFuture<?> localTimer = timer; if (localInputFuture != null) { String message = "inputFuture=[" + localInputFuture + "]"; if (localTimer != null) { final long delay = localTimer.getDelay(TimeUnit.MILLISECONDS); // Negative delays look confusing in an error message if (delay > 0) { message += ", remaining delay=[" + delay + " ms]"; } } return message; } return null; }
@Override public long getDelay(TimeUnit unit) { return scheduledDelegate.getDelay(unit); }
@Override public long getDelay(TimeUnit unit) { return scheduledDelegate.getDelay(unit); }
@Override public long getDelay(TimeUnit unit) { return scheduledDelegate.getDelay(unit); }
@Override public long getDelay(TimeUnit unit) { return scheduledDelegate.getDelay(unit); }
@Override public long getDelay(TimeUnit unit) { return delegate.getDelay(unit); }
public long getRemainingDelay() { return future.getDelay(TimeUnit.MILLISECONDS); }
@Override public long getDelay(TimeUnit unit) { ScheduledFuture<?> curr; synchronized (this.triggerContextMonitor) { curr = obtainCurrentFuture(); } return curr.getDelay(unit); }
/** * Get remaining expiration time * * @param key Key * @return Remaining time in milliseconds or 0 if no delay or key doesn't exist */ public long getExpirationDelayMillis(ByteArrayWrapper key) { ScheduledFuture<?> future = this.expirationsMap.get(key); return future != null ? future.getDelay(TimeUnit.MILLISECONDS) : 0L; }
@Override public long getDelay(TimeUnit unit) { ScheduledFuture<?> curr; synchronized (this.triggerContextMonitor) { curr = obtainCurrentFuture(); } return curr.getDelay(unit); }
/** * Provide a human-readable explanation of why this future has not yet completed. * * @return null if an explanation cannot be provided because the future is done. * @since 23.0 */ protected @Nullable String pendingToString() { Object localValue = value; if (localValue instanceof SetFuture) { return "setFuture=[" + userObjectToString(((SetFuture) localValue).future) + "]"; } else if (this instanceof ScheduledFuture) { return "remaining delay=[" + ((ScheduledFuture) this).getDelay(TimeUnit.MILLISECONDS) + " ms]"; } return null; }
/** * Provide a human-readable explanation of why this future has not yet completed. * * @return null if an explanation cannot be provided because the future is done. * @since 23.0 */ @NullableDecl protected String pendingToString() { Object localValue = value; if (localValue instanceof SetFuture) { return "setFuture=[" + userObjectToString(((SetFuture) localValue).future) + "]"; } else if (this instanceof ScheduledFuture) { return "remaining delay=[" + ((ScheduledFuture) this).getDelay(TimeUnit.MILLISECONDS) + " ms]"; } return null; }
/** * For JMX to forget about all previously exported metrics. */ public static void clearJmxCache() { if (LOG.isTraceEnabled()) { LOG.trace("clearing JMX Cache" + StringUtils.stringifyException(new Exception())); } //If there are more then 100 ms before the executor will run then everything should be merged. ScheduledFuture future = fut.get(); if ((future != null && (!future.isDone() && future.getDelay(TimeUnit.MILLISECONDS) > 100))) { // BAIL OUT return; } if (stopped.get()) { return; } future = executor.getExecutor().schedule(new JmxCacheBusterRunnable(), 5, TimeUnit.SECONDS); fut.set(future); }
/** * Provide a human-readable explanation of why this future has not yet completed. * * @return null if an explanation cannot be provided because the future is done. * @since 23.0 */ @NullableDecl protected String pendingToString() { Object localValue = value; if (localValue instanceof SetFuture) { return "setFuture=[" + userObjectToString(((SetFuture) localValue).future) + "]"; } else if (this instanceof ScheduledFuture) { return "remaining delay=[" + ((ScheduledFuture) this).getDelay(TimeUnit.MILLISECONDS) + " ms]"; } return null; }
/** * Provide a human-readable explanation of why this future has not yet completed. * * @return null if an explanation cannot be provided because the future is done. * @since 23.0 */ @NullableDecl protected String pendingToString() { Object localValue = value; if (localValue instanceof SetFuture) { return "setFuture=[" + userObjectToString(((SetFuture) localValue).future) + "]"; } else if (this instanceof ScheduledFuture) { return "remaining delay=[" + ((ScheduledFuture) this).getDelay(TimeUnit.MILLISECONDS) + " ms]"; } return null; }
/** * Schedule an execution of a task. This will either add the task to the execution service, or if * a task has already been scheduled through this decorator and is still pending execution it will * return the future associated with the previously scheduled task. * * @param runnable a runnable to execution * @param delay the time to delay before execution * @param unit the time unit * @return The future associated with this task, or with a previously scheduled task if that task * has not yet been run. * @see ScheduledExecutorService#schedule(Runnable, long, TimeUnit) */ public ScheduledFuture<?> schedule(Runnable runnable, long delay, TimeUnit unit) { synchronized (this) { if (future == null || future.isCancelled() || future.isDone() || future.getDelay(unit) > delay) { if (future != null && !future.isDone()) { future.cancel(false); listener.taskDropped(); } future = ex.schedule(new DelegatingRunnable(runnable), delay, unit); } else { listener.taskDropped(); } } return future; }
/** * Schedule an execution of a task. This will either add the task to the execution service, or if * a task has already been scheduled through this decorator and is still pending execution it will * return the future associated with the previously scheduled task. * * @param callable a callable to execute * @param delay the time to delay before execution * @param unit the time unit * @return The future associated with this task, or with a previously scheduled task if that task * has not yet been run. * @see ScheduledExecutorService#schedule(Runnable, long, TimeUnit) */ public <T> ScheduledFuture<?> schedule(Callable<T> callable, long delay, TimeUnit unit) { synchronized (this) { if (future == null || future.isCancelled() || future.isDone() || future.getDelay(unit) > delay) { if (future != null && !future.isDone()) { future.cancel(false); listener.taskDropped(); } future = ex.schedule(new DelegatingCallable<T>(callable), delay, unit); } else { listener.taskDropped(); } } return future; }
String message = "Timed out"; if (timer != null) { long overDelayMs = Math.abs(timer.getDelay(TimeUnit.MILLISECONDS)); if (overDelayMs > 10) { // Not all timing drift is worth reporting message += " (timeout delayed by " + overDelayMs + " ms after scheduled time)";
long delayms = 0; if(scheduledFuture != null) { delayms = scheduledFuture.getDelay(TimeUnit.MILLISECONDS);