use of io.mantisrx.server.master.InvalidJobRequest in project mantis by Netflix.
the class JobClusterActor method submitJob.
private void submitJob(JobDefinition jobDefinition, ActorRef sender, String user) throws PersistException {
if (logger.isTraceEnabled()) {
logger.trace("Enter submitJobb");
}
JobId jId = null;
try {
validateJobDefinition(jobDefinition);
long lastJobIdNumber = jobClusterMetadata.getLastJobCount();
jId = new JobId(name, ++lastJobIdNumber);
logger.info("Creating new job id: " + jId + " with job defn " + jobDefinition);
MantisJobMetadataImpl mantisJobMetaData = new MantisJobMetadataImpl.Builder().withJobId(jId).withSubmittedAt(Instant.now()).withJobState(JobState.Accepted).withNextWorkerNumToUse(1).withJobDefinition(jobDefinition).build();
eventPublisher.publishAuditEvent(new LifecycleEventsProto.AuditEvent(LifecycleEventsProto.AuditEvent.AuditEventType.JOB_SUBMIT, jId.getId(), jId + " submitter: " + user));
jobManager.initJob(mantisJobMetaData, jobClusterMetadata, sender);
numJobActorCreationCounter.increment();
jobClusterMetadata = new JobClusterMetadataImpl.Builder().withJobClusterDefinition((JobClusterDefinitionImpl) this.jobClusterMetadata.getJobClusterDefinition()).withLastJobCount(lastJobIdNumber).withIsDisabled(jobClusterMetadata.isDisabled()).build();
try {
jobStore.updateJobCluster(jobClusterMetadata);
} catch (Exception e) {
logger.error("Failed to persist job cluster {} error {}", jobClusterMetadata, e.getMessage(), e);
numJobSubmissionFailures.increment();
cleanUpOnJobSubmitFailure(jId);
throw new PersistException(e);
}
jobIdSubmissionSubject.onNext(jId);
numJobSubmissions.increment();
} catch (PersistException pe) {
throw pe;
} catch (InvalidJobRequest e) {
logger.error("Invalid jobcluster : {} error {}", jobClusterMetadata, e.getMessage(), e);
numJobSubmissionFailures.increment();
throw new IllegalArgumentException(e);
} catch (Exception e) {
logger.error("Exception persisting job in store", e);
numJobSubmissionFailures.increment();
cleanUpOnJobSubmitFailure(jId);
throw new IllegalStateException(e);
}
if (logger.isTraceEnabled()) {
logger.trace("Exit submitJob");
}
}
use of io.mantisrx.server.master.InvalidJobRequest in project mantis by Netflix.
the class JobClusterActor method validateJobDefinition.
/**
* @param definition Job Definition to be validated
* @throws InvalidJobRequest If the job definition is invalid
*/
private void validateJobDefinition(JobDefinition definition) throws InvalidJobRequest {
if (definition == null) {
throw new InvalidJobRequest(null, "MantisJobDefinition cannot be null");
}
if (definition.getArtifactName() == null) {
throw new InvalidJobRequest(null, "MantisJobDefinition job artifactName attribute cannot be null");
}
if (definition.getName() == null) {
throw new InvalidJobRequest(null, "MantisJobDefinition name attribute cannot be null");
}
if (definition.getSchedulingInfo() == null) {
throw new InvalidJobRequest(null, "MantisJobDefinition schedulingInfo cannot be null");
}
for (StageSchedulingInfo ssi : definition.getSchedulingInfo().getStages().values()) {
List<JobConstraints> hardConstraints = ssi.getHardConstraints();
List<JobConstraints> softConstraints = ssi.getSoftConstraints();
validateConstraints(softConstraints, hardConstraints);
}
;
}
Aggregations