use of alluxio.exception.JobDoesNotExistException in project alluxio by Alluxio.
the class WorkflowTracker method next.
private synchronized void next(long jobId) {
WorkflowExecution workflowExecution = mWorkflows.get(jobId);
mChildren.putIfAbsent(jobId, new ConcurrentHashSet<>());
Set<JobConfig> childJobConfigs = workflowExecution.next();
if (childJobConfigs.isEmpty()) {
done(jobId);
return;
}
ConcurrentHashSet<Long> childJobIds = new ConcurrentHashSet<>();
for (int i = 0; i < childJobConfigs.size(); i++) {
childJobIds.add(mJobMaster.getNewJobId());
}
mWaitingOn.put(jobId, childJobIds);
mChildren.get(jobId).addAll(childJobIds);
for (Long childJobId : childJobIds) {
mParentWorkflow.put(childJobId, jobId);
}
Iterator<Long> childJobIdsIter = childJobIds.iterator();
Iterator<JobConfig> childJobConfigsIter = childJobConfigs.iterator();
while (childJobIdsIter.hasNext() && childJobConfigsIter.hasNext()) {
Long childJobId = childJobIdsIter.next();
JobConfig childJobConfig = childJobConfigsIter.next();
try {
mJobMaster.run(childJobConfig, childJobId);
} catch (JobDoesNotExistException | ResourceExhaustedException e) {
LOG.warn(e.getMessage());
final String errorType = ErrorUtils.getErrorType(e);
workflowExecution.stop(Status.FAILED, errorType, e.getMessage());
stop(jobId, Status.FAILED, errorType, e.getMessage());
}
}
}
use of alluxio.exception.JobDoesNotExistException in project alluxio by Alluxio.
the class JobMaster method run.
/**
* Runs a job with the given configuration and job id.
*
* @param jobConfig the job configuration
* @param jobId the job id
* @throws JobDoesNotExistException when the job doesn't exist
* @throws ResourceExhaustedException if the job master is too busy to run the job
*/
public synchronized void run(JobConfig jobConfig, long jobId) throws JobDoesNotExistException, ResourceExhaustedException {
// This RPC service implementation triggers another RPC.
// Run the implementation under forked context to avoid interference.
// Then restore the current context at the end.
Context forkedCtx = Context.current().fork();
Context prevCtx = forkedCtx.attach();
try (JobMasterAuditContext auditContext = createAuditContext("run")) {
auditContext.setJobId(jobId);
if (jobConfig instanceof PlanConfig) {
mPlanTracker.run((PlanConfig) jobConfig, mCommandManager, mJobServerContext, getWorkerInfoList(), jobId);
auditContext.setSucceeded(true);
return;
} else if (jobConfig instanceof WorkflowConfig) {
mWorkflowTracker.run((WorkflowConfig) jobConfig, jobId);
auditContext.setSucceeded(true);
return;
}
throw new JobDoesNotExistException(ExceptionMessage.JOB_DEFINITION_DOES_NOT_EXIST.getMessage(jobConfig.getName()));
} finally {
forkedCtx.detach(prevCtx);
}
}
use of alluxio.exception.JobDoesNotExistException in project alluxio by Alluxio.
the class JobTestUtils method waitForJobStatus.
/**
* Waits for the job with the given job ID to be in the one of given states.
*
* @param jobMaster the job master running the job
* @param jobId the ID of the job
* @param statuses set of statuses to wait for
* @return the status of the job waited for
*/
public static JobInfo waitForJobStatus(final JobMaster jobMaster, final long jobId, final Set<Status> statuses) throws InterruptedException, TimeoutException {
final AtomicReference<JobInfo> singleton = new AtomicReference<>();
final AtomicReference<String> jobStatus = new AtomicReference<>();
try {
CommonUtils.waitFor(String.format("job %d to be one of status %s", jobId, Arrays.toString(statuses.toArray())), () -> {
JobInfo info;
try {
info = jobMaster.getStatus(jobId);
jobStatus.set(info.toString());
if (statuses.contains(info.getStatus())) {
singleton.set(info);
}
return statuses.contains(info.getStatus());
} catch (JobDoesNotExistException e) {
throw Throwables.propagate(e);
}
}, WaitForOptions.defaults().setTimeoutMs(30 * Constants.SECOND_MS));
} catch (TimeoutException e) {
throw new TimeoutException(String.format("%s, %s", e.getMessage(), jobStatus.toString()));
}
return singleton.get();
}
use of alluxio.exception.JobDoesNotExistException in project alluxio by Alluxio.
the class JobTestUtils method waitForJobStatus.
/**
* Waits for the job with the given job ID to be in the one of given states in provided timeout.
*
* @param jobMaster the job master running the job
* @param jobId the ID of the job
* @param statuses set of statuses to wait for
* @param timeout the timeout for the wait period
* @return the status of the job waited for
*/
public static JobInfo waitForJobStatus(final JobMaster jobMaster, final long jobId, final Set<Status> statuses, int timeout) throws InterruptedException, TimeoutException {
final AtomicReference<JobInfo> singleton = new AtomicReference<>();
CommonUtils.waitFor(String.format("job %d to be one of status %s", jobId, Arrays.toString(statuses.toArray())), () -> {
JobInfo info;
try {
info = jobMaster.getStatus(jobId);
if (statuses.contains(info.getStatus())) {
singleton.set(info);
}
return statuses.contains(info.getStatus());
} catch (JobDoesNotExistException e) {
throw Throwables.propagate(e);
}
}, WaitForOptions.defaults().setTimeoutMs(timeout * Constants.SECOND_MS));
return singleton.get();
}
Aggregations