Search in sources :

Example 6 with JobDoesNotExistException

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());
        }
    }
}
Also used : JobDoesNotExistException(alluxio.exception.JobDoesNotExistException) JobConfig(alluxio.job.JobConfig) ResourceExhaustedException(alluxio.exception.status.ResourceExhaustedException) ConcurrentHashSet(alluxio.collections.ConcurrentHashSet) WorkflowExecution(alluxio.job.workflow.WorkflowExecution)

Example 7 with JobDoesNotExistException

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);
    }
}
Also used : Context(io.grpc.Context) JobServerContext(alluxio.job.JobServerContext) AuditContext(alluxio.master.audit.AuditContext) MasterContext(alluxio.master.MasterContext) HeartbeatContext(alluxio.heartbeat.HeartbeatContext) FileSystemContext(alluxio.client.file.FileSystemContext) WorkflowConfig(alluxio.job.workflow.WorkflowConfig) JobDoesNotExistException(alluxio.exception.JobDoesNotExistException) PlanConfig(alluxio.job.plan.PlanConfig)

Example 8 with JobDoesNotExistException

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();
}
Also used : JobDoesNotExistException(alluxio.exception.JobDoesNotExistException) JobInfo(alluxio.job.wire.JobInfo) AtomicReference(java.util.concurrent.atomic.AtomicReference) TimeoutException(java.util.concurrent.TimeoutException)

Example 9 with JobDoesNotExistException

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();
}
Also used : JobDoesNotExistException(alluxio.exception.JobDoesNotExistException) JobInfo(alluxio.job.wire.JobInfo) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Aggregations

JobDoesNotExistException (alluxio.exception.JobDoesNotExistException)9 JobConfig (alluxio.job.JobConfig)3 JobInfo (alluxio.job.wire.JobInfo)3 ResourceExhaustedException (alluxio.exception.status.ResourceExhaustedException)2 WorkflowExecution (alluxio.job.workflow.WorkflowExecution)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 AlluxioURI (alluxio.AlluxioURI)1 FileSystemContext (alluxio.client.file.FileSystemContext)1 ConcurrentHashSet (alluxio.collections.ConcurrentHashSet)1 BlockInfoException (alluxio.exception.BlockInfoException)1 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)1 UnavailableException (alluxio.exception.status.UnavailableException)1 HeartbeatContext (alluxio.heartbeat.HeartbeatContext)1 JobServerContext (alluxio.job.JobServerContext)1 SelectExecutorsContext (alluxio.job.SelectExecutorsContext)1 BatchedJobConfig (alluxio.job.plan.BatchedJobConfig)1 PlanConfig (alluxio.job.plan.PlanConfig)1 WorkflowInfo (alluxio.job.wire.WorkflowInfo)1