@Beta public final class Hz3Sinks extends Object
The usage is similar to Sinks.remoteMap(String, ClientConfig)
.
Because of incompatible APIs the configuration is passed as an XML
document in a string - note that the XML configuration must conform
to 3.x schema - see
https://www.hazelcast.com/schema/config/.
Usage:
String clientConfig = "...";
Sink<Map.Entry<Integer, String>> sink =
Hz3Sinks.map("test-map", HZ3_CLIENT_CONFIG);
p.readFrom(source)
.writeTo(sink);
Additionally, a custom classpath element for the source
stage
must be set with the Hazelcast 3 client and the Hazelcast 3 connector:
List<String> jars = new ArrayList<>();
jars.add("hazelcast-3.12.13.jar");
jars.add("hazelcast-client-3.12.13.jar");
jars.add("hazelcast-3-connector-impl.jar");
JobConfig config = new JobConfig();
config.addCustomClasspaths(sink.name(), jars)
The jars must exist in the directory specified by the
ClusterProperty.PROCESSOR_CUSTOM_LIB_DIR
directory. This is already set up for the regular zip distribution.
Modifier and Type | Method and Description |
---|---|
static <T,K,V> Sink<T> |
remoteMap(String mapName,
FunctionEx<? super T,? extends K> toKeyFn,
FunctionEx<? super T,? extends V> toValueFn,
String clientXml)
Returns a sink that uses the supplied functions to extract the key
and value with which to put to a Hazelcast
IMap with the
specified name. |
static <K,V> Sink<Map.Entry<K,V>> |
remoteMap(String mapName,
String clientXml)
Returns a sink that puts
Map.Entry s it receives into a Hazelcast
IMap with the specified name. |
@Beta @Nonnull public static <K,V> Sink<Map.Entry<K,V>> remoteMap(@Nonnull String mapName, @Nonnull String clientXml)
Map.Entry
s it receives into a Hazelcast
IMap
with the specified name.
This sink provides the exactly-once guarantee thanks to idempotent updates. It means that the value with the same key is not appended, but overwritten. After the job is restarted from snapshot, duplicate items will not change the state in the target map.
The default local parallelism for this sink is 1.
@Beta @Nonnull public static <T,K,V> Sink<T> remoteMap(@Nonnull String mapName, @Nonnull FunctionEx<? super T,? extends K> toKeyFn, @Nonnull FunctionEx<? super T,? extends V> toValueFn, @Nonnull String clientXml)
IMap
with the
specified name.
This sink provides the exactly-once guarantee thanks to idempotent updates. It means that the value with the same key is not appended, but overwritten. After the job is restarted from snapshot, duplicate items will not change the state in the target map.
The default local parallelism for this sink is 1.
The given functions must be stateless and cooperative.
Copyright © 2023 Hazelcast, Inc.. All rights reserved.