Search in sources :

Example 1 with PlanConfig

use of alluxio.job.plan.PlanConfig in project alluxio by Alluxio.

the class WorkflowTrackerTest method testCleanup.

@Test
public void testCleanup() throws Exception {
    SleepJobConfig jobConfig = new SleepJobConfig(1);
    mPlanTracker.run(jobConfig, mCommandManager, mMockJobServerContext, mWorkers, 1);
    jobConfig = new SleepJobConfig(1);
    mPlanTracker.run(jobConfig, mCommandManager, mMockJobServerContext, mWorkers, 2);
    jobConfig = new SleepJobConfig(1);
    mPlanTracker.run(jobConfig, mCommandManager, mMockJobServerContext, mWorkers, 3);
    doAnswer(invocation -> {
        PlanConfig config = invocation.getArgument(0, PlanConfig.class);
        long jobId = invocation.getArgument(1, Long.class);
        mPlanTracker.run(config, mCommandManager, mMockJobServerContext, mWorkers, jobId);
        return null;
    }).when(mMockJobMaster).run(any(PlanConfig.class), any(Long.class));
    ArrayList<JobConfig> jobs = Lists.newArrayList();
    SleepJobConfig child1 = new SleepJobConfig(1);
    SleepJobConfig child2 = new SleepJobConfig(2);
    jobs.add(child1);
    jobs.add(child2);
    CompositeConfig config = new CompositeConfig(jobs, false);
    mWorkflowTracker.run(config, 0);
    try {
        mPlanTracker.run(new SleepJobConfig(1), mCommandManager, mMockJobServerContext, mWorkers, 4);
        fail();
    } catch (ResourceExhaustedException e) {
    // Should fail
    }
    mPlanTracker.coordinators().stream().filter(coordinator -> coordinator.getJobId() == 100).findFirst().get().setJobAsFailed("TestError", "failed");
    mPlanTracker.run(new SleepJobConfig(1), mCommandManager, mMockJobServerContext, mWorkers, 4);
    assertNotNull(mWorkflowTracker.getStatus(0, true));
    try {
        mPlanTracker.run(new SleepJobConfig(1), mCommandManager, mMockJobServerContext, mWorkers, 5);
        fail();
    } catch (ResourceExhaustedException e) {
    // Should fail
    }
    mPlanTracker.coordinators().stream().filter(coordinator -> coordinator.getJobId() == 101).findFirst().get().setJobAsFailed("TestError", "failed");
    mPlanTracker.run(new SleepJobConfig(1), mCommandManager, mMockJobServerContext, mWorkers, 5);
    assertNull(mWorkflowTracker.getStatus(100, true));
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) JobServerContext(alluxio.job.JobServerContext) Status(alluxio.job.wire.Status) ArrayList(java.util.ArrayList) CommandManager(alluxio.master.job.command.CommandManager) WorkflowInfo(alluxio.job.wire.WorkflowInfo) Lists(com.google.common.collect.Lists) ResourceExhaustedException(alluxio.exception.status.ResourceExhaustedException) WorkerInfo(alluxio.wire.WorkerInfo) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Assert.fail(org.junit.Assert.fail) SleepJobConfig(alluxio.job.SleepJobConfig) Before(org.junit.Before) Assert.assertNotNull(org.junit.Assert.assertNotNull) CompositeConfig(alluxio.job.workflow.composite.CompositeConfig) JobMaster(alluxio.master.job.JobMaster) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) PlanInfo(alluxio.job.plan.meta.PlanInfo) Mockito.never(org.mockito.Mockito.never) Assert.assertNull(org.junit.Assert.assertNull) JobConfig(alluxio.job.JobConfig) PlanTracker(alluxio.master.job.plan.PlanTracker) PlanConfig(alluxio.job.plan.PlanConfig) Mockito.any(org.mockito.Mockito.any) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) ResourceExhaustedException(alluxio.exception.status.ResourceExhaustedException) SleepJobConfig(alluxio.job.SleepJobConfig) TestPlanConfig(alluxio.job.TestPlanConfig) PlanConfig(alluxio.job.plan.PlanConfig) CompositeConfig(alluxio.job.workflow.composite.CompositeConfig) SleepJobConfig(alluxio.job.SleepJobConfig) JobConfig(alluxio.job.JobConfig) Test(org.junit.Test)

Example 2 with PlanConfig

use of alluxio.job.plan.PlanConfig 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

JobServerContext (alluxio.job.JobServerContext)2 PlanConfig (alluxio.job.plan.PlanConfig)2 FileSystemContext (alluxio.client.file.FileSystemContext)1 JobDoesNotExistException (alluxio.exception.JobDoesNotExistException)1 ResourceExhaustedException (alluxio.exception.status.ResourceExhaustedException)1 HeartbeatContext (alluxio.heartbeat.HeartbeatContext)1 JobConfig (alluxio.job.JobConfig)1 SleepJobConfig (alluxio.job.SleepJobConfig)1 TestPlanConfig (alluxio.job.TestPlanConfig)1 PlanInfo (alluxio.job.plan.meta.PlanInfo)1 Status (alluxio.job.wire.Status)1 WorkflowInfo (alluxio.job.wire.WorkflowInfo)1 WorkflowConfig (alluxio.job.workflow.WorkflowConfig)1 CompositeConfig (alluxio.job.workflow.composite.CompositeConfig)1 MasterContext (alluxio.master.MasterContext)1 AuditContext (alluxio.master.audit.AuditContext)1 JobMaster (alluxio.master.job.JobMaster)1 CommandManager (alluxio.master.job.command.CommandManager)1 PlanTracker (alluxio.master.job.plan.PlanTracker)1 WorkerInfo (alluxio.wire.WorkerInfo)1