use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class JobExecutionMetricsTest method testExecutionMetricsBatchJob.
@Test
public void testExecutionMetricsBatchJob() {
JobConfig jobConfig = new JobConfig();
jobConfig.setStoreMetricsAfterJobCompletion(true);
Job job = instance().getJet().newJob(batchPipeline(), jobConfig);
job.join();
JobMetricsChecker checker = new JobMetricsChecker(job);
assertTrueEventually(() -> checker.assertSummedMetricValueAtLeast(EXECUTION_START_TIME, 1));
long executionStartTime = checker.assertSummedMetricValueAtLeast(EXECUTION_START_TIME, 1);
checker.assertSummedMetricValueAtLeast(EXECUTION_COMPLETION_TIME, executionStartTime);
}
use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class JobMetrics_MiscTest method when_metricsForJobDisabled_then_emptyMetrics.
@Test
public void when_metricsForJobDisabled_then_emptyMetrics() throws Throwable {
DAG dag = new DAG();
dag.newVertex("v1", MockP::new);
dag.newVertex("v2", (SupplierEx<Processor>) NoOutputSourceP::new);
JobConfig config = new JobConfig().setMetricsEnabled(false).setStoreMetricsAfterJobCompletion(true);
Job job = hz().getJet().newJob(dag, config);
// when
NoOutputSourceP.executionStarted.await();
assertJobStatusEventually(job, JobStatus.RUNNING);
// then
assertTrueAllTheTime(() -> assertEmptyJobMetrics(job, false), 2);
// when
NoOutputSourceP.proceedLatch.countDown();
job.join();
assertJobStatusEventually(job, JobStatus.COMPLETED);
// then
assertEmptyJobMetrics(job, true);
}
use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class JobMetrics_MiscTest method when_jobSuspended_andMetricsNotStored_then_onlyPeriodicMetricsReturned.
@Test
public void when_jobSuspended_andMetricsNotStored_then_onlyPeriodicMetricsReturned() throws Throwable {
DAG dag = new DAG();
Vertex v1 = dag.newVertex("v1", TestProcessors.MockP::new);
Vertex v2 = dag.newVertex("v2", (SupplierEx<Processor>) TestProcessors.NoOutputSourceP::new);
dag.edge(between(v1, v2));
// init
JobConfig config = new JobConfig().setMetricsEnabled(// enable metric collection
true).setStoreMetricsAfterJobCompletion(// disable metric saving on completion
false);
Job job = hz().getJet().newJob(dag, config);
// when
TestProcessors.NoOutputSourceP.executionStarted.await();
// then
assertJobStatusEventually(job, JobStatus.RUNNING);
assertTrueEventually(() -> assertJobHasMetrics(job, false));
// when
job.suspend();
// then
assertJobStatusEventually(job, SUSPENDED);
assertTrueEventually(() -> assertEmptyJobMetrics(job, false));
// when
job.resume();
// then
assertJobStatusEventually(job, RUNNING);
assertTrueEventually(() -> assertJobHasMetrics(job, false));
// when
TestProcessors.NoOutputSourceP.proceedLatch.countDown();
job.join();
// then
assertJobStatusEventually(job, JobStatus.COMPLETED);
assertEmptyJobMetrics(job, false);
}
use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class JobMetrics_StreamTest method when_suspendAndResume_then_metricsReset.
@Test
public void when_suspendAndResume_then_metricsReset() {
Map<String, String> map = hz().getMap(journalMapName);
putIntoMap(map, 2, 1);
List<String> sink = hz().getList(sinkListName);
JobConfig jobConfig = new JobConfig().setStoreMetricsAfterJobCompletion(true).setProcessingGuarantee(ProcessingGuarantee.EXACTLY_ONCE);
// When
Job job = hz().getJet().newJob(createPipeline(), jobConfig);
putIntoMap(map, 1, 1);
assertTrueEventually(() -> assertEquals(3, sink.size()));
assertTrueEventually(() -> assertMetrics(job.getMetrics(), 5, 2));
job.suspend();
assertJobStatusEventually(job, SUSPENDED);
assertTrue(job.getMetrics().metrics().isEmpty());
putIntoMap(map, 1, 1);
job.resume();
assertJobStatusEventually(job, RUNNING);
assertTrueEventually(() -> assertEquals(4, sink.size()));
// Then
assertTrueEventually(() -> assertMetrics(job.getMetrics(), 2, 1));
putIntoMap(map, 1, 1);
assertTrueEventually(() -> assertEquals(5, sink.size()));
// Then
assertTrueEventually(() -> assertMetrics(job.getMetrics(), 4, 2));
}
use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class JobSnapshotMetricsTest method when_snapshotCreated_then_snapshotMetricsAreEmptyForStatelessVertex.
@Test
public void when_snapshotCreated_then_snapshotMetricsAreEmptyForStatelessVertex() throws Exception {
JobConfig jobConfig = new JobConfig();
jobConfig.setProcessingGuarantee(ProcessingGuarantee.EXACTLY_ONCE).setSnapshotIntervalMillis(50);
Job job = instance().getJet().newJob(pipeline(), jobConfig);
JobRepository jr = new JobRepository(instance());
waitForFirstSnapshot(jr, job.getId(), 20, false);
JobMetricsChecker checker = new JobMetricsChecker(job);
assertTrueEventually(() -> checker.assertSummedMetricValueAtLeast(MetricNames.SNAPSHOT_KEYS, 1));
assertSnapshotMBeans(job, FILTER_VERTEX_NAME, 0, false);
}
Aggregations