use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast-jet by hazelcast.
the class SessionWindowP_failoverTest method init.
private void init(ProcessingGuarantee guarantee) {
AggregateOperation1<Object, LongAccumulator, Long> aggrOp = counting();
p = new SessionWindowP<>(5000, singletonList((DistributedToLongFunction<Entry<?, Long>>) Entry::getValue), singletonList(entryKey()), aggrOp, WindowResult::new);
Outbox outbox = new TestOutbox(128);
Context context = new TestProcessorContext().setProcessingGuarantee(guarantee);
p.init(outbox, context);
}
use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast-jet by hazelcast.
the class SlidingWindowP_failoverTest method init.
private void init(ProcessingGuarantee guarantee) {
SlidingWindowPolicy wDef = SlidingWindowPolicy.tumblingWinPolicy(1);
AggregateOperation1<Object, LongAccumulator, Long> aggrOp = counting();
p = new SlidingWindowP<>(singletonList(entryKey()), singletonList((DistributedToLongFunction<Entry<?, Long>>) Entry::getValue), wDef, aggrOp, TimestampedEntry::new, true);
Outbox outbox = new TestOutbox(128);
Context context = new TestProcessorContext().setProcessingGuarantee(guarantee);
p.init(outbox, context);
}
use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast-jet by hazelcast.
the class StreamEventJournalPTest method when_lostItems_afterRestore.
@Test
public void when_lostItems_afterRestore() {
TestOutbox outbox = new TestOutbox(new int[] { 16 }, 16);
final Processor p = supplier.get();
p.init(outbox, new TestProcessorContext());
List<Object> output = new ArrayList<>();
assertTrueEventually(() -> {
assertFalse("Processor should never complete", p.complete());
outbox.drainQueueAndReset(0, output, true);
assertTrue("consumed different number of items than expected", output.size() == 0);
}, 3);
assertTrueEventually(() -> {
assertTrue("Processor did not finish snapshot", p.saveToSnapshot());
}, 3);
// overflow journal
fillJournal(CAPACITY_PER_PARTITION + 1);
List<Entry> snapshotItems = new ArrayList<>();
outbox.drainSnapshotQueueAndReset(snapshotItems, false);
System.out.println("Restoring journal");
// restore from snapshot
assertRestore(snapshotItems);
}
use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast-jet by hazelcast.
the class StreamEventJournalPTest method when_lostItems.
@Test
public void when_lostItems() {
TestOutbox outbox = new TestOutbox(new int[] { 16 }, 16);
Processor p = supplier.get();
p.init(outbox, new TestProcessorContext());
// 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);
}
use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast-jet by hazelcast.
the class StreamEventJournalPTest method assertRestore.
private void assertRestore(List<Entry> snapshotItems) {
Processor p = supplier.get();
TestOutbox newOutbox = new TestOutbox(new int[] { 16 }, 16);
List<Object> output = new ArrayList<>();
p.init(newOutbox, new TestProcessorContext());
TestInbox inbox = new TestInbox();
inbox.addAll(snapshotItems);
p.restoreFromSnapshot(inbox);
p.finishSnapshotRestore();
assertTrueEventually(() -> {
assertFalse("Processor should never complete", p.complete());
newOutbox.drainQueueAndReset(0, output, true);
assertEquals("consumed different number of items than expected", JOURNAL_CAPACITY, output.size());
}, 3);
}
Aggregations