Search in sources :

Example 51 with JobConfig

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

the class MetricsTest method metricsDisabled.

@Test
public void metricsDisabled() {
    Long[] input = { 0L, 1L, 2L, 3L, 4L };
    pipeline.readFrom(TestSources.items(input)).map(l -> {
        Metrics.metric("mapped").increment();
        Metrics.metric("total", Unit.COUNT).set(input.length);
        return l;
    }).writeTo(Sinks.noop());
    Job job = instance.getJet().newJob(pipeline, new JobConfig().setMetricsEnabled(false));
    job.join();
    JobMetrics metrics = job.getMetrics();
    assertTrue(metrics.get("mapped").isEmpty());
    assertTrue(metrics.get("total").isEmpty());
}
Also used : ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) AggregateOperations.counting(com.hazelcast.jet.aggregate.AggregateOperations.counting) Arrays(java.util.Arrays) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) Processor(com.hazelcast.jet.core.Processor) Processors(com.hazelcast.jet.core.processor.Processors) CompletableFuture(java.util.concurrent.CompletableFuture) ServiceFactories.nonSharedService(com.hazelcast.jet.pipeline.ServiceFactories.nonSharedService) HashSet(java.util.HashSet) TestProcessors(com.hazelcast.jet.core.TestProcessors) Arrays.asList(java.util.Arrays.asList) DAG(com.hazelcast.jet.core.DAG) Edge(com.hazelcast.jet.core.Edge) Job(com.hazelcast.jet.Job) Before(org.junit.Before) JobRepository(com.hazelcast.jet.impl.JobRepository) Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) FunctionEx(com.hazelcast.function.FunctionEx) Pipeline(com.hazelcast.jet.pipeline.Pipeline) JetTestSupport(com.hazelcast.jet.core.JetTestSupport) EXACTLY_ONCE(com.hazelcast.jet.config.ProcessingGuarantee.EXACTLY_ONCE) JobConfig(com.hazelcast.jet.config.JobConfig) Sinks(com.hazelcast.jet.pipeline.Sinks) Assert.assertTrue(org.junit.Assert.assertTrue) ResettableSingletonTraverser(com.hazelcast.jet.core.ResettableSingletonTraverser) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) SupplierEx(com.hazelcast.function.SupplierEx) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) Vertex(com.hazelcast.jet.core.Vertex) TestSources(com.hazelcast.jet.pipeline.test.TestSources) List(java.util.List) LongAccumulator(com.hazelcast.jet.accumulator.LongAccumulator) Assert.assertFalse(org.junit.Assert.assertFalse) TransformP(com.hazelcast.jet.impl.processor.TransformP) FunctionEx.identity(com.hazelcast.function.FunctionEx.identity) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) RUNNING(com.hazelcast.jet.core.JobStatus.RUNNING) Assert.assertEquals(org.junit.Assert.assertEquals) Edge.between(com.hazelcast.jet.core.Edge.between) SinkProcessors.writeListP(com.hazelcast.jet.core.processor.SinkProcessors.writeListP) 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 52 with JobConfig

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

the class SnapshotFailureTest method when_snapshotFails_then_jobShouldNotFail.

@Test
public void when_snapshotFails_then_jobShouldNotFail() {
    storeFailed = false;
    int numPartitions = 2;
    int numElements = 10;
    IMap<Object, Object> results = instance1.getMap("results");
    DAG dag = new DAG();
    SupplierEx<Processor> sup = () -> new SequencesInPartitionsGeneratorP(numPartitions, numElements, false);
    Vertex generator = dag.newVertex("generator", peekOutputP(throttle(sup, 2))).localParallelism(1);
    Vertex writeMap = dag.newVertex("writeMap", writeMapP(results.getName())).localParallelism(1);
    dag.edge(between(generator, writeMap));
    JobConfig config = new JobConfig();
    config.setProcessingGuarantee(ProcessingGuarantee.EXACTLY_ONCE);
    config.setSnapshotIntervalMillis(100);
    Job job = instance1.getJet().newJob(dag, config);
    job.join();
    assertEquals("numPartitions", numPartitions, results.size());
    assertEquals("offset partition 0", numElements - 1, results.get(0));
    assertEquals("offset partition 1", numElements - 1, results.get(1));
    assertTrue("no failure occurred in store", storeFailed);
}
Also used : SequencesInPartitionsGeneratorP(com.hazelcast.jet.core.JobRestartWithSnapshotTest.SequencesInPartitionsGeneratorP) 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 53 with JobConfig

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

