use of com.hazelcast.jet.core.Processor in project hazelcast by hazelcast.
the class AsyncTransformUsingServicePTest method test_watermarksConflated.
@Test
public void test_watermarksConflated() throws Exception {
Processor processor = getSupplier(2, (ctx, item) -> new CompletableFuture<>()).get(1).iterator().next();
processor.init(new TestOutbox(128), new TestProcessorContext());
TestInbox inbox = new TestInbox();
// i have to add an item first because otherwise the WMs are forwarded right away
inbox.add("foo");
processor.process(0, inbox);
assertTrue("inbox not empty", inbox.isEmpty());
assertTrue("wm rejected", processor.tryProcessWatermark(wm(0)));
assertTrue("wm rejected", processor.tryProcessWatermark(wm(1)));
assertTrue("wm rejected", processor.tryProcessWatermark(wm(2)));
}
use of com.hazelcast.jet.core.Processor in project hazelcast by hazelcast.
the class SinksTest method mapWithMerging_when_multipleValuesForSingleKeyInABatch.
@Test
public void mapWithMerging_when_multipleValuesForSingleKeyInABatch() throws Exception {
ProcessorMetaSupplier metaSupplier = adaptSupplier(SinkProcessors.<Entry<String, Integer>, String, Integer>mergeMapP(sinkName, Entry::getKey, Entry::getValue, Integer::sum));
TestProcessorSupplierContext psContext = new TestProcessorSupplierContext().setHazelcastInstance(member);
Processor p = TestSupport.supplierFrom(metaSupplier, psContext).get();
TestOutbox outbox = new TestOutbox();
p.init(outbox, new TestProcessorContext().setHazelcastInstance(member));
TestInbox inbox = new TestInbox();
inbox.add(entry("k", 1));
inbox.add(entry("k", 2));
p.process(0, inbox);
assertTrue("inbox.isEmpty()", inbox.isEmpty());
assertTrueEventually(() -> {
assertTrue("p.complete()", p.complete());
}, 10);
p.close();
// assert the output map contents
IMap<Object, Object> actual = member.getMap(sinkName);
assertEquals(1, actual.size());
assertEquals(3, actual.get("k"));
}
use of com.hazelcast.jet.core.Processor 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.core.Processor in project hazelcast by hazelcast.
the class JobMetrics_StressTest method buildDag.
private DAG buildDag() {
DAG dag = new DAG();
dag.newVertex("p", (SupplierEx<Processor>) IncrementingProcessor::new);
return dag;
}
use of com.hazelcast.jet.core.Processor in project hazelcast by hazelcast.
the class StreamEventJournalPTest method when_lostItems.
@Test
public void when_lostItems() throws Exception {
TestOutbox outbox = new TestOutbox(new int[] { 16 }, 16);
Processor p = supplier.get();
p.init(outbox, new TestProcessorContext().setHazelcastInstance(instance));
// overflow the journal
fillJournal(CAPACITY_PER_PARTITION + 1);
// fill and consume
List<Object> actual = new ArrayList<>();
assertTrueEventually(() -> {
assertFalse("Processor should never complete", p.complete());
outbox.drainQueueAndReset(0, actual, true);
assertTrue("consumed different number of items than expected", actual.size() == JOURNAL_CAPACITY);
}, 3);
}
Aggregations