T
- type of emitted objectspublic final class SourceBuilder.Batch<T> extends Object
Modifier and Type | Method and Description |
---|---|
BatchSource<T> |
build()
Builds and returns the batch source.
|
SourceBuilder.Batch<T> |
destroyFn(ConsumerEx<? super C> destroyFn)
Sets the function that Jet will call when it is done cleaning up after
an execution.
|
SourceBuilder.Batch<T> |
distributed(int preferredLocalParallelism)
Declares that you're creating a distributed source.
|
<T_NEW> SourceBuilder.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.
|
@Nonnull public <T_NEW> SourceBuilder.Batch<T_NEW> fillBufferFn(@Nonnull BiConsumerEx<? super C,? super SourceBuilder.SourceBuffer<T_NEW>> fillBufferFn)
createFn
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.
Once it has emitted all the data, the function must call SourceBuilder.SourceBuffer.close()
.
T_NEW
- type of the emitted itemsfillBufferFn
- function that fills the buffer with source datafillBufferFn
@Nonnull public SourceBuilder.Batch<T> destroyFn(@Nonnull ConsumerEx<? super C> destroyFn)
@Nonnull public SourceBuilder.Batch<T> distributed(int preferredLocalParallelism)
preferredLocalParallelism
parameter. If you call this, you must
ensure that all the source processors are coordinated and not emitting
duplicated data. The createFn
can consult processorContext.totalParallelism()
and processorContext.globalProcessorIndex()
. Jet calls createFn
exactly once with each globalProcessorIndex
from 0 to totalParallelism - 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.
preferredLocalParallelism
- the requested number of processors on each cluster member@Nonnull public BatchSource<T> build()
Copyright © 2019 Hazelcast, Inc.. All rights reserved.