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