/** * May be overridden to provide an alternate executor service. * @return by default, {@link Timer#get} */ protected ExecutorService executorService() { return Timer.get(); }
private void schedule(long interval) { Timer.get() .scheduleAtFixedRate(new SafeTimerTask() { public void doRun() { triggerUpdate(); } }, interval, interval, TimeUnit.MILLISECONDS); }
private void periodic() { long interval = 5000; Timer.get().scheduleWithFixedDelay(this, interval, interval, TimeUnit.MILLISECONDS); }
/** * Triggers the update with 5 seconds quiet period, to avoid triggering data check too often * when multiple agents become online at about the same time. */ @Override public void onOnline(Computer c, TaskListener listener) throws IOException, InterruptedException { synchronized(this) { future.cancel(false); future = Timer.get().schedule(MONITOR_UPDATER, 5, TimeUnit.SECONDS); } } }
/** * Schedules the next execution. */ public void schedule() { // randomize the scheduling so that multiple Hudson instances will write at the file at different time long MINUTE = 1000*60; Timer.get() .schedule(new SafeTimerTask() { protected void doRun() { execute(); } }, (random.nextInt(30) + 60) * MINUTE, TimeUnit.MILLISECONDS); }
private void push() { if (DELAY_SECONDS < 0) return; synchronized (lock) { // Can be done or canceled in case of a bug or external intervention - do not allow it to hang there forever if (nextSave != null && !(nextSave.isDone() || nextSave.isCancelled())) return; nextSave = Timer.get().schedule(this, DELAY_SECONDS, TimeUnit.SECONDS); } }
/** * Rebuilds the dependency map asynchronously. * * <p> * This would keep the UI thread more responsive and helps avoid the deadlocks, * as dependency graph recomputation tends to touch a lot of other things. * * @since 1.522 */ public Future<DependencyGraph> rebuildDependencyGraphAsync() { dependencyGraphDirty.set(true); return Timer.get().schedule(new java.util.concurrent.Callable<DependencyGraph>() { @Override public DependencyGraph call() throws Exception { if (dependencyGraphDirty.get()) { rebuildDependencyGraph(); } return dependencyGraph; } }, 500, TimeUnit.MILLISECONDS); }
@Initializer(after= JOB_LOADED) public static void init() { // start monitoring nodes, although there's no hurry. Timer.get().schedule(new SafeTimerTask() { public void doRun() { ComputerSet.initialize(); } }, 10, TimeUnit.SECONDS); }
private static void scheduleAperiodWork(AperiodicWork ap) { Timer.get().schedule(ap, ap.getInitialDelay(), TimeUnit.MILLISECONDS); }
private static void schedulePeriodicWork(PeriodicWork p) { Timer.get().scheduleAtFixedRate(p, p.getInitialDelay(), p.getRecurrencePeriod(), TimeUnit.MILLISECONDS); }
@Override public final void doRun() throws Exception{ doAperiodicRun(); Timer.get().schedule(getNewInstance(), getRecurrencePeriod(), TimeUnit.MILLISECONDS); }
Timer.get().scheduleAtFixedRate(new SafeTimerTask() { @Override protected void doRun() throws Exception {
/** * May be overridden to provide an alternate executor service. * @return by default, {@link Timer#get} */ protected ExecutorService executorService() { return Timer.get(); }
private void schedule(long interval) { Timer.get() .scheduleAtFixedRate(new SafeTimerTask() { public void doRun() { triggerUpdate(); } }, interval, interval, TimeUnit.MILLISECONDS); }
private void periodic() { long interval = 5000; Timer.get().scheduleWithFixedDelay(this, interval, interval, TimeUnit.MILLISECONDS); }
/** * Triggers the update with 5 seconds quiet period, to avoid triggering data check too often * when multiple agents become online at about the same time. */ @Override public void onOnline(Computer c, TaskListener listener) throws IOException, InterruptedException { synchronized(this) { future.cancel(false); future = Timer.get().schedule(MONITOR_UPDATER, 5, TimeUnit.SECONDS); } } }
@Initializer(after= JOB_LOADED) public static void init() { // start monitoring nodes, although there's no hurry. Timer.get().schedule(new SafeTimerTask() { public void doRun() { ComputerSet.initialize(); } }, 10, TimeUnit.SECONDS); }
@Initializer(after= JOB_LOADED) public static void init() { // start all AperidocWorks for (AperiodicWork p : AperiodicWork.all()) { Timer.get().schedule(p, p.getInitialDelay(), TimeUnit.MILLISECONDS); } }
@Override public final void doRun() throws Exception{ doAperiodicRun(); Timer.get().schedule(getNewInstance(), getRecurrencePeriod(), TimeUnit.MILLISECONDS); }
@Initializer(after= JOB_LOADED) public static void init() { // start all PeriodicWorks for (PeriodicWork p : PeriodicWork.all()) { Timer.get().scheduleAtFixedRate(p, p.getInitialDelay(), p.getRecurrencePeriod(), TimeUnit.MILLISECONDS); } }