the class JobRepositoryTest method test_getJobRecordFromClient.

@Test
public void test_getJobRecordFromClient() {
    HazelcastInstance client = createHazelcastClient();
    Pipeline p = Pipeline.create();
    p.readFrom(Sources.streamFromProcessor("source", ProcessorMetaSupplier.of(() -> new NoOutputSourceP()))).withoutTimestamps().writeTo(Sinks.logger());
    Job job = instance.getJet().newJob(p, new JobConfig().setProcessingGuarantee(ProcessingGuarantee.EXACTLY_ONCE).setSnapshotIntervalMillis(100));
    JobRepository jobRepository = new JobRepository(client);
    assertTrueEventually(() -> assertNotNull(jobRepository.getJobRecord(job.getId())));
    client.shutdown();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig) Pipeline(com.hazelcast.jet.pipeline.Pipeline) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 54 with JobConfig

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

the class JobSummaryTest method when_batchJob.

@Test
public void when_batchJob() {
    Job job = instance.getJet().newJob(newBatchPipeline(), new JobConfig().setName("jobA"));
    job.join();
    List<JobSummary> list = getJetClientInstanceImpl(client).getJobSummaryList();
    assertEquals(1, list.size());
    JobSummary jobSummary = list.get(0);
    assertFalse(jobSummary.isLightJob());
    assertEquals("jobA", jobSummary.getNameOrId());
    assertEquals(job.getId(), jobSummary.getJobId());
    assertEquals(JobStatus.COMPLETED, jobSummary.getStatus());
    assertNull(jobSummary.getFailureText());
}
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 55 with JobConfig

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

the class SourceBuilderTest method test_nonFaultTolerantSource_processingGuaranteeOn.

@Test
public void test_nonFaultTolerantSource_processingGuaranteeOn() {
    StreamSource<Integer> source = SourceBuilder.stream("src", procCtx -> "foo").<Integer>fillBufferFn((ctx, buffer) -> {
        buffer.add(0);
        Thread.sleep(100);
    }).build();
    Pipeline p = Pipeline.create();
    IList<Integer> result = hz().getList("result-" + UuidUtil.newUnsecureUuidString());
    p.readFrom(source).withoutTimestamps().writeTo(Sinks.list(result));
    Job job = hz().getJet().newJob(p, new JobConfig().setProcessingGuarantee(EXACTLY_ONCE).setSnapshotIntervalMillis(100));
    JobRepository jr = new JobRepository(hz());
    waitForFirstSnapshot(jr, job.getId(), 10, true);
    job.restart();
    assertJobStatusEventually(job, JobStatus.RUNNING);
    int currentSize = result.size();
    assertTrueEventually(() -> assertTrue(result.size() > currentSize), 5);
}
Also used : IntStream(java.util.stream.IntStream) Socket(java.net.Socket) NANOSECONDS(java.util.concurrent.TimeUnit.NANOSECONDS) ArrayList(java.util.ArrayList) ServerSocket(java.net.ServerSocket) WindowDefinition.tumbling(com.hazelcast.jet.pipeline.WindowDefinition.tumbling) Map(java.util.Map) UuidUtil(com.hazelcast.internal.util.UuidUtil) OutputStreamWriter(java.io.OutputStreamWriter) JobStatus(com.hazelcast.jet.core.JobStatus) Job(com.hazelcast.jet.Job) IList(com.hazelcast.collection.IList) JobRepository(com.hazelcast.jet.impl.JobRepository) PrintWriter(java.io.PrintWriter) FunctionEx(com.hazelcast.function.FunctionEx) LongStream(java.util.stream.LongStream) Iterator(java.util.Iterator) EXACTLY_ONCE(com.hazelcast.jet.config.ProcessingGuarantee.EXACTLY_ONCE) JobConfig(com.hazelcast.jet.config.JobConfig) FileWriter(java.io.FileWriter) AggregateOperations(com.hazelcast.jet.aggregate.AggregateOperations) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) Serializable(java.io.Serializable) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ToLongFunctionEx(com.hazelcast.function.ToLongFunctionEx) Assert.assertFalse(org.junit.Assert.assertFalse) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) Assert.assertEquals(org.junit.Assert.assertEquals) WindowResult(com.hazelcast.jet.datamodel.WindowResult) Job(com.hazelcast.jet.Job) JobRepository(com.hazelcast.jet.impl.JobRepository) JobConfig(com.hazelcast.jet.config.JobConfig) 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