Search in sources :

Example 1 with Identity

use of com.hazelcast.jet.core.TestProcessors.Identity in project hazelcast-jet by hazelcast.

the class JobTest method testJobStatusDuringStart.

private void testJobStatusDuringStart(JetInstance submitter) {
    PSThatWaitsOnInit.initLatch = new CountDownLatch(1);
    DAG dag = new DAG().vertex(new Vertex("test", new PSThatWaitsOnInit(Identity::new)));
    // When
    Job job = submitter.newJob(dag);
    JobStatus status = job.getStatus();
    assertTrue(status == NOT_STARTED || status == STARTING);
    PSThatWaitsOnInit.initLatch.countDown();
    // Then
    assertCompletedEventually(job);
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) Identity(com.hazelcast.jet.core.TestProcessors.Identity) Job(com.hazelcast.jet.Job)

Example 2 with Identity

use of com.hazelcast.jet.core.TestProcessors.Identity in project hazelcast-jet by hazelcast.

the class JobTest method when_lastSubmittedJobIsCompletedBeforePreviouslySubmittedRunningJob_then_itIsQueriedByName.

@Test
public void when_lastSubmittedJobIsCompletedBeforePreviouslySubmittedRunningJob_then_itIsQueriedByName() {
    // Given
    DAG dag1 = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
    DAG dag2 = new DAG().vertex(new Vertex("test", new MockPS(Identity::new, NODE_COUNT)));
    JobConfig config = new JobConfig();
    String jobName = "job1";
    config.setName(jobName);
    // When
    Job job1 = instance1.newJob(dag1, config);
    sleepAtLeastMillis(1);
    Job job2 = instance1.newJob(dag2, config);
    job2.join();
    // Then
    Job trackedJob = instance1.getJob(jobName);
    assertNotNull(trackedJob);
    assertEquals(jobName, trackedJob.getName());
    assertNotEquals(job1.getId(), trackedJob.getId());
    assertEquals(job2.getId(), trackedJob.getId());
    assertEquals(COMPLETED, trackedJob.getStatus());
    StuckProcessor.proceedLatch.countDown();
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Identity(com.hazelcast.jet.core.TestProcessors.Identity) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig) Test(org.junit.Test)

Example 3 with Identity

use of com.hazelcast.jet.core.TestProcessors.Identity in project hazelcast by hazelcast.

the class JobTest method when_jobSubmittedWithNewJobIfAbsent_then_jobStatusIsStarting.

private void when_jobSubmittedWithNewJobIfAbsent_then_jobStatusIsStarting(HazelcastInstance submitter) {
    PSThatWaitsOnInit.initLatch = new CountDownLatch(1);
    DAG dag = new DAG().vertex(new Vertex("test", new PSThatWaitsOnInit(Identity::new)));
    // When
    Job job = submitter.getJet().newJobIfAbsent(dag, new JobConfig());
    JobStatus status = job.getStatus();
    assertTrue(status == NOT_RUNNING || status == STARTING);
    PSThatWaitsOnInit.initLatch.countDown();
    // Then
    assertJobStatusEventually(job, COMPLETED);
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) Identity(com.hazelcast.jet.core.TestProcessors.Identity) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig)

Example 4 with Identity

use of com.hazelcast.jet.core.TestProcessors.Identity in project hazelcast by hazelcast.

the class JobTest method when_jobSubmitted_then_jobStatusIsStarting.

private void when_jobSubmitted_then_jobStatusIsStarting(HazelcastInstance submitter) {
    PSThatWaitsOnInit.initLatch = new CountDownLatch(1);
    DAG dag = new DAG().vertex(new Vertex("test", new PSThatWaitsOnInit(Identity::new)));
    // When
    Job job = submitter.getJet().newJob(dag);
    JobStatus status = job.getStatus();
    assertTrue(status == NOT_RUNNING || status == STARTING);
    PSThatWaitsOnInit.initLatch.countDown();
    // Then
    assertJobStatusEventually(job, COMPLETED);
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) Identity(com.hazelcast.jet.core.TestProcessors.Identity) Job(com.hazelcast.jet.Job)

Example 5 with Identity

use of com.hazelcast.jet.core.TestProcessors.Identity in project hazelcast-jet by hazelcast.

the class JobTest method when_jobsAreCompletedInReverseOrderOfTheirSubmissionOrder_then_theyAreQueriedByName.

@Test
public void when_jobsAreCompletedInReverseOrderOfTheirSubmissionOrder_then_theyAreQueriedByName() {
    // Given
    DAG dag1 = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
    DAG dag2 = new DAG().vertex(new Vertex("test", new MockPS(Identity::new, NODE_COUNT)));
    JobConfig config = new JobConfig();
    String jobName = "job1";
    config.setName(jobName);
    // When
    Job job1 = instance1.newJob(dag1, config);
    sleepAtLeastMillis(1);
    Job job2 = instance1.newJob(dag2, config);
    job2.join();
    StuckProcessor.proceedLatch.countDown();
    job1.join();
    // Then
    List<Job> jobs = instance1.getJobs(jobName);
    assertEquals(2, jobs.size());
    Job trackedJob1 = jobs.get(0);
    Job trackedJob2 = jobs.get(1);
    assertEquals(job2.getId(), trackedJob1.getId());
    assertEquals(COMPLETED, trackedJob1.getStatus());
    assertEquals(job1.getId(), trackedJob2.getId());
    assertEquals(COMPLETED, trackedJob2.getStatus());
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Identity(com.hazelcast.jet.core.TestProcessors.Identity) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig) Test(org.junit.Test)

Aggregations

Job (com.hazelcast.jet.Job)5 Identity (com.hazelcast.jet.core.TestProcessors.Identity)5 JobConfig (com.hazelcast.jet.config.JobConfig)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)2 StuckProcessor (com.hazelcast.jet.core.TestProcessors.StuckProcessor)2 Test (org.junit.Test)2