use of co.cask.cdap.internal.app.runtime.schedule.queue.JobQueueDataset in project cdap by caskdata.
the class CoreSchedulerService method cleanupJobs.
// Attempts to remove all jobs that are in PENDING_LAUNCH state.
// These are jobs that were about to be launched, but the scheduler shut down or crashed after the job was marked
// PENDING_LAUNCH, but before they were actually launched.
// This should only be called at startup.
private void cleanupJobs() {
try {
transactional.execute(context -> {
JobQueueDataset jobQueue = Schedulers.getJobQueue(context, datasetFramework);
try (CloseableIterator<Job> jobIter = jobQueue.fullScan()) {
LOG.info("Cleaning up jobs in state {}.", Job.State.PENDING_LAUNCH);
while (jobIter.hasNext()) {
Job job = jobIter.next();
if (job.getState() == Job.State.PENDING_LAUNCH) {
LOG.warn("Removing job because it was left in state {} from a previous run of the scheduler: {} .", Job.State.PENDING_LAUNCH, job);
jobQueue.deleteJob(job);
}
}
}
});
} catch (TransactionFailureException exception) {
LOG.warn("Failed to cleanup jobs upon startup.", exception);
}
}
use of co.cask.cdap.internal.app.runtime.schedule.queue.JobQueueDataset in project cdap by caskdata.
the class CoreSchedulerService method execute.
private <V, T extends Exception> V execute(final StoreAndQueueTxRunnable<V, T> runnable, final Class<? extends T> tClass) throws T {
return Transactionals.execute(transactional, context -> {
ProgramScheduleStoreDataset store = Schedulers.getScheduleStore(context, datasetFramework);
JobQueueDataset queue = Schedulers.getJobQueue(context, datasetFramework);
return runnable.run(store, queue);
}, tClass);
}
Aggregations