Search in sources :

Example 1 with InvalidJobRequest

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");
    }
}
Also used : InvalidJobRequest(io.mantisrx.server.master.InvalidJobRequest) TriggerNotFoundException(com.netflix.fenzo.triggers.exceptions.TriggerNotFoundException) SchedulerException(com.netflix.fenzo.triggers.exceptions.SchedulerException) JobClusterAlreadyExistsException(io.mantisrx.server.master.persistence.exceptions.JobClusterAlreadyExistsException) MantisJobMetadataImpl(io.mantisrx.master.jobcluster.job.MantisJobMetadataImpl) LifecycleEventsProto(io.mantisrx.master.events.LifecycleEventsProto) JobId(io.mantisrx.server.master.domain.JobId)

Example 2 with InvalidJobRequest

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);
    }
    ;
}
Also used : StageSchedulingInfo(io.mantisrx.runtime.descriptor.StageSchedulingInfo) JobConstraints(io.mantisrx.runtime.JobConstraints) InvalidJobRequest(io.mantisrx.server.master.InvalidJobRequest)

Aggregations

InvalidJobRequest (io.mantisrx.server.master.InvalidJobRequest)2 SchedulerException (com.netflix.fenzo.triggers.exceptions.SchedulerException)1 TriggerNotFoundException (com.netflix.fenzo.triggers.exceptions.TriggerNotFoundException)1 LifecycleEventsProto (io.mantisrx.master.events.LifecycleEventsProto)1 MantisJobMetadataImpl (io.mantisrx.master.jobcluster.job.MantisJobMetadataImpl)1 JobConstraints (io.mantisrx.runtime.JobConstraints)1 StageSchedulingInfo (io.mantisrx.runtime.descriptor.StageSchedulingInfo)1 JobId (io.mantisrx.server.master.domain.JobId)1 JobClusterAlreadyExistsException (io.mantisrx.server.master.persistence.exceptions.JobClusterAlreadyExistsException)1