use of io.mantisrx.master.jobcluster.JobClusterActor.JobManager in project mantis by Netflix.
the class JobManagerTest method acceptedToTerminating.
@Test
public void acceptedToTerminating() {
JobClusterActor.JobManager jm = new JobManager("name", context, scheduler, publisher, jobStore);
JobId jId1 = new JobId("name", 1);
JobInfo jInfo1 = new JobInfo(jId1, null, 0, null, JobState.Accepted, "nj");
assertTrue(jm.markJobAccepted(jInfo1));
assertTrue(jm.getAllNonTerminalJobsList().contains(jInfo1));
assertEquals(1, jm.acceptedJobsCount());
assertTrue(jm.markJobTerminating(jInfo1, JobState.Terminating_abnormal));
assertTrue(jm.getAllNonTerminalJobsList().contains(jInfo1));
assertEquals(0, jm.acceptedJobsCount());
assertEquals(0, jm.activeJobsCount());
Optional<JobInfo> j1 = jm.getJobInfoForNonTerminalJob(jId1);
assertTrue(j1.isPresent());
assertEquals(jId1, j1.get().jobId);
}
use of io.mantisrx.master.jobcluster.JobClusterActor.JobManager in project mantis by Netflix.
the class JobManagerTest method activeToAcceptedFails.
@Test
public void activeToAcceptedFails() {
JobClusterActor.JobManager jm = new JobManager("name", context, scheduler, publisher, jobStore);
JobId jId1 = new JobId("name", 1);
JobInfo jInfo1 = new JobInfo(jId1, null, 0, null, JobState.Accepted, "nj");
assertTrue(jm.markJobAccepted(jInfo1));
assertEquals(1, jm.acceptedJobsCount());
assertTrue(jm.markJobTerminating(jInfo1, JobState.Terminating_abnormal));
assertFalse(jm.markJobAccepted(jInfo1));
}
use of io.mantisrx.master.jobcluster.JobClusterActor.JobManager in project mantis by Netflix.
the class JobManagerTest method acceptedToCompleted.
@Test
public void acceptedToCompleted() {
JobClusterActor.JobManager jm = new JobManager("name", context, scheduler, publisher, jobStore);
JobId jId1 = new JobId("name", 1);
JobInfo jInfo1 = new JobInfo(jId1, null, 0, null, JobState.Accepted, "nj");
assertTrue(jm.markJobAccepted(jInfo1));
assertEquals(1, jm.acceptedJobsCount());
assertTrue(jm.getCompletedJobsList().size() == 0);
assertTrue(jm.markCompleted(jId1, empty(), JobState.Completed).isPresent());
assertEquals(0, jm.acceptedJobsCount());
assertEquals(1, jm.getCompletedJobsList().size());
assertEquals(0, jm.activeJobsCount());
assertFalse(jm.getAllNonTerminalJobsList().contains(jInfo1));
assertTrue(jm.getCompletedJobsList().size() == 1);
JobClusterDefinitionImpl.CompletedJob completedJob = jm.getCompletedJobsList().get(0);
assertEquals(jId1.getId(), completedJob.getJobId());
}
use of io.mantisrx.master.jobcluster.JobClusterActor.JobManager in project mantis by Netflix.
the class JobManagerTest method terminatingToActiveIsIgnored.
@Test
public void terminatingToActiveIsIgnored() {
JobClusterActor.JobManager jm = new JobManager("name", context, scheduler, publisher, jobStore);
JobId jId1 = new JobId("name", 1);
JobDefinition jdMock = mock(JobDefinition.class);
JobInfo jInfo1 = new JobInfo(jId1, jdMock, 0, null, JobState.Accepted, "nj");
jm.markJobAccepted(jInfo1);
assertEquals(1, jm.acceptedJobsCount());
Optional<JobInfo> jInfo1Op = jm.getJobInfoForNonTerminalJob(jId1);
assertTrue(jInfo1Op.isPresent());
assertTrue(jm.markJobTerminating(jInfo1Op.get(), JobState.Terminating_abnormal));
jInfo1Op = jm.getJobInfoForNonTerminalJob(jId1);
assertTrue(jInfo1Op.isPresent());
assertFalse(jm.markJobStarted(jInfo1Op.get()));
}
use of io.mantisrx.master.jobcluster.JobClusterActor.JobManager in project mantis by Netflix.
the class JobManagerTest method testPurgeOldJobs.
@Test
public void testPurgeOldJobs() {
String clusterName = "testPurgeOldJobs";
MantisJobStore jobStoreMock = mock(MantisJobStore.class);
JobClusterActor.JobManager jm = new JobManager(clusterName, context, scheduler, publisher, jobStoreMock);
JobId jId1 = new JobId(clusterName, 1);
JobInfo jInfo1 = new JobInfo(jId1, null, 0, null, JobState.Accepted, "nj");
assertTrue(jm.markJobAccepted(jInfo1));
assertTrue(jm.getAllNonTerminalJobsList().contains(jInfo1));
JobId jId2 = new JobId(clusterName, 2);
JobInfo jInfo2 = new JobInfo(jId2, null, 1, null, JobState.Accepted, "nj");
assertTrue(jm.markJobAccepted(jInfo2));
assertTrue(jm.getAllNonTerminalJobsList().contains(jInfo2));
assertTrue(jm.getAllNonTerminalJobsList().size() == 2);
assertEquals(jInfo1, jm.getAllNonTerminalJobsList().get(1));
assertEquals(jInfo2, jm.getAllNonTerminalJobsList().get(0));
jm.markJobTerminating(jInfo1, JobState.Terminating_abnormal);
Instant completionInstant = Instant.now().minusSeconds(5);
jm.markCompleted(jId1, completionInstant.toEpochMilli(), empty(), JobState.Completed);
assertEquals(1, jm.getCompletedJobsList().size());
assertEquals(jId1.getId(), jm.getCompletedJobsList().get(0).getJobId());
jm.purgeOldCompletedJobs(Instant.now().minusSeconds(3).toEpochMilli());
assertEquals(0, jm.getCompletedJobsList().size());
try {
verify(jobStoreMock, times(1)).deleteCompletedJob(clusterName, jId1.getId());
verify(jobStoreMock, times(1)).deleteJob(jId1.getId());
} catch (IOException e) {
e.printStackTrace();
fail();
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
Aggregations