use of com.hazelcast.jet.core.test.TestOutbox in project hazelcast by hazelcast.
the class StreamFilesPTest method initializeProcessor.
private void initializeProcessor(String glob) throws Exception {
if (glob == null) {
glob = "*";
}
processor = new StreamFilesP<>(workDir.getAbsolutePath(), UTF_8, glob, false, Util::entry);
outbox = new TestOutbox(1);
Context ctx = new TestProcessorContext().setLogger(Logger.getLogger(StreamFilesP.class));
processor.init(outbox, ctx);
}
use of com.hazelcast.jet.core.test.TestOutbox 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.TestOutbox 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.TestOutbox in project hazelcast-jet by hazelcast.
the class ReadWithPartitionIteratorPTest method when_readFromTwoPartitions_then_emitRoundRobin.
@Test
@SuppressWarnings("unchecked")
public void when_readFromTwoPartitions_then_emitRoundRobin() {
// Given
final List<Integer> partitions = asList(0, 1);
final Iterator<Entry<Integer, Integer>>[] content = new Iterator[] { iterate(51, 52, 53), iterate(71, 72, 73) };
ReadWithPartitionIteratorP<Entry<Integer, Integer>> r = new ReadWithPartitionIteratorP<>(p -> content[p], partitions);
TestOutbox outbox = new TestOutbox(3);
Queue<Object> bucket = outbox.queue(0);
r.init(outbox, mock(Processor.Context.class));
// When
assertFalse(r.complete());
// Then
assertEquals(entry(51), bucket.poll());
assertEquals(entry(71), bucket.poll());
assertEquals(entry(52), bucket.poll());
outbox.reset();
// When
assertTrue(r.complete());
// Then
assertEquals(entry(72), bucket.poll());
assertEquals(entry(53), bucket.poll());
assertEquals(entry(73), bucket.poll());
}
use of com.hazelcast.jet.core.test.TestOutbox 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);
}
Aggregations