Search in sources :

Example 1 with AuditContext

use of alluxio.master.audit.AuditContext 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)

Aggregations

FileSystemContext (alluxio.client.file.FileSystemContext)1 JobDoesNotExistException (alluxio.exception.JobDoesNotExistException)1 HeartbeatContext (alluxio.heartbeat.HeartbeatContext)1 JobServerContext (alluxio.job.JobServerContext)1 PlanConfig (alluxio.job.plan.PlanConfig)1 WorkflowConfig (alluxio.job.workflow.WorkflowConfig)1 MasterContext (alluxio.master.MasterContext)1 AuditContext (alluxio.master.audit.AuditContext)1 Context (io.grpc.Context)1