storage.write(new MutateWork.NoResult<ScheduleException>() {
@Override
protected void execute(MutableStoreProvider storeProvider) throws ScheduleException {
final IJobConfiguration job = sanitizedConfiguration.getJobConfig();
if (hasActiveJob(job)) {
throw new ScheduleException(
"Job already exists: " + JobKeys.canonicalString(job.getKey()));
}
validateTaskLimits(job.getTaskConfig(), job.getInstanceCount());
// TODO(mchucarroll): deprecate cron as a part of create/kill job.(AURORA-454)
if (sanitizedConfiguration.isCron()) {
try {
LOG.warning("Deprecated behavior: scheduling job " + job.getKey()
+ " with cron via createJob (AURORA_454)");
cronJobManager.createJob(SanitizedCronJob.from(sanitizedConfiguration));
} catch (CronException e) {
throw new ScheduleException(e);
}
} else {
LOG.info("Launching " + sanitizedConfiguration.getTaskConfigs().size() + " tasks.");
stateManager.insertPendingTasks(sanitizedConfiguration.getTaskConfigs());
}