use of com.hazelcast.jet.config.JobConfig 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);
}
use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class JobTest method when_jobSubmittedWithNewJobIfAbsent_then_trackedJobCanQueryStatus.
@Test
public void when_jobSubmittedWithNewJobIfAbsent_then_trackedJobCanQueryStatus() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
// When
Job submittedJob = instance().getJet().newJobIfAbsent(dag, new JobConfig());
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_jobIsCompleted_then_jobSubmissionTimeIsQueried.
@Test
public void when_jobIsCompleted_then_jobSubmissionTimeIsQueried() {
// 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);
NoOutputSourceP.proceedLatch.countDown();
job.join();
Job trackedJob = instance().getJet().getJob(jobName);
// Then
assertNotNull(trackedJob);
assertNotEquals(0, job.getSubmissionTime());
assertNotEquals(0, trackedJob.getSubmissionTime());
}
use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class JobTimeoutClusterTest method when_masterFails_timedOutJobIsCancelled.
@Test
public void when_masterFails_timedOutJobIsCancelled() {
final HazelcastInstance[] instances = createHazelcastInstances(2);
final HazelcastInstance oldMaster = instances[0];
final HazelcastInstance newMaster = instances[1];
assertClusterSizeEventually(2, newMaster);
assertClusterStateEventually(ClusterState.ACTIVE, newMaster);
final DAG dag = new DAG();
dag.newVertex("stuck", () -> new MockP().streaming());
final JobConfig jobConfig = new JobConfig().setTimeoutMillis(10000L).setSnapshotIntervalMillis(1L).setProcessingGuarantee(ProcessingGuarantee.EXACTLY_ONCE);
final Job job = oldMaster.getJet().newJob(dag, jobConfig);
final long jobId = job.getId();
// start and wait for the job to start running
assertJobStatusEventually(job, JobStatus.RUNNING);
final JobRepository oldJobRepository = new JobRepository(oldMaster);
assertTrueEventually(() -> {
final JobExecutionRecord record = oldJobRepository.getJobExecutionRecord(jobId);
assertTrue(record.snapshotId() > 0);
});
// kill old master and wait for the cluster to reconfigure
oldMaster.getLifecycleService().terminate();
assertClusterStateEventually(ClusterState.ACTIVE, newMaster);
assertClusterSize(1, newMaster);
// wait for the job to be restarted and cancelled due to timeout
final Job restartedJob = newMaster.getJet().getJob(jobId);
assertNotNull(restartedJob);
assertJobStatusEventually(restartedJob, JobStatus.FAILED);
}
use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class JobTimeoutTest method when_jobIsCompletedBeforeTimeout_jobIsNotCancelled.
@Test
public void when_jobIsCompletedBeforeTimeout_jobIsNotCancelled() {
final HazelcastInstance hz = createHazelcastInstance();
final DAG dag = new DAG();
dag.newVertex("normal", MockP::new);
final JobConfig jobConfig = new JobConfig().setTimeoutMillis(1000L);
final Job job = hz.getJet().newJob(dag, jobConfig);
job.join();
assertEquals(JobStatus.COMPLETED, job.getStatus());
}
Aggregations