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);
}
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)));
}
}
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));
}
});
}
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);
}
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);
}
Aggregations