List of usage examples for org.springframework.scheduling TaskScheduler schedule
ScheduledFuture<?> schedule(Runnable task, Date startTime);
From source file:io.pivotal.strepsirrhini.chaosloris.destroyer.DestructionScheduler.java
private static Mono<ScheduledFuture<?>> schedule(TaskScheduler taskScheduler, Destroyer destroyer, String expression) {//from ww w .j a va 2 s .c om return Mono.just(taskScheduler.schedule(destroyer, new CronTrigger(expression))); }
From source file:org.trustedanalytics.serviceexposer.checker.CheckerScheduler.java
public void start() { LOG.info("Preparing CheckerScheduler"); TaskScheduler s = new DefaultManagedTaskScheduler(); s.schedule(checkingJob::run, new CronTrigger(checkerTriggerExpression)); LOG.info("CheckerScheduler started {}", checkerTriggerExpression); }
From source file:org.trustedanalytics.serviceexposer.nats.registrator.RegistratorScheduler.java
public void start() { LOG.info("Preparing RegistratorScheduler"); TaskScheduler s = new DefaultManagedTaskScheduler(); s.schedule(registeringJob::run, new CronTrigger(natsTriggerExpression)); LOG.info("RegistratorScheduler started {}", natsTriggerExpression); }
From source file:org.trustedanalytics.routermetrics.gathering.Scheduler.java
@PostConstruct public void start() { TaskScheduler s = new DefaultManagedTaskScheduler(); s.schedule(gatheringJob::run, new CronTrigger(triggerExpression)); LOG.info("Scheduler started {}", triggerExpression); }
From source file:com.netflix.genie.web.tasks.node.DiskCleanupTask.java
/** * Constructor. Schedules this task to be run by the task scheduler. * * @param properties The disk cleanup properties to use. * @param scheduler The scheduler to use to schedule the cron trigger. * @param jobsDir The resource representing the location of the job directory * @param jobSearchService The service to find jobs with * @param jobsProperties The jobs properties to use * @param processExecutor The process executor to use to delete directories * @param registry The metrics registry * @throws IOException When it is unable to open a file reference to the job directory *//*from ww w. ja va 2 s .c o m*/ @Autowired public DiskCleanupTask(@NotNull final DiskCleanupProperties properties, @NotNull final TaskScheduler scheduler, @NotNull final Resource jobsDir, @NotNull final JobSearchService jobSearchService, @NotNull final JobsProperties jobsProperties, @NotNull final Executor processExecutor, @NotNull final Registry registry) throws IOException { // Job Directory is guaranteed to exist by the MvcConfig bean creation but just in case someone overrides if (!jobsDir.exists()) { throw new IOException("Jobs dir " + jobsDir + " doesn't exist. Unable to create task to cleanup."); } this.properties = properties; this.jobsDir = jobsDir.getFile(); this.jobSearchService = jobSearchService; this.runAsUser = jobsProperties.getUsers().isRunAsUserEnabled(); this.processExecutor = processExecutor; this.numberOfDeletedJobDirs = registry.gauge("genie.tasks.diskCleanup.numberDeletedJobDirs.gauge", new AtomicLong()); this.numberOfDirsUnableToDelete = registry.gauge("genie.tasks.diskCleanup.numberDirsUnableToDelete.gauge", new AtomicLong()); this.unableToGetJobCounter = registry.counter("genie.tasks.diskCleanup.unableToGetJobs.rate"); this.unableToDeleteJobDirCounter = registry.counter("genie.tasks.diskCleanup.unableToDeleteJobsDir.rate"); // Only schedule the task if we don't need sudo while on a non-unix system if (this.runAsUser && !SystemUtils.IS_OS_UNIX) { log.error("System is not UNIX like. Unable to schedule disk cleanup due to needing Unix commands"); } else { final CronTrigger trigger = new CronTrigger(properties.getExpression(), JobConstants.UTC); scheduler.schedule(this, trigger); } }
From source file:org.craftercms.deployer.impl.TargetImpl.java
@Override public void scheduleDeployment(TaskScheduler scheduler, String cronExpression) { scheduledDeploymentFuture = scheduler.schedule(new ScheduledDeploymentTask(), new CronTrigger(cronExpression)); }
From source file:org.springframework.integration.jms.JmsOutboundGateway.java
@Override public void start() { synchronized (this.lifeCycleMonitor) { if (!this.active) { if (this.replyContainer != null) { TaskScheduler taskScheduler = getTaskScheduler(); if (this.idleReplyContainerTimeout <= 0) { this.replyContainer.start(); } else { Assert.state(taskScheduler != null, "'taskScheduler' is required."); }/*w ww .j av a 2 s . co m*/ if (!isAsync() && this.receiveTimeout >= 0) { Assert.state(taskScheduler != null, "'taskScheduler' is required."); this.reaper = taskScheduler.schedule(new LateReplyReaper(), new Date()); } } this.active = true; } } }
From source file:org.springframework.statemachine.state.AbstractState.java
/** * Schedule action and return future which can be used to cancel it. * * @param action the action/*from w w w . j ava2 s.c o m*/ * @param context the context * @return the scheduled future */ protected ScheduledFuture<?> scheduleAction(final Action<S, E> action, final StateContext<S, E> context) { TaskScheduler taskScheduler = getTaskScheduler(); if (taskScheduler == null) { log.error("Unable to schedule action as taskSchedule is not set, action=[" + action + "]"); return null; } ScheduledFuture<?> future = taskScheduler.schedule(new Runnable() { @Override public void run() { executeAction(action, context); } }, new Date()); return future; }
From source file:org.springframework.vault.authentication.LifecycleAwareSessionManager.java
private void scheduleTask(TaskScheduler taskScheduler, int seconds, Runnable task) { taskScheduler.schedule(task, new OneShotTrigger(seconds)); }