Search in sources :

Example 46 with JobConfig

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);
}
Also used : 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 47 with JobConfig

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);
}
Also used : Processor(com.hazelcast.jet.core.Processor) MockP(com.hazelcast.jet.core.TestProcessors.MockP) DAG(com.hazelcast.jet.core.DAG) 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 48 with JobConfig

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);
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) TestProcessors(com.hazelcast.jet.core.TestProcessors) Processor(com.hazelcast.jet.core.Processor) MockP(com.hazelcast.jet.core.TestProcessors.MockP) DAG(com.hazelcast.jet.core.DAG) 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 49 with JobConfig

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));
}
Also used : 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 50 with JobConfig

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);
}
Also used : Job(com.hazelcast.jet.Job) JobRepository(com.hazelcast.jet.impl.JobRepository) 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