Search in sources :

Example 1 with PlanCoordinator

use of alluxio.master.job.plan.PlanCoordinator in project alluxio by Alluxio.

the class JobMasterTest method flowControl.

@Test
public void flowControl() throws Exception {
    PlanCoordinator coordinator = PowerMockito.mock(PlanCoordinator.class);
    mockStatic(PlanCoordinator.class);
    when(PlanCoordinator.create(any(CommandManager.class), any(JobServerContext.class), anyList(), anyLong(), any(JobConfig.class), any(Consumer.class))).thenReturn(coordinator);
    TestPlanConfig jobConfig = new TestPlanConfig("/test");
    for (long i = 0; i < TEST_JOB_MASTER_JOB_CAPACITY; i++) {
        mJobMaster.run(jobConfig);
    }
    try {
        mJobMaster.run(jobConfig);
        Assert.fail("should not be able to run more jobs than job master capacity");
    } catch (ResourceExhaustedException e) {
        Assert.assertEquals(ExceptionMessage.JOB_MASTER_FULL_CAPACITY.getMessage(ServerConfiguration.get(PropertyKey.JOB_MASTER_JOB_CAPACITY)), e.getMessage());
    }
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) ResourceExhaustedException(alluxio.exception.status.ResourceExhaustedException) JobServerContext(alluxio.job.JobServerContext) CommandManager(alluxio.master.job.command.CommandManager) Consumer(java.util.function.Consumer) PlanCoordinator(alluxio.master.job.plan.PlanCoordinator) SleepJobConfig(alluxio.job.SleepJobConfig) JobConfig(alluxio.job.JobConfig) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with PlanCoordinator

use of alluxio.master.job.plan.PlanCoordinator in project alluxio by Alluxio.

the class JobMasterTest method run.

@Test
public void run() throws Exception {
    PlanCoordinator coordinator = PowerMockito.mock(PlanCoordinator.class);
    mockStatic(PlanCoordinator.class);
    when(PlanCoordinator.create(any(CommandManager.class), any(JobServerContext.class), anyList(), anyLong(), any(JobConfig.class), any(Consumer.class))).thenReturn(coordinator);
    TestPlanConfig jobConfig = new TestPlanConfig("/test");
    List<Long> jobIdList = new ArrayList<>();
    for (long i = 0; i < TEST_JOB_MASTER_JOB_CAPACITY; i++) {
        jobIdList.add(mJobMaster.run(jobConfig));
    }
    final List<Long> list = mJobMaster.list(ListAllPOptions.getDefaultInstance());
    Assert.assertEquals(jobIdList, list);
    Assert.assertEquals(TEST_JOB_MASTER_JOB_CAPACITY, mJobMaster.list(ListAllPOptions.getDefaultInstance()).size());
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) JobServerContext(alluxio.job.JobServerContext) CommandManager(alluxio.master.job.command.CommandManager) Consumer(java.util.function.Consumer) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) ArrayList(java.util.ArrayList) PlanCoordinator(alluxio.master.job.plan.PlanCoordinator) SleepJobConfig(alluxio.job.SleepJobConfig) JobConfig(alluxio.job.JobConfig) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with PlanCoordinator

use of alluxio.master.job.plan.PlanCoordinator in project alluxio by Alluxio.

the class JobMaster method cancel.

/**
 * Cancels a job.
 *
 * @param jobId the id of the job
 * @throws JobDoesNotExistException when the job does not exist
 */
public void cancel(long jobId) throws JobDoesNotExistException {
    try (JobMasterAuditContext auditContext = createAuditContext("cancel")) {
        auditContext.setJobId(jobId);
        PlanCoordinator planCoordinator = mPlanTracker.getCoordinator(jobId);
        if (planCoordinator == null) {
            if (!mWorkflowTracker.cancel(jobId)) {
                throw new JobDoesNotExistException(ExceptionMessage.JOB_DOES_NOT_EXIST.getMessage(jobId));
            }
            return;
        }
        planCoordinator.cancel();
        auditContext.setSucceeded(true);
    }
}
Also used : JobDoesNotExistException(alluxio.exception.JobDoesNotExistException) PlanCoordinator(alluxio.master.job.plan.PlanCoordinator)

