use of com.hazelcast.jet.core.Processor in project hazelcast-jet by hazelcast.
the class WriteLoggerPTest method test.
@Test
public void test() {
// Given
Processor p = supplierFrom(writeLoggerP()).get();
TestInbox inbox = new TestInbox();
Outbox outbox = mock(Outbox.class);
ILogger logger = mock(ILogger.class);
p.init(outbox, new TestProcessorContext().setLogger(logger));
// When
inbox.add(1);
p.process(0, inbox);
Watermark wm = new Watermark(2);
p.tryProcessWatermark(wm);
// Then
verifyZeroInteractions(outbox);
verify(logger).info("1");
verify(logger).fine(wm.toString());
verifyZeroInteractions(logger);
}
use of com.hazelcast.jet.core.Processor in project hazelcast-jet by hazelcast.
the class WriteSocketTest method unitTest.
@Test
public void unitTest() throws Exception {
AtomicInteger counter = new AtomicInteger();
ServerSocket serverSocket = new ServerSocket(0);
new Thread(() -> uncheckRun(() -> {
Socket socket = serverSocket.accept();
serverSocket.close();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
while (reader.readLine() != null) {
counter.incrementAndGet();
}
}
})).start();
TestInbox inbox = new TestInbox();
range(0, ITEM_COUNT).forEach(inbox::add);
Processor p = supplierFrom(writeSocketP("localhost", serverSocket.getLocalPort(), Object::toString, UTF_8)).get();
p.init(mock(Outbox.class), new TestProcessorContext());
p.process(0, inbox);
p.complete();
assertTrueEventually(() -> assertTrue(counter.get() >= ITEM_COUNT));
// wait a little to check, if the counter doesn't get too far
Thread.sleep(500);
assertEquals(ITEM_COUNT, counter.get());
}
use of com.hazelcast.jet.core.Processor in project hazelcast by hazelcast.
the class JoinByEquiJoinProcessorSupplier method get.
@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
List<Processor> processors = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
PartitionIdSet partitions = this.partitions == null ? null : new PartitionIdSet(partitionCount, this.partitions);
QueryPath[] rightPaths = rightRowProjectorSupplier.paths();
KvRowProjector rightProjector = rightRowProjectorSupplier.get(evalContext, extractors);
Processor processor = new TransformP<JetSqlRow, JetSqlRow>(joinFn(joinInfo, map, partitions, rightPaths, rightProjector, evalContext)) {
@Override
public boolean isCooperative() {
return false;
}
};
processors.add(processor);
}
return processors;
}
use of com.hazelcast.jet.core.Processor in project hazelcast by hazelcast.
the class JoinScanProcessorSupplier method get.
@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
List<Processor> processors = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
Processor processor = new TransformBatchedP<JetSqlRow, JetSqlRow>(joinFn(joinInfo, map, rightRowProjectorSupplier, evalContext)) {
@Override
public boolean isCooperative() {
return false;
}
};
processors.add(processor);
}
return processors;
}
use of com.hazelcast.jet.core.Processor in project hazelcast by hazelcast.
the class RowProjectorProcessorSupplier method get.
@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
List<Processor> processors = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
KvRowProjector projector = projectorSupplier.get(evalContext, extractors);
Processor processor = new StreamKafkaP<>(properties, singletonList(topic), record -> projector.project(record.key(), record.value()), eventTimePolicy);
processors.add(processor);
}
return processors;
}
Aggregations