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());
}
}
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());
}
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);
}
}
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());
}
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();
}
Aggregations