use of io.cdap.cdap.internal.app.runtime.schedule.queue.JobQueueTable in project cdap by caskdata.
the class CoreSchedulerService method execute.
@SuppressWarnings("UnusedReturnValue")
private <V, T extends Exception> V execute(StoreQueueAndProfileTxRunnable<V, ? extends Exception> runnable, Class<? extends T> tClass) throws T {
return TransactionRunners.run(transactionRunner, context -> {
ProgramScheduleStoreDataset store = Schedulers.getScheduleStore(context);
ProfileStore profileStore = ProfileStore.get(context);
JobQueueTable queue = JobQueueTable.getJobQueue(context, cConf);
return runnable.run(store, queue, profileStore);
}, tClass);
}
use of io.cdap.cdap.internal.app.runtime.schedule.queue.JobQueueTable 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 {
TransactionRunners.run(transactionRunner, context -> {
JobQueueTable jobQueue = JobQueueTable.getJobQueue(context, cConf);
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);
}
}
}
}, TransactionException.class);
} catch (TransactionException exception) {
LOG.warn("Failed to cleanup jobs upon startup.", exception);
}
}
use of io.cdap.cdap.internal.app.runtime.schedule.queue.JobQueueTable in project cdap by caskdata.
the class CoreSchedulerService method execute.
@SuppressWarnings("UnusedReturnValue")
private <V, T extends Exception> V execute(StoreAndQueueTxRunnable<V, ? extends Exception> runnable, Class<? extends T> tClass) throws T {
return TransactionRunners.run(transactionRunner, context -> {
ProgramScheduleStoreDataset store = Schedulers.getScheduleStore(context);
JobQueueTable queue = JobQueueTable.getJobQueue(context, cConf);
return runnable.run(store, queue);
}, tClass);
}
use of io.cdap.cdap.internal.app.runtime.schedule.queue.JobQueueTable in project cdap by caskdata.
the class CoreSchedulerServiceTest method getLastMessageId.
@Nullable
private MessageId getLastMessageId(final TopicId topic) {
return TransactionRunners.run(transactionRunner, context -> {
JobQueueTable jobQueue = JobQueueTable.getJobQueue(context, cConf);
String id = jobQueue.retrieveSubscriberState(topic.getTopic());
if (id == null) {
return null;
}
byte[] bytes = Bytes.fromHexString(id);
return new MessageId(bytes);
});
}
Aggregations