Package com.hazelcast.jet.pipeline
Class SourceBuilder.Batch<T>
java.lang.Object
com.hazelcast.jet.pipeline.SourceBuilder.Batch<T>
- Type Parameters:
T
- type of emitted objects
- Enclosing class:
- SourceBuilder<C>
- Since:
- Jet 3.0
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds and returns the batch source.SourceBuilder<C>.Batch<T>
destroyFn
(ConsumerEx<? super C> destroyFn) Sets the function that Jet will call when it is done cleaning up after an execution.SourceBuilder<C>.Batch<T>
distributed
(int preferredLocalParallelism) Declares that you're creating a distributed source.<T_NEW> SourceBuilder<C>.Batch<T_NEW>
fillBufferFn
(BiConsumerEx<? super C, ? super SourceBuilder.SourceBuffer<T_NEW>> fillBufferFn) Sets the function that Jet will call whenever it needs more data from your source.SourceBuilder<C>.Batch<T>
permission
(Permission permission) Sets the permission required to use this sink when the security is enabled.
-
Method Details
-
fillBufferFn
@Nonnull public <T_NEW> SourceBuilder<C>.Batch<T_NEW> fillBufferFn(@Nonnull BiConsumerEx<? super C, ? super SourceBuilder.SourceBuffer<T_NEW>> fillBufferFn) Sets the function that Jet will call whenever it needs more data from your source. The function receives the context object obtained fromcreateFn
and Jet's buffer object. It should add some items to the buffer, ideally those it can produce without making any blocking calls. On any given invocation the function may also choose not to add any items. Jet will automatically employ an exponential backoff strategy to avoid calling your function in a tight loop, if the previous call didn't add any items to the buffer.The given
SourceBuilder.SourceBuffer
isn't thread-safe, you shouldn't pass it to other threads. For example, you shouldn't add to it in a callback of an asynchronous operation.Once it has emitted all the data, the function must call
SourceBuilder.SourceBuffer.close()
.- Type Parameters:
T_NEW
- type of the emitted items- Parameters:
fillBufferFn
- function that fills the buffer with source data. It must be stateless.- Returns:
- this builder with the item type reset to the one inferred from
fillBufferFn
-
destroyFn
Sets the function that Jet will call when it is done cleaning up after an execution. It gives you the opportunity to release any resources that your context object may be holding. Jet also calls this function when the user cancels or restarts the job.The function must be stateless.
-
distributed
Declares that you're creating a distributed source. On each member of the cluster Jet will create as many processors as you specify with thepreferredLocalParallelism
parameter. If you call this, you must ensure that all the source processors are coordinated and not emitting duplicated data. ThecreateFn
can consultprocessorContext.totalParallelism()
andProcessor.Context.globalProcessorIndex()
. Jet callscreateFn
exactly once with eachglobalProcessorIndex
from 0 tototalParallelism - 1
and you can use this to make all the instances agree on which part of the data to emit.If you don't call this method, there will be only one processor instance running on an arbitrary member.
- Parameters:
preferredLocalParallelism
- the requested number of processors on each cluster member
-
permission
Sets the permission required to use this sink when the security is enabled. The default value isnull
which means there is no restriction to use this sink. Security is an enterprise feature.- Parameters:
permission
- the required permission to use this sink when security is enabled.
-
build
Builds and returns the batch source.
-