Search in sources :

Example 1 with JobInfo

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

the class JobClusterTest method testGetLastSubmittedJobWithCompletedOnly.

/**
 * With only completed jobs getlastSubmitted should return the completed job with highest job number
 * @throws Exception
 */
@Test
public void testGetLastSubmittedJobWithCompletedOnly() throws Exception {
    TestKit probe = new TestKit(system);
    String clusterName = "testGetLastSubmittedJobWithCompletedOnly";
    final JobDefinition jobDefn1 = createJob(clusterName);
    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<>();
    Optional<JobId> lastJobIdOp = JobListHelper.getLastSubmittedJobId(activeList, completedJobs);
    assertTrue(lastJobIdOp.isPresent());
    assertEquals(jobId2, 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 2 with JobInfo

use of io.mantisrx.master.jobcluster.JobClusterActor.JobInfo 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);
}
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 3 with JobInfo

use of io.mantisrx.master.jobcluster.JobClusterActor.JobInfo 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));
}
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 4 with JobInfo

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

Example 5 with JobInfo

use of io.mantisrx.master.jobcluster.JobClusterActor.JobInfo 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()));
}
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) JobDefinition(io.mantisrx.server.master.domain.JobDefinition) 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