path));
CRON_JOB_MISFIRES.incrementAndGet();
return Optional.absent();
}
SanitizedCronJob cronJob;
try {
cronJob = SanitizedCronJob.fromUnsanitized(config.get());
} catch (ConfigurationManager.TaskDescriptionException | CronException e) {
LOG.warning(String.format(
"Invalid cron job for %s in storage - failed to parse with %s", key, e));
CRON_JOB_PARSE_FAILURES.incrementAndGet();
return Optional.absent();
}
CronCollisionPolicy collisionPolicy = cronJob.getCronCollisionPolicy();
LOG.info(String.format(
"Cron triggered for %s at %s with policy %s", path, new Date(), collisionPolicy));
CRON_JOB_TRIGGERS.incrementAndGet();
final Query.Builder activeQuery = Query.jobScoped(key).active();
Set<String> activeTasks =
Tasks.ids(storeProvider.getTaskStore().fetchTasks(activeQuery));
ITaskConfig task = cronJob.getSanitizedConfig().getJobConfig().getTaskConfig();
Set<Integer> instanceIds = cronJob.getSanitizedConfig().getInstanceIds();
if (activeTasks.isEmpty()) {
stateManager.insertPendingTasks(storeProvider, task, instanceIds);
return Optional.absent();
}