@Override public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return scheduleAtFixedRate(command, initialDelay, period, unit, false); }
/** * Shuts down all shared scheduled executors. * This is not intended to be called by application directly. */ public static void shutdown() { singleThreadExecutor.backingExecutor().shutdown(); poolThreadExecutor.backingExecutor().shutdown(); } }
@Override public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { return schedule(command, delay, unit, false); }
/** * Creates and executes a one-shot action that becomes enabled * after the given delay. * * @param command the task to execute * @param delay the time from now to delay execution * @param unit the time unit of the delay parameter * @param repeatFlag the flag to denote whether to restart a failed task * @return a ScheduledFuture representing pending completion of * the task and whose {@code get()} method will return * {@code null} upon completion */ public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit, boolean repeatFlag) { return executor.schedule(wrap(command, repeatFlag), delay, unit); }
@Override public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) { return scheduleWithFixedDelay(command, initialDelay, delay, unit, false); }
/** * Configures the shared scheduled thread pool size. * * @param poolSize new pool size */ public static void setPoolSize(int poolSize) { checkArgument(poolSize > 0, "Shared pool size size must be greater than 0"); poolThreadExecutor.setBackingExecutor( newScheduledThreadPool(poolSize, groupedThreads("onos/shared/scheduled", "onos-pool-executor-%d"))); }
/** * Creates and executes a periodic action that becomes enabled first * after the given initial delay, and subsequently with the * given delay between the termination of one execution and the * commencement of the next. * Depends on the repeat flag that the user set, the failed tasks can be * either restarted or terminated. If the repeat flag is set to to true, * ant execution of the task encounters an exception, subsequent executions * are permitted, otherwise, subsequent executions are suppressed. * * @param command the task to execute * @param initialDelay the time to delay first execution * @param delay the delay between the termination of one * execution and the commencement of the next * @param unit the time unit of the initialDelay and delay parameters * @param repeatFlag the flag to denote whether to restart a failed task * @return a ScheduledFuture representing pending completion of * the task, and whose {@code get()} method will throw an * exception upon cancellation */ public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit, boolean repeatFlag) { return executor.scheduleWithFixedDelay(wrap(command, repeatFlag), initialDelay, delay, unit); }
@Override public void switchAdded(Dpid dpid) { if (providerService == null) { return; } DeviceId deviceId = deviceId(uri(dpid)); OpenFlowControlMessageAggregator ofcma = new OpenFlowControlMessageAggregator(metricsService, providerService, deviceId); ScheduledFuture result = executor.scheduleAtFixedRate(ofcma, AGGR_INIT_DELAY, AGGR_PERIOD, AGGR_TIME_UNIT, true); aggregators.put(dpid, ofcma); executorResults.put(dpid, result); }
/** * Creates and executes a periodic action that becomes enabled first * after the given initial delay, and subsequently with the given * period; that is executions will commence after * {@code initialDelay} then {@code initialDelay+period}, then * {@code initialDelay + 2 * period}, and so on. * Depends on the repeat flag that the user set, the failed tasks can be * either restarted or terminated. If the repeat flag is set to to true, * ant execution of the task encounters an exception, subsequent executions * are permitted, otherwise, subsequent executions are suppressed. * If any execution of this task takes longer than its period, then * subsequent executions may start late, but will not concurrently execute. * * @param command the task to execute * @param initialDelay the time to delay first execution * @param period the period between successive executions * @param unit the time unit of the initialDelay and period parameters * @param repeatFlag the flag to denote whether to restart a failed task * @return a ScheduledFuture representing pending completion of * the task, and whose {@code get()} method will throw an * exception upon cancellation */ public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit, boolean repeatFlag) { return executor.scheduleAtFixedRate(wrap(command, repeatFlag), initialDelay, period, unit); }
/** * Executes one-shot timer task on shared thread pool. * * @param task timer task to execute * @param delay before executing the task * @param unit of delay * @return a ScheduledFuture representing pending completion of the task * and whose get() method will return null upon completion */ public static ScheduledFuture<?> newTimeout(Runnable task, long delay, TimeUnit unit) { return SharedScheduledExecutors.getPoolThreadExecutor() .schedule(task, delay, unit); }