Example 4 with PlanCoordinator

use of alluxio.master.job.plan.PlanCoordinator in project alluxio by Alluxio.

the class JobMasterTest method list.

@Test
public void list() throws Exception {
    PlanCoordinator coordinator = PowerMockito.mock(PlanCoordinator.class);
    mockStatic(PlanCoordinator.class);
    when(PlanCoordinator.create(any(CommandManager.class), any(JobServerContext.class), anyList(), anyLong(), any(JobConfig.class), any(Consumer.class))).thenReturn(coordinator);
    TestPlanConfig jobConfig = new TestPlanConfig("/test");
    List<Long> jobIdList = new ArrayList<>();
    for (long i = 0; i < TEST_JOB_MASTER_JOB_CAPACITY; i++) {
        jobIdList.add(mJobMaster.run(jobConfig));
    }
    final List<Long> list = mJobMaster.list(ListAllPOptions.getDefaultInstance());
    Assert.assertEquals(jobIdList, list);
    Assert.assertEquals(TEST_JOB_MASTER_JOB_CAPACITY, mJobMaster.list(ListAllPOptions.getDefaultInstance()).size());
}
Also used : TestPlanConfig(alluxio.job.TestPlanConfig) JobServerContext(alluxio.job.JobServerContext) CommandManager(alluxio.master.job.command.CommandManager) Consumer(java.util.function.Consumer) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) ArrayList(java.util.ArrayList) PlanCoordinator(alluxio.master.job.plan.PlanCoordinator) SleepJobConfig(alluxio.job.SleepJobConfig) JobConfig(alluxio.job.JobConfig) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with PlanCoordinator

use of alluxio.master.job.plan.PlanCoordinator in project alluxio by Alluxio.

the class JobMasterTest method cancel.

@Test
public void cancel() throws Exception {
    mockStatic(PlanCoordinator.class);
    PlanCoordinator coordinator = PowerMockito.mock(PlanCoordinator.class);
    when(PlanCoordinator.create(any(CommandManager.class), any(JobServerContext.class), anyList(), anyLong(), any(JobConfig.class), any(Consumer.class))).thenReturn(coordinator);
    SleepJobConfig config = new SleepJobConfig(10000);
    long jobId = mJobMaster.run(config);
    mJobMaster.cancel(jobId);
    verify(coordinator).cancel();
}
Also used : JobServerContext(alluxio.job.JobServerContext) CommandManager(alluxio.master.job.command.CommandManager) Consumer(java.util.function.Consumer) SleepJobConfig(alluxio.job.SleepJobConfig) PlanCoordinator(alluxio.master.job.plan.PlanCoordinator) SleepJobConfig(alluxio.job.SleepJobConfig) JobConfig(alluxio.job.JobConfig) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

PlanCoordinator (alluxio.master.job.plan.PlanCoordinator)9 JobConfig (alluxio.job.JobConfig)4 JobServerContext (alluxio.job.JobServerContext)4 SleepJobConfig (alluxio.job.SleepJobConfig)4 CommandManager (alluxio.master.job.command.CommandManager)4 ArrayList (java.util.ArrayList)4 Consumer (java.util.function.Consumer)4 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 TestPlanConfig (alluxio.job.TestPlanConfig)3 MasterWorkerInfo (alluxio.job.MasterWorkerInfo)2 LockResource (alluxio.resource.LockResource)2 ArgumentMatchers.anyLong (org.mockito.ArgumentMatchers.anyLong)2 JobDoesNotExistException (alluxio.exception.JobDoesNotExistException)1 ResourceExhaustedException (alluxio.exception.status.ResourceExhaustedException)1 HeartbeatThread (alluxio.heartbeat.HeartbeatThread)1 JobInfo (alluxio.job.wire.JobInfo)1 TaskInfo (alluxio.job.wire.TaskInfo)1 AsyncUserAccessAuditLogWriter (alluxio.master.audit.AsyncUserAccessAuditLogWriter)1 HashMap (java.util.HashMap)1