Search in sources :

Example 16 with JobInfo

use of io.mantisrx.master.jobcluster.JobClusterActor.JobInfo in project mantis by Netflix.

the class JobClusterTest method testGetLastSubmittedJobWithNoJobs.

/**
 * No Active or completed jobs should return an empty Optional
 * @throws Exception
 */
@Test
public void testGetLastSubmittedJobWithNoJobs() throws Exception {
    TestKit probe = new TestKit(system);
    String clusterName = "testGetLastSubmittedJobWithNoJobs";
    final JobDefinition jobDefn1 = createJob(clusterName);
    List<JobClusterDefinitionImpl.CompletedJob> completedJobs = new ArrayList<>();
    List<JobInfo> activeList = new ArrayList<>();
    Optional<JobId> lastJobIdOp = JobListHelper.getLastSubmittedJobId(activeList, completedJobs);
    assertFalse(lastJobIdOp.isPresent());
}
Also used : JobInfo(io.mantisrx.master.jobcluster.JobClusterActor.JobInfo) ArrayList(java.util.ArrayList) TestKit(akka.testkit.javadsl.TestKit) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 17 with JobInfo

use of io.mantisrx.master.jobcluster.JobClusterActor.JobInfo in project mantis by Netflix.

the class JobClusterTest method testGetLastSubmittedJob.

@Test
public void testGetLastSubmittedJob() throws Exception {
    TestKit probe = new TestKit(system);
    String clusterName = "testGetLastSubmittedJob";
    final JobDefinition jobDefn1 = createJob(clusterName);
    JobId jobId3 = new JobId(clusterName, 3);
    JobInfo jInfo3 = new JobInfo(jobId3, jobDefn1, 1000L, null, JobState.Launched, "user1");
    JobId jobId4 = new JobId(clusterName, 4);
    JobInfo jInfo4 = new JobInfo(jobId4, jobDefn1, 2000L, null, JobState.Launched, "user1");
    JobId jobId1 = new JobId(clusterName, 1);
    JobClusterDefinitionImpl.CompletedJob cJob1 = new JobClusterDefinitionImpl.CompletedJob(clusterName, jobId1.getId(), "0.0.1", JobState.Completed, 800L, 900L, "user1", new ArrayList<>());
    JobId jobId2 = new JobId(clusterName, 2);
    JobClusterDefinitionImpl.CompletedJob cJob2 = new JobClusterDefinitionImpl.CompletedJob(clusterName, jobId2.getId(), "0.0.1", JobState.Completed, 900L, 1000L, "user1", new ArrayList<>());
    List<JobClusterDefinitionImpl.CompletedJob> completedJobs = new ArrayList<>();
    completedJobs.add(cJob1);
    completedJobs.add(cJob2);
    List<JobInfo> activeList = new ArrayList<>();
    activeList.add(jInfo3);
    activeList.add(jInfo4);
    Optional<JobId> lastJobIdOp = JobListHelper.getLastSubmittedJobId(activeList, completedJobs);
    assertTrue(lastJobIdOp.isPresent());
    assertEquals(jobId4, lastJobIdOp.get());
}
Also used : ArrayList(java.util.ArrayList) TestKit(akka.testkit.javadsl.TestKit) Matchers.anyString(org.mockito.Matchers.anyString) JobInfo(io.mantisrx.master.jobcluster.JobClusterActor.JobInfo) Test(org.junit.Test)

Example 18 with JobInfo

use of io.mantisrx.master.jobcluster.JobClusterActor.JobInfo 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) {
    }
}
Also used : JobManager(io.mantisrx.master.jobcluster.JobClusterActor.JobManager) JobInfo(io.mantisrx.master.jobcluster.JobClusterActor.JobInfo) JobManager(io.mantisrx.master.jobcluster.JobClusterActor.JobManager) JobId(io.mantisrx.server.master.domain.JobId) IOException(java.io.IOException) Test(org.junit.Test)

Example 19 with JobInfo

use of io.mantisrx.master.jobcluster.JobClusterActor.JobInfo 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));
}
Also used : JobManager(io.mantisrx.master.jobcluster.JobClusterActor.JobManager) JobInfo(io.mantisrx.master.jobcluster.JobClusterActor.JobInfo) JobManager(io.mantisrx.master.jobcluster.JobClusterActor.JobManager) JobId(io.mantisrx.server.master.domain.JobId) Test(org.junit.Test)

Example 20 with JobInfo

use of io.mantisrx.master.jobcluster.JobClusterActor.JobInfo 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());
}
Also used : JobManager(io.mantisrx.master.jobcluster.JobClusterActor.JobManager) MantisJobStore(io.mantisrx.server.master.persistence.MantisJobStore) JobInfo(io.mantisrx.master.jobcluster.JobClusterActor.JobInfo) Instant(java.time.Instant) JobManager(io.mantisrx.master.jobcluster.JobClusterActor.JobManager) JobId(io.mantisrx.server.master.domain.JobId) Test(org.junit.Test)

Aggregations

JobInfo (io.mantisrx.master.jobcluster.JobClusterActor.JobInfo)20 Test (org.junit.Test)18 JobId (io.mantisrx.server.master.domain.JobId)17 JobManager (io.mantisrx.master.jobcluster.JobClusterActor.JobManager)9 SLA (io.mantisrx.server.master.domain.SLA)6 Instant (org.joda.time.Instant)6 TestKit (akka.testkit.javadsl.TestKit)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Matchers.anyString (org.mockito.Matchers.anyString)3 MantisJobStore (io.mantisrx.server.master.persistence.MantisJobStore)2 Instant (java.time.Instant)2 JobClusterDefinitionImpl (io.mantisrx.server.master.domain.JobClusterDefinitionImpl)1 CompletedJob (io.mantisrx.server.master.domain.JobClusterDefinitionImpl.CompletedJob)1 JobDefinition (io.mantisrx.server.master.domain.JobDefinition)1