Search in sources :

Example 6 with ProcessorSupplier

use of com.hazelcast.jet.core.ProcessorSupplier in project hazelcast by hazelcast.

the class SourceProcessors method streamJmsTopicP.

/**
 * Returns a supplier of processors for {@link Sources#jmsTopicBuilder}.
 *
 * @param isSharedConsumer true, if {@code createSharedConsumer()} or
 *      {@code createSharedDurableConsumer()} was used to create the
 *      consumer in the {@code consumerFn}
 * @param maxGuarantee maximum processing guarantee for the source. You can
 *      use it to disable acknowledging in transactions to save transaction
 *      overhead
 */
@Nonnull
public static <T> ProcessorMetaSupplier streamJmsTopicP(@Nullable String destination, boolean isSharedConsumer, @Nonnull ProcessingGuarantee maxGuarantee, @Nonnull EventTimePolicy<? super T> eventTimePolicy, @Nonnull SupplierEx<? extends Connection> newConnectionFn, @Nonnull FunctionEx<? super Session, ? extends MessageConsumer> consumerFn, @Nonnull FunctionEx<? super Message, ?> messageIdFn, @Nonnull FunctionEx<? super Message, ? extends T> projectionFn) {
    ProcessorSupplier pSupplier = new StreamJmsP.Supplier<>(destination, maxGuarantee, eventTimePolicy, newConnectionFn, consumerFn, messageIdFn, projectionFn);
    ConnectorPermission permission = ConnectorPermission.jms(destination, ACTION_READ);
    return isSharedConsumer ? ProcessorMetaSupplier.preferLocalParallelismOne(permission, pSupplier) : ProcessorMetaSupplier.forceTotalParallelismOne(pSupplier, newUnsecureUuidString(), permission);
}
Also used : ConnectorPermission(com.hazelcast.security.permission.ConnectorPermission) ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier) ProcessorMetaSupplier(com.hazelcast.jet.core.ProcessorMetaSupplier) StreamEventJournalP.streamRemoteCacheSupplier(com.hazelcast.jet.impl.connector.StreamEventJournalP.streamRemoteCacheSupplier) ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier) Nonnull(javax.annotation.Nonnull)

Example 7 with ProcessorSupplier

use of com.hazelcast.jet.core.ProcessorSupplier in project hazelcast by hazelcast.

the class ExecutionPlan method initProcSuppliers.

// End implementation of IdentifiedDataSerializable
private void initProcSuppliers(long jobId, ConcurrentHashMap<String, File> tempDirectories, InternalSerializationService jobSerializationService) {
    for (VertexDef vertex : vertices) {
        ClassLoader processorClassLoader = isLightJob ? null : jobClassLoaderService.getProcessorClassLoader(jobId, vertex.name());
        ProcessorSupplier supplier = vertex.processorSupplier();
        String prefix = prefix(jobConfig.getName(), jobId, vertex.name(), "#PS");
        ILogger logger = prefixedLogger(nodeEngine.getLogger(supplier.getClass()), prefix);
        doWithClassLoader(processorClassLoader, () -> supplier.init(new ProcSupplierCtx(nodeEngine, jobId, executionId, jobConfig, logger, vertex.name(), vertex.localParallelism(), vertex.localParallelism() * memberCount, memberIndex, memberCount, isLightJob, partitionAssignment, tempDirectories, jobSerializationService, subject, processorClassLoader)));
    }
}
Also used : ProcSupplierCtx(com.hazelcast.jet.impl.execution.init.Contexts.ProcSupplierCtx) Util.doWithClassLoader(com.hazelcast.jet.impl.util.Util.doWithClassLoader) ILogger(com.hazelcast.logging.ILogger) ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier)

Example 8 with ProcessorSupplier

use of com.hazelcast.jet.core.ProcessorSupplier in project hazelcast by hazelcast.

the class WriteJdbcP method metaSupplier.

/**
 * Use {@link SinkProcessors#writeJdbcP}.
 */
