requireNonNull(config);
requireNonNull(session);
checkNotBlank(config.getInstanceIds());
IJobKey jobKey = JobKeys.assertValid(IJobKey.build(config.getKey()));
Response resp = Util.emptyResponse();
try {
sessionValidator.checkAuthenticated(session, ImmutableSet.of(jobKey.getRole()));
ITaskConfig task = ConfigurationManager.validateAndPopulate(
ITaskConfig.build(config.getTaskConfig()));
if (cronJobManager.hasJob(jobKey)) {
return addMessage(resp, INVALID_REQUEST, "Instances may not be added to cron jobs.");
}
lockManager.validateIfLocked(
ILockKey.build(LockKey.job(jobKey.newBuilder())),
Optional.fromNullable(mutableLock).transform(ILock.FROM_BUILDER));
schedulerCore.addInstances(jobKey, ImmutableSet.copyOf(config.getInstanceIds()), task);
return resp.setResponseCode(OK);
} catch (AuthFailedException e) {
return addMessage(resp, AUTH_FAILED, e);
} catch (LockException e) {
return addMessage(resp, LOCK_ERROR, e);
} catch (TaskDescriptionException | ScheduleException e) {