C
- the user-defined context object typepublic final class ContextFactory<C> extends Object implements Serializable
You can use the context factory from these Pipeline API methods:
GeneralStage.mapUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.BiFunctionEx<? super C, ? super T, ? extends R>)
GeneralStage.filterUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.BiPredicateEx<? super C, ? super T>)
GeneralStage.flatMapUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.BiFunctionEx<? super C, ? super T, ? extends com.hazelcast.jet.Traverser<R>>)
GeneralStage.mapUsingContextAsync(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.BiFunctionEx<? super C, ? super T, ? extends java.util.concurrent.CompletableFuture<R>>)
GeneralStage.filterUsingContextAsync(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.BiFunctionEx<? super C, ? super T, ? extends java.util.concurrent.CompletableFuture<java.lang.Boolean>>)
GeneralStage.flatMapUsingContextAsync(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.BiFunctionEx<? super C, ? super T, ? extends java.util.concurrent.CompletableFuture<com.hazelcast.jet.Traverser<R>>>)
GeneralStageWithKey.mapUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.TriFunction<? super C, ? super K, ? super T, ? extends R>)
GeneralStageWithKey.filterUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.TriPredicate<? super C, ? super K, ? super T>)
GeneralStageWithKey.flatMapUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.TriFunction<? super C, ? super K, ? super T, ? extends com.hazelcast.jet.Traverser<? extends R>>)
GeneralStageWithKey.mapUsingContextAsync(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.TriFunction<? super C, ? super K, ? super T, java.util.concurrent.CompletableFuture<R>>)
GeneralStageWithKey.filterUsingContextAsync(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.TriFunction<? super C, ? super K, ? super T, java.util.concurrent.CompletableFuture<java.lang.Boolean>>)
GeneralStageWithKey.flatMapUsingContextAsync(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.TriFunction<? super C, ? super K, ? super T, java.util.concurrent.CompletableFuture<com.hazelcast.jet.Traverser<R>>>)
Modifier and Type | Field and Description |
---|---|
static boolean |
COOPERATIVE_DEFAULT
Default value for
isCooperative . |
static int |
MAX_PENDING_CALLS_DEFAULT
Default value for
maxPendingCallsPerProcessor . |
static boolean |
ORDERED_ASYNC_RESPONSES_DEFAULT
Default value for
hasOrderedAsyncResponses() . |
static boolean |
SHARE_LOCALLY_DEFAULT
Default value for
hasLocalSharing . |
Modifier and Type | Method and Description |
---|---|
FunctionEx<JetInstance,? extends C> |
createFn()
Returns the create-function.
|
ConsumerEx<? super C> |
destroyFn()
Returns the destroy-function.
|
boolean |
hasLocalSharing()
Returns the
hasLocalSharing flag. |
boolean |
hasOrderedAsyncResponses()
Tells whether the async responses are ordered, see
withUnorderedAsyncResponses() . |
boolean |
isCooperative()
Returns the
isCooperative flag. |
int |
maxPendingCallsPerProcessor()
Returns the maximum pending calls per processor, see
withMaxPendingCallsPerProcessor(int) . |
ContextFactory<C> |
toNonCooperative()
Returns a copy of this
ContextFactory with the
isCooperative flag set to false . |
static <C> ContextFactory<C> |
withCreateFn(FunctionEx<JetInstance,? extends C> createContextFn)
Creates a new
ContextFactory with the given create-function. |
ContextFactory<C> |
withDestroyFn(ConsumerEx<? super C> destroyFn)
Returns a copy of this
ContextFactory with the destroy-function
replaced with the given function. |
ContextFactory<C> |
withLocalSharing()
Returns a copy of this
ContextFactory with the
localSharing flag set. |
ContextFactory<C> |
withMaxPendingCallsPerProcessor(int maxPendingCallsPerProcessor)
Returns a copy of this
ContextFactory with the
maxPendingCallsPerProcessor property set to the given value. |
ContextFactory<C> |
withUnorderedAsyncResponses()
Returns a copy of this
ContextFactory with the
unorderedAsyncResponses flag set to true. |
public static final int MAX_PENDING_CALLS_DEFAULT
maxPendingCallsPerProcessor
.public static final boolean COOPERATIVE_DEFAULT
isCooperative
.public static final boolean SHARE_LOCALLY_DEFAULT
hasLocalSharing
.public static final boolean ORDERED_ASYNC_RESPONSES_DEFAULT
hasOrderedAsyncResponses()
.@Nonnull public static <C> ContextFactory<C> withCreateFn(@Nonnull FunctionEx<JetInstance,? extends C> createContextFn)
ContextFactory
with the given create-function.C
- the user-defined context object typecreateContextFn
- the function to create new context object, given
a JetInstance@Nonnull public ContextFactory<C> withDestroyFn(@Nonnull ConsumerEx<? super C> destroyFn)
ContextFactory
with the destroy-function
replaced with the given function.
The destroy function is called at the end of the job to destroy all created context objects.
destroyFn
- the function to destroy user-defined context@Nonnull public ContextFactory<C> toNonCooperative()
ContextFactory
with the
isCooperative flag set to false
. The context factory is
cooperative by default. Call this method if your transform function
doesn't follow the cooperative
processor contract, that is if it waits for IO, blocks for
synchronization, takes too long to complete etc. If you intend to use
the factory for an async operation, you also typically can use a
cooperative processor. Cooperative processors offer higher performance.isCooperative
flag set
to false
.@Nonnull public ContextFactory<C> withLocalSharing()
ContextFactory
with the
localSharing flag set. If the pipeline doesn't have grouping,
there will be:
hasLocalSharing
flag
set.@Nonnull public ContextFactory<C> withMaxPendingCallsPerProcessor(int maxPendingCallsPerProcessor)
ContextFactory
with the
maxPendingCallsPerProcessor property set to the given value. Jet
will execute at most this many concurrent async operations per processor
and will apply backpressure to the upstream.
If you use the same context factory on multiple pipeline stages, each stage will count the pending calls independently.
This value is ignored when the ContextFactory
is used in a
synchronous transformation.
Default value is 256.
maxPendingCallsPerProcessor
property set.@Nonnull public ContextFactory<C> withUnorderedAsyncResponses()
ContextFactory
with the
unorderedAsyncResponses flag set to true.
Jet can process asynchronous responses in two modes:
This value is ignored when the ContextFactory
is used in a
synchronous transformation: the output is always ordered in this case.
unorderedAsyncResponses
flag set.@Nonnull public FunctionEx<JetInstance,? extends C> createFn()
@Nonnull public ConsumerEx<? super C> destroyFn()
public boolean isCooperative()
isCooperative
flag.public boolean hasLocalSharing()
hasLocalSharing
flag.public int maxPendingCallsPerProcessor()
withMaxPendingCallsPerProcessor(int)
.public boolean hasOrderedAsyncResponses()
withUnorderedAsyncResponses()
.Copyright © 2019 Hazelcast, Inc.. All rights reserved.