use of com.hazelcast.jet.core.ProcessorSupplier in project hazelcast by hazelcast.
the class TestSupportTest method test_processorMetaSupplierHasJetInstance.
@Test
public void test_processorMetaSupplierHasJetInstance() {
HazelcastInstance hazelcastInstance = mockHazelcastInstance();
boolean[] called = { false };
verifyProcessor(new ProcessorMetaSupplier() {
@Override
public void init(@Nonnull Context context) {
assertSame(context.hazelcastInstance(), hazelcastInstance);
called[0] = true;
}
@Nonnull
@Override
public Function<? super Address, ? extends ProcessorSupplier> get(@Nonnull List<Address> addresses) {
return a -> ProcessorSupplier.of(MockP::new);
}
}).hazelcastInstance(hazelcastInstance).expectOutput(emptyList());
assertTrue(called[0]);
}
use of com.hazelcast.jet.core.ProcessorSupplier in project hazelcast by hazelcast.
the class TestSupportTest method when_processorSupplierTested_then_completeCalled.
@Test
public void when_processorSupplierTested_then_completeCalled() {
boolean[] completeCalled = { false };
ProcessorSupplier supplier = new ProcessorSupplier() {
@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
assertEquals(1, count);
return singletonList(noopP().get());
}
@Override
public void close(Throwable error) {
completeCalled[0] = true;
}
};
TestSupport.verifyProcessor(supplier).expectOutput(emptyList());
assertTrue("PS.complete not called", completeCalled[0]);
// test once more with PMS
completeCalled[0] = false;
TestSupport.verifyProcessor(ProcessorMetaSupplier.of(supplier)).expectOutput(emptyList());
assertTrue("PS.complete not called when using PMS", completeCalled[0]);
}
use of com.hazelcast.jet.core.ProcessorSupplier in project hazelcast by hazelcast.
the class SqlHashJoinPTest method runTest.
private void runTest(JoinRelType joinType, Expression<Boolean> nonEquiCondition, int rightInputColumnCount, int[] leftEquiJoinIndices, int[] rightEquiJoinIndices, List<JetSqlRow> leftInput, List<JetSqlRow> rightInput, List<JetSqlRow> output) {
ProcessorSupplier processor = SqlHashJoinP.supplier(new JetJoinInfo(joinType, leftEquiJoinIndices, rightEquiJoinIndices, nonEquiCondition, null), rightInputColumnCount);
TestSupport.verifyProcessor(adaptSupplier(processor)).jobConfig(new JobConfig().setArgument(SQL_ARGUMENTS_KEY_NAME, emptyList())).inputs(asList(leftInput, rightInput), new int[] { LOW_PRIORITY, HIGH_PRIORITY }).hazelcastInstance(instance()).outputChecker(SqlTestSupport::compareRowLists).disableSnapshots().expectOutput(output);
}
use of com.hazelcast.jet.core.ProcessorSupplier in project hazelcast by hazelcast.
the class PartitionedProcessorTransform method flatMapUsingServiceAsyncPartitionedTransform.
public static <S, T, K, R> PartitionedProcessorTransform<T, K> flatMapUsingServiceAsyncPartitionedTransform(@Nonnull Transform upstream, @Nonnull String operationName, @Nonnull ServiceFactory<?, S> serviceFactory, int maxConcurrentOps, boolean preserveOrder, @Nonnull BiFunctionEx<? super S, ? super T, CompletableFuture<Traverser<R>>> flatMapAsyncFn, @Nonnull FunctionEx<? super T, ? extends K> partitionKeyFn) {
String name = operationName + "UsingPartitionedServiceAsync";
ProcessorSupplier supplier = flatMapUsingServiceAsyncP(serviceFactory, maxConcurrentOps, preserveOrder, partitionKeyFn, flatMapAsyncFn);
ProcessorMetaSupplier metaSupplier = ProcessorMetaSupplier.of(getPreferredLP(serviceFactory), serviceFactory.permission(), supplier);
return new PartitionedProcessorTransform<>(name, upstream, metaSupplier, partitionKeyFn);
}
use of com.hazelcast.jet.core.ProcessorSupplier in project hazelcast by hazelcast.
the class ProcessorTransform method flatMapUsingServiceAsyncTransform.
public static <S, T, R> ProcessorTransform flatMapUsingServiceAsyncTransform(@Nonnull Transform upstream, @Nonnull String operationName, @Nonnull ServiceFactory<?, S> serviceFactory, int maxConcurrentOps, boolean preserveOrder, @Nonnull BiFunctionEx<? super S, ? super T, ? extends CompletableFuture<Traverser<R>>> flatMapAsyncFn) {
// TODO use better key so that snapshots are local. Currently they will
// be sent to a random member. We keep it this way for simplicity:
// the number of in-flight items is limited (maxConcurrentOps)
ProcessorSupplier supplier = flatMapUsingServiceAsyncP(serviceFactory, maxConcurrentOps, preserveOrder, Object::hashCode, flatMapAsyncFn);
ProcessorMetaSupplier metaSupplier = ProcessorMetaSupplier.of(getPreferredLP(serviceFactory), serviceFactory.permission(), supplier);
return new ProcessorTransform(operationName + "UsingServiceAsync", upstream, metaSupplier);
}
Aggregations