use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.SubmitJobResponse in project mantis by Netflix.
the class JobClusterActor method onGetJobDefinitionUpdatedFromJobActorResponse.
public void onGetJobDefinitionUpdatedFromJobActorResponse(GetJobDefinitionUpdatedFromJobActorResponse request) {
logger.info("Resuming job submission from job actor");
// this request is returned by job actor but the response needs to be replied to the original job request sender (from API routes).
ActorRef originalSender = request.getOriginalSender();
if (request.responseCode == SERVER_ERROR || request.getJobDefinition() == null) {
logger.error("Failed to retrieve job definition from job actor");
numJobSubmissionFailures.increment();
originalSender.tell(new SubmitJobResponse(request.requestId, SERVER_ERROR, request.message, empty()), getSelf());
return;
}
try {
JobDefinition resolvedJobDefn = request.getJobDefinition();
// for quick submit the artifact version/name needs to be reset using the fork method below.
if (request.isQuickSubmitMode()) {
Optional<JobDefinition> jobDefinitionCloneO = cloneToNewJobDefinitionWithoutArtifactNameAndVersion(request.getJobDefinition());
if (jobDefinitionCloneO.isPresent()) {
resolvedJobDefn = jobDefinitionCloneO.get();
}
}
resolvedJobDefn = this.jobDefinitionResolver.getResolvedJobDefinition(request.getUser(), resolvedJobDefn, this.jobClusterMetadata);
eventPublisher.publishStatusEvent(new LifecycleEventsProto.JobClusterStatusEvent(LifecycleEventsProto.StatusEvent.StatusEventType.INFO, "Job submit request received", jobClusterMetadata.getJobClusterDefinition().getName()));
resolvedJobDefn = LabelManager.insertSystemLabels(resolvedJobDefn, request.isAutoResubmit());
submitJob(resolvedJobDefn, originalSender, request.getUser());
numJobSubmissions.increment();
} catch (PersistException pe) {
logger.error("Exception submitting job {} from {}", this.name, request.getUser(), pe);
numJobSubmissionFailures.increment();
originalSender.tell(new SubmitJobResponse(request.requestId, SERVER_ERROR, pe.getMessage(), empty()), getSelf());
} catch (Exception e) {
logger.error("Exception submitting job {} from {}", this.name, request.getUser(), e);
numJobSubmissionFailures.increment();
originalSender.tell(new SubmitJobResponse(request.requestId, CLIENT_ERROR, e.getMessage(), empty()), getSelf());
}
}
use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.SubmitJobResponse in project mantis by Netflix.
the class JobClusterActor method onJobSubmit.
@Override
public void onJobSubmit(final SubmitJobRequest request) {
final ActorRef sender = getSender();
// if the job is submitted with a userDefinedType check to see if such a job is already running. If so just reply with a reference to it.
if (request.getJobDefinition().isPresent()) {
String uniq = request.getJobDefinition().get().getJobSla().getUserProvidedType();
if (uniq != null && !uniq.isEmpty()) {
Optional<JobInfo> existingJob = jobManager.getJobInfoByUniqueId(uniq);
if (existingJob.isPresent()) {
logger.info("Job with unique {} already exists, returning its job Id {}", uniq, existingJob.get().jobId);
sender.tell(new SubmitJobResponse(request.requestId, SUCCESS, existingJob.get().jobId.getId(), of(existingJob.get().jobId)), getSelf());
return;
}
}
}
logger.info("Submitting job {}", request);
try {
if (requireJobActorProcess(request)) {
logger.info("Sending job submit request to job actor for inheritance: {}", request.requestId);
return;
}
JobDefinition resolvedJobDefn = getResolvedJobDefinition(request.getSubmitter(), request.getJobDefinition());
eventPublisher.publishStatusEvent(new LifecycleEventsProto.JobClusterStatusEvent(LifecycleEventsProto.StatusEvent.StatusEventType.INFO, "Job submit request received", jobClusterMetadata.getJobClusterDefinition().getName()));
resolvedJobDefn = LabelManager.insertSystemLabels(resolvedJobDefn, request.isAutoResubmit());
submitJob(resolvedJobDefn, sender, request.getSubmitter());
numJobSubmissions.increment();
} catch (PersistException pe) {
logger.error("Exception submitting job {} from {}", request.getClusterName(), request.getSubmitter(), pe);
numJobSubmissionFailures.increment();
sender.tell(new SubmitJobResponse(request.requestId, SERVER_ERROR, pe.getMessage(), empty()), getSelf());
} catch (Exception e) {
logger.error("Exception submitting job {} from {}", request.getClusterName(), request.getSubmitter(), e);
numJobSubmissionFailures.increment();
sender.tell(new SubmitJobResponse(request.requestId, CLIENT_ERROR, e.getMessage(), empty()), getSelf());
}
}
use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.SubmitJobResponse in project mantis by Netflix.
the class JobClusterTest method testJobSubmitFails.
@Test
public void testJobSubmitFails() {
TestKit probe = new TestKit(system);
try {
String clusterName = "testJobSubmitFails";
MantisScheduler schedulerMock = mock(MantisScheduler.class);
MantisJobStore jobStoreMock = mock(MantisJobStore.class);
final JobClusterDefinitionImpl fakeJobCluster = createFakeJobClusterDefn(clusterName);
Mockito.doThrow(Exception.class).when(jobStoreMock).storeNewJob(any());
ActorRef jobClusterActor = system.actorOf(props(clusterName, jobStoreMock, schedulerMock, eventPublisher));
jobClusterActor.tell(new JobClusterProto.InitializeJobClusterRequest(fakeJobCluster, user, probe.getRef()), probe.getRef());
JobClusterProto.InitializeJobClusterResponse createResp = probe.expectMsgClass(JobClusterProto.InitializeJobClusterResponse.class);
assertEquals(SUCCESS, createResp.responseCode);
final JobDefinition jobDefn = createJob(clusterName, 1, MantisJobDurationType.Transient);
String jobId = clusterName + "-1";
jobClusterActor.tell(new SubmitJobRequest(clusterName, "user", Optional.ofNullable(jobDefn)), probe.getRef());
SubmitJobResponse submitResponse = probe.expectMsgClass(SubmitJobResponse.class);
assertEquals(SERVER_ERROR, submitResponse.responseCode);
verify(jobStoreMock, times(1)).createJobCluster(any());
verify(jobStoreMock, times(1)).updateJobCluster(any());
verify(jobStoreMock, times(0)).storeNewWorker(any());
verify(jobStoreMock, times(0)).storeNewWorkers(any(), any());
} catch (Exception e) {
fail();
}
}
use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.SubmitJobResponse in project mantis by Netflix.
the class JobClustersManagerActor method onJobSubmit.
// ////////////////// JOB OPERATIONS ////////////////////////////////////////////////
@Override
public void onJobSubmit(final SubmitJobRequest request) {
logger.info("Submitting job " + request);
Optional<JobClusterInfo> jobClusterInfo = jobClusterInfoManager.getJobClusterInfo(request.getClusterName());
ActorRef sender = getSender();
if (jobClusterInfo.isPresent()) {
jobClusterInfo.get().jobClusterActor.forward(request, getContext());
} else {
sender.tell(new SubmitJobResponse(request.requestId, CLIENT_ERROR_NOT_FOUND, "Job Cluster " + request.getClusterName() + " doesn't exist", empty()), getSelf());
}
}
use of io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.SubmitJobResponse in project mantis by Netflix.
the class JobClusterActor method onJobInitialized.
@Override
public void onJobInitialized(JobProto.JobInitialized jobInited) {
if (logger.isTraceEnabled()) {
logger.trace("Enter onJobInitialized");
}
jobManager.markJobInitialized(jobInited.jobId, System.currentTimeMillis());
if (jobInited.responseCode == SUCCESS) {
jobInited.requestor.tell(new SubmitJobResponse(jobInited.requestId, SUCCESS, jobInited.jobId.getId(), of(jobInited.jobId)), getSelf());
numJobsInitialized.increment();
} else {
logger.warn("Job was not initialized {}", jobInited);
Optional<JobInfo> jobInfo = jobManager.getJobInfoForNonTerminalJob(jobInited.jobId);
if (jobInfo.isPresent()) {
cleanUpOnJobSubmitFailure(jobInfo.get().jobId);
// if this is not a cron submission inform the caller
if (jobInited.requestor != null)
jobInited.requestor.tell(new SubmitJobResponse(jobInited.requestId, jobInited.responseCode, "Job " + jobInited.jobId + " submission failed", ofNullable(jobInited.jobId)), getSelf());
} else {
logger.warn("No such job found {}", jobInited.jobId);
}
}
if (logger.isTraceEnabled()) {
logger.trace("Exit onJobInitialized");
}
}
Aggregations