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;
}
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();
}
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);
}
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);
}
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());
}
Aggregations