Search in sources :

Example 66 with JobConfig

use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.

the class NonSmartClientTest method startJobAndVerifyItIsRunning.

private Job startJobAndVerifyItIsRunning() {
    String jobName = randomName();
    DAG dag = streamingDag();
    Job job = nonMasterClient.getJet().newJob(dag, new JobConfig().setName(jobName));
    assertJobStatusEventually(nonMasterClient.getJet().getJob(jobName), JobStatus.RUNNING);
    return job;
}
Also used : DAG(com.hazelcast.jet.core.DAG) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig)

Example 67 with JobConfig

use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.

the class JobTest method when_jobIsRunning_then_itIsQueriedByName.

private void when_jobIsRunning_then_itIsQueriedByName(HazelcastInstance instance) throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
    JobConfig config = new JobConfig();
    String jobName = randomName();
    config.setName(jobName);
    // When
    Job job = instance().getJet().newJob(dag, config);
    assertEquals(jobName, job.getName());
    NoOutputSourceP.executionStarted.await();
    // Then
    Job trackedJob = instance.getJet().getJob(jobName);
    assertNotNull(trackedJob);
    assertEquals(jobName, trackedJob.getName());
    assertEquals(job.getId(), trackedJob.getId());
    assertJobStatusEventually(trackedJob, RUNNING);
    NoOutputSourceP.proceedLatch.countDown();
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig)

Example 68 with JobConfig

use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.

the class JobTest method when_namedJobIsRunning_then_newNamedJobFails.

private void when_namedJobIsRunning_then_newNamedJobFails(HazelcastInstance instance) {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
    JobConfig config = new JobConfig().setName(randomName());
    // When
    Job job1 = instance.getJet().newJob(dag, config);
    assertTrueEventually(() -> assertEquals(RUNNING, job1.getStatus()));
    // Then
    assertThatThrownBy(() -> instance.getJet().newJob(dag, config)).isInstanceOf(JobAlreadyExistsException.class);
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig)

Example 69 with JobConfig

use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.

the class JobTest method when_namedJobSubmittedWithNewJobIfAbsent_then_trackedJobCanQueryStatus.

@Test
public void when_namedJobSubmittedWithNewJobIfAbsent_then_trackedJobCanQueryStatus() throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
    JobConfig config = new JobConfig().setName(randomName());
    // When
    Job submittedJob = instance().getJet().newJobIfAbsent(dag, config);
    NoOutputSourceP.executionStarted.await();
    Collection<Job> trackedJobs = instances()[1].getJet().getJobs();
    Job trackedJob = trackedJobs.stream().filter(j -> j.getId() == submittedJob.getId()).findFirst().orElse(null);
    assertNotNull(trackedJob);
    // Then
    assertJobStatusEventually(trackedJob, RUNNING);
    cancelAndJoin(submittedJob);
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 70 with JobConfig

use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.

the class JobTest method when_jobsCompleted_then_theyAreQueriedByName.

@Test
public void when_jobsCompleted_then_theyAreQueriedByName() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
    JobConfig config = new JobConfig().setName(randomName());
    // When
    Job job1 = instance().getJet().newJob(dag, config);
    NoOutputSourceP.proceedLatch.countDown();
    job1.join();
    sleepAtLeastMillis(1);
    NoOutputSourceP.proceedLatch = new CountDownLatch(1);
    Job job2 = instance().getJet().newJob(dag, config);
    NoOutputSourceP.proceedLatch.countDown();
    job2.join();
    // Then
    assertNotNull(config.getName());
    List<Job> jobs = instance().getJet().getJobs(config.getName());
    assertEquals(2, jobs.size());
    Job trackedJob1 = jobs.get(0);
    Job trackedJob2 = jobs.get(1);
    assertEquals(job2.getId(), trackedJob1.getId());
    assertEquals(config.getName(), trackedJob1.getName());
    assertEquals(COMPLETED, trackedJob1.getStatus());
    assertEquals(job1.getId(), trackedJob2.getId());
    assertEquals(config.getName(), trackedJob2.getName());
    assertEquals(COMPLETED, trackedJob2.getStatus());
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) CountDownLatch(java.util.concurrent.CountDownLatch) JobConfig(com.hazelcast.jet.config.JobConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

JobConfig (com.hazelcast.jet.config.JobConfig)254 Test (org.junit.Test)196 Job (com.hazelcast.jet.Job)160 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)111 QuickTest (com.hazelcast.test.annotation.QuickTest)109 Pipeline (com.hazelcast.jet.pipeline.Pipeline)70 HazelcastInstance (com.hazelcast.core.HazelcastInstance)64 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)46 Category (org.junit.experimental.categories.Category)45 Assert.assertEquals (org.junit.Assert.assertEquals)43 DAG (com.hazelcast.jet.core.DAG)41 JobRepository (com.hazelcast.jet.impl.JobRepository)40 List (java.util.List)36 NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)35 Config (com.hazelcast.config.Config)33 Assert.assertTrue (org.junit.Assert.assertTrue)32 ArrayList (java.util.ArrayList)31 Sinks (com.hazelcast.jet.pipeline.Sinks)28 RUNNING (com.hazelcast.jet.core.JobStatus.RUNNING)27 RunWith (org.junit.runner.RunWith)27