public static <T> ProcessorMetaSupplier metaSupplier(@Nullable String jdbcUrl, @Nonnull String updateQuery, @Nonnull SupplierEx<? extends CommonDataSource> dataSourceSupplier, @Nonnull BiConsumerEx<? super PreparedStatement, ? super T> bindFn, boolean exactlyOnce, int batchLimit) {
    checkSerializable(dataSourceSupplier, "newConnectionFn");
    checkSerializable(bindFn, "bindFn");
    checkPositive(batchLimit, "batchLimit");
    return ProcessorMetaSupplier.preferLocalParallelismOne(ConnectorPermission.jdbc(jdbcUrl, ACTION_WRITE), new ProcessorSupplier() {

        private transient CommonDataSource dataSource;

        @Override
        public void init(@Nonnull Context context) {
            dataSource = dataSourceSupplier.get();
        }

        @Nonnull
        @Override
        public Collection<? extends Processor> get(int count) {
            return IntStream.range(0, count).mapToObj(i -> new WriteJdbcP<>(updateQuery, dataSource, bindFn, exactlyOnce, batchLimit)).collect(Collectors.toList());
        }

        @Override
        public List<Permission> permissions() {
            return singletonList(ConnectorPermission.jdbc(jdbcUrl, ACTION_WRITE));
        }
    });
}
Also used : Processor(com.hazelcast.jet.core.Processor) Nonnull(javax.annotation.Nonnull) Collection(java.util.Collection) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier) CommonDataSource(javax.sql.CommonDataSource)

Example 9 with ProcessorSupplier

use of com.hazelcast.jet.core.ProcessorSupplier in project hazelcast by hazelcast.

the class PartitionedProcessorTransform method flatMapUsingServiceAsyncBatchedPartitionedTransform.

public static <S, T, K, R> PartitionedProcessorTransform<T, K> flatMapUsingServiceAsyncBatchedPartitionedTransform(@Nonnull Transform upstream, @Nonnull String operationName, @Nonnull ServiceFactory<?, S> serviceFactory, int maxConcurrentOps, int maxBatchSize, @Nonnull BiFunctionEx<? super S, ? super List<T>, ? extends CompletableFuture<Traverser<R>>> flatMapAsyncFn, @Nonnull FunctionEx<? super T, ? extends K> partitionKeyFn) {
    String name = operationName + "UsingPartitionedServiceAsync";
    ProcessorSupplier supplier = flatMapUsingServiceAsyncBatchedP(serviceFactory, maxConcurrentOps, maxBatchSize, flatMapAsyncFn);
    ProcessorMetaSupplier metaSupplier = ProcessorMetaSupplier.of(getPreferredLP(serviceFactory), serviceFactory.permission(), supplier);
    return new PartitionedProcessorTransform<>(name, upstream, metaSupplier, partitionKeyFn);
}
Also used : ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier) ProcessorMetaSupplier(com.hazelcast.jet.core.ProcessorMetaSupplier)

Example 10 with ProcessorSupplier

use of com.hazelcast.jet.core.ProcessorSupplier in project hazelcast by hazelcast.

the class ProcessorTransform method flatMapUsingServiceAsyncBatchedTransform.

public static <S, T, R> ProcessorTransform flatMapUsingServiceAsyncBatchedTransform(@Nonnull Transform upstream, @Nonnull String operationName, @Nonnull ServiceFactory<?, S> serviceFactory, int maxConcurrentOps, int maxBatchSize, @Nonnull BiFunctionEx<? super S, ? super List<T>, ? extends CompletableFuture<Traverser<R>>> flatMapAsyncFn) {
    String name = operationName + "UsingServiceAsyncBatched";
    ProcessorSupplier supplier = flatMapUsingServiceAsyncBatchedP(serviceFactory, maxConcurrentOps, maxBatchSize, flatMapAsyncFn);
    ProcessorMetaSupplier metaSupplier = ProcessorMetaSupplier.of(getPreferredLP(serviceFactory), serviceFactory.permission(), supplier);
    return new ProcessorTransform(name, upstream, metaSupplier);
}
Also used : ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier) ProcessorMetaSupplier(com.hazelcast.jet.core.ProcessorMetaSupplier)

Aggregations

ProcessorSupplier (com.hazelcast.jet.core.ProcessorSupplier)29 ProcessorMetaSupplier (com.hazelcast.jet.core.ProcessorMetaSupplier)14 Nonnull (javax.annotation.Nonnull)10 Test (org.junit.Test)9 List (java.util.List)8 Function (java.util.function.Function)8 JobConfig (com.hazelcast.jet.config.JobConfig)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Traverser (com.hazelcast.jet.Traverser)5 DAG (com.hazelcast.jet.core.DAG)5 Processor (com.hazelcast.jet.core.Processor)5 Vertex (com.hazelcast.jet.core.Vertex)5 EdgeConfig (com.hazelcast.jet.config.EdgeConfig)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 FunctionEx (com.hazelcast.function.FunctionEx)3 Edge (com.hazelcast.jet.core.Edge)3 Address (com.hazelcast.nio.Address)3 Map (java.util.Map)3 Assert.assertEquals (org.junit.Assert.assertEquals)3