Class EnterpriseSinks
- Since:
- 5.7
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> com.hazelcast.jet.pipeline.Sink<T>mapFlushSink(com.hazelcast.map.IMap<?, ?> map, boolean isLocalFlush) Returns a sink that flushes entries from the specifiedIMapto its configuredMapStoreas part of the Hazelcast Jet snapshotting process.static <T> com.hazelcast.jet.pipeline.Sink<T>mapFlushSink(com.hazelcast.map.IMap<?, ?> map, boolean isLocalFlush, Duration flushTimeout) Returns a sink that flushes entries from the specifiedIMapto its configuredMapStoreas part of the Hazelcast Jet snapshotting process.static <T> com.hazelcast.jet.pipeline.Sink<T>mapFlushSink(String mapName, boolean isLocalFlush) Returns a sink that flushes entries from the specifiedIMapto its configuredMapStoreas part of the Hazelcast Jet snapshotting process.static <T> com.hazelcast.jet.pipeline.Sink<T>mapFlushSink(String mapName, boolean isLocalFlush, Duration flushTimeout) Returns a sink that flushes entries from the specifiedIMapto its configuredMapStoreas part of the Hazelcast Jet snapshotting process.
-
Method Details
-
mapFlushSink
@Nonnull public static <T> com.hazelcast.jet.pipeline.Sink<T> mapFlushSink(@Nonnull String mapName, boolean isLocalFlush) Returns a sink that flushes entries from the specifiedIMapto its configuredMapStoreas part of the Hazelcast Jet snapshotting process.The sink ensures that all pending write-behind updates are flushed to the underlying storage before a job snapshot is committed.
The sink can also be used in batch jobs to flush the
MapStorewhen the job completes, ensuring that all data is persisted before termination.The sink supports two flushing modes:
-
Local flush (
isLocalFlush == true): each processor instance flushes only the partitions owned by the current member. This mode is more efficient but requires that the upstream pipeline processes updates locally and does not repartition or rebalance items before reaching this sink. -
Global flush (
isLocalFlush == false): all partitions across all members are flushed. This mode is less efficient but safe when local processing guarantees cannot be ensured.
Local flush mode must be used only when it is guaranteed that the partitions updated by upstream processors exactly match the partitions flushed by this sink. Otherwise, mismatched partitions may lead to data loss in case of failures.
By default, the system waits indefinitely for the flush operation to complete. To modify this behavior, use the appropriate methods that accept a flush timeout:
Example usage:mapFlushSink(String, boolean, Duration)},mapFlushSink(IMap, boolean, Duration).}// target-map has write-behind MapStore configured p.readFrom(Sources.map("source-imap")) // Rebalance only if required for correct partitioning .rebalance(Map.Entry::getKey) .mapUsingServiceAsync(ServiceFactories.iMapService("target-map"), (map, entry) -> map.putAsync(entry.getKey(), entry.getValue()).toCompletableFuture()) .writeTo(mapFlushSink("target-map", true));Note that local parallelism of
1is sufficient, since this sink does not perform meaningful item processing and only invokesIMap.flush()during snapshotting.- Type Parameters:
T- the type of items accepted by the sink- Parameters:
mapName- the name of theIMapto flushisLocalFlush-trueto flush only partitions owned by the current processor,falseto flush all partitions globally- Returns:
- a sink that flushes the specified
IMapto itsMapStore - Since:
- 5.7
-
Local flush (
-
mapFlushSink
@Nonnull public static <T> com.hazelcast.jet.pipeline.Sink<T> mapFlushSink(@Nonnull com.hazelcast.map.IMap<?, ?> map, boolean isLocalFlush) Returns a sink that flushes entries from the specifiedIMapto its configuredMapStoreas part of the Hazelcast Jet snapshotting process.This method is the same as the
mapFlushSink(String, boolean)} method, but allows to pass the IMap directly.- Type Parameters:
T- the type of items accepted by the sink- Parameters:
map- theIMapto flushisLocalFlush-trueto flush only partitions owned by the current processor,falseto flush all partitions globally- Returns:
- a sink that flushes the specified
IMapto itsMapStore - Since:
- 5.7
-
mapFlushSink
@Nonnull public static <T> com.hazelcast.jet.pipeline.Sink<T> mapFlushSink(@Nonnull String mapName, boolean isLocalFlush, @Nonnull Duration flushTimeout) Returns a sink that flushes entries from the specifiedIMapto its configuredMapStoreas part of the Hazelcast Jet snapshotting process.This method is the same as the
mapFlushSink(String, boolean)} method, but allows to pass flush timeout.flushTimeoutdetermines the maximum time the system waits for the flush operation to finish. If the timeout is reached, the system logs a warning and continues processing without throwing an exception.- Type Parameters:
T- the type of items accepted by the sink- Parameters:
mapName- the name of theIMapto flushisLocalFlush-trueto flush only partitions owned by the current processor,falseto flush all partitions globallyflushTimeout- the maximum time to wait for the flush- Returns:
- a sink that flushes the specified
IMapto itsMapStore - Since:
- 5.7
-
mapFlushSink
@Nonnull public static <T> com.hazelcast.jet.pipeline.Sink<T> mapFlushSink(@Nonnull com.hazelcast.map.IMap<?, ?> map, boolean isLocalFlush, Duration flushTimeout) Returns a sink that flushes entries from the specifiedIMapto its configuredMapStoreas part of the Hazelcast Jet snapshotting process.The same as the
mapFlushSink(String, boolean)} method, but allows to pass the IMap directly and configure flush timeout.flushTimeoutdetermines the maximum time the system waits for the flush operation to finish. If the timeout is reached, the system logs a warning and continues processing without throwing an exception.- Type Parameters:
T- the type of items accepted by the sink- Parameters:
map- theIMapto flushisLocalFlush-trueto flush only partitions owned by the current processor,falseto flush all partitions globallyflushTimeout- the maximum time to wait for the flush- Returns:
- a sink that flushes the specified
IMapto itsMapStore - Since:
- 5.7
-