use of io.mantisrx.master.jobcluster.JobClusterActor.JobManager in project mantis by Netflix.
the class JobManagerTest method testGetAcceptedJobList.
@Test
public void testGetAcceptedJobList() {
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));
JobId jId2 = new JobId("name", 2);
JobInfo jInfo2 = new JobInfo(jId2, null, 0, null, JobState.Accepted, "nj");
assertTrue(jm.markJobAccepted(jInfo2));
List<JobInfo> acceptedJobList = jm.getAcceptedJobsList();
assertEquals(2, acceptedJobList.size());
assertTrue(jId1.equals(acceptedJobList.get(0).jobId) || jId1.equals(acceptedJobList.get(1).jobId));
assertTrue(jId2.equals(acceptedJobList.get(0).jobId) || jId2.equals(acceptedJobList.get(1).jobId));
try {
acceptedJobList.remove(0);
fail();
} catch (Exception e) {
}
}
use of io.mantisrx.master.jobcluster.JobClusterActor.JobManager in project mantis by Netflix.
the class JobManagerTest method testGetActiveJobList.
@Test
public void testGetActiveJobList() {
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.markJobStarted(jInfo1));
JobId jId2 = new JobId("name", 2);
JobInfo jInfo2 = new JobInfo(jId2, null, 0, null, JobState.Accepted, "nj");
assertTrue(jm.markJobAccepted(jInfo2));
assertTrue(jm.markJobStarted(jInfo2));
List<JobInfo> acceptedJobList = jm.getAcceptedJobsList();
assertEquals(0, acceptedJobList.size());
List<JobInfo> activeJobList = jm.getActiveJobsList();
assertEquals(2, jm.getActiveJobsList().size());
assertTrue(jId1.equals(activeJobList.get(0).jobId) || jId1.equals(activeJobList.get(1).jobId));
assertTrue(jId2.equals(activeJobList.get(0).jobId) || jId2.equals(activeJobList.get(1).jobId));
try {
activeJobList.remove(0);
fail();
} catch (Exception e) {
}
}
use of io.mantisrx.master.jobcluster.JobClusterActor.JobManager in project mantis by Netflix.
the class JobManagerTest method acceptedToActive.
@Test
public void acceptedToActive() {
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.markJobStarted(jInfo1));
assertEquals(0, jm.acceptedJobsCount());
assertEquals(1, jm.activeJobsCount());
assertTrue(jm.getAllNonTerminalJobsList().contains(jInfo1));
}
use of io.mantisrx.master.jobcluster.JobClusterActor.JobManager in project mantis by Netflix.
the class JobManagerTest method testJobListSortedCorrectly.
@Test
public void testJobListSortedCorrectly() {
String clusterName = "testJobListSortedCorrectly";
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.markJobTerminating(jInfo1, JobState.Terminating_abnormal);
completionInstant = Instant.now().minusSeconds(2);
jm.markCompleted(jId2, completionInstant.toEpochMilli(), empty(), JobState.Completed);
assertEquals(2, jm.getCompletedJobsList().size());
assertEquals(jId2.getId(), jm.getCompletedJobsList().get(0).getJobId());
assertEquals(jId1.getId(), jm.getCompletedJobsList().get(1).getJobId());
}
Aggregations