@Beta public final class Hz3Enrichment extends Object
The usage is similar to
GeneralStage.mapUsingIMap(String, FunctionEx, BiFunctionEx)
and
other similarly named methods. The difference is that instead of providing
a name of the map, a ServiceFactory
to Hazelcast 3 Map is used.
This class provides utility methods to create and use this service factory.
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:
First you need to obtain a ServiceFactory for a Hazelcast 3 Map/ReplicatedMap:
ServiceFactory<Hz3MapAdapter, AsyncMap<Integer, String>> hz3MapSF =
hz3MapServiceFactory("test-map", HZ3_CLIENT_CONFIG);
Then use this service factory in a pipeline step
GeneralStage.mapUsingService(ServiceFactory, BiFunctionEx)
:
BatchStage<String> mapStage = p.readFrom(TestSources.items(1, 2, 3))
.mapUsingService(
hz3MapSF,
mapUsingIMap(FunctionEx.identity(), (Integer i, String s) -> s)
);
mapStage.writeTo(Sinks.list(results));
And finally, a custom classpath element for the mapUsingService
stage must be set with the Hazelcast 3 client:
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");
config.addCustomClasspaths(mapStage.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 <K,V> ServiceFactory<Hz3MapAdapter,AsyncMap<K,V>> |
hz3MapServiceFactory(String mapName,
String clientXML)
Create a service factory for enrichment using Hazelcast 3 remote map.
|
static <K,V> ServiceFactory<Hz3MapAdapter,Map<K,V>> |
hz3ReplicatedMapServiceFactory(String mapName,
String clientXML)
Create a service factory for enrichment using Hazelcast 3 remote replicated map.
|
static <K,V,T,R> BiFunctionEx<? super Map<K,V>,? super T,R> |
mapUsingIMap(FunctionEx<? super T,? extends K> lookupKeyFn,
BiFunctionEx<? super T,? super V,? extends R> mapFn)
Helper function to convert simple lookupKeyFn and mapFn to mapAsyncFn required by
GeneralStage.mapUsingServiceAsync(ServiceFactory, BiFunctionEx) |
static <K,V,T,R> BiFunctionEx<? super AsyncMap<K,V>,? super T,CompletableFuture<R>> |
mapUsingIMapAsync(FunctionEx<? super T,? extends K> lookupKeyFn,
BiFunctionEx<? super T,? super V,? extends R> mapFn)
Helper function to convert simple lookupKeyFn and mapFn to mapAsyncFn required by
GeneralStage.mapUsingServiceAsync(ServiceFactory, BiFunctionEx) |
@Beta public static <K,V> ServiceFactory<Hz3MapAdapter,AsyncMap<K,V>> hz3MapServiceFactory(String mapName, String clientXML)
See the class javadoc for usage.
@Beta public static <K,V> ServiceFactory<Hz3MapAdapter,Map<K,V>> hz3ReplicatedMapServiceFactory(String mapName, String clientXML)
See the class javadoc for usage.
@Beta public static <K,V,T,R> BiFunctionEx<? super AsyncMap<K,V>,? super T,CompletableFuture<R>> mapUsingIMapAsync(@Nonnull FunctionEx<? super T,? extends K> lookupKeyFn, @Nonnull BiFunctionEx<? super T,? super V,? extends R> mapFn)
GeneralStage.mapUsingServiceAsync(ServiceFactory, BiFunctionEx)
See the class javadoc for usage.
@Beta public static <K,V,T,R> BiFunctionEx<? super Map<K,V>,? super T,R> mapUsingIMap(@Nonnull FunctionEx<? super T,? extends K> lookupKeyFn, @Nonnull BiFunctionEx<? super T,? super V,? extends R> mapFn)
GeneralStage.mapUsingServiceAsync(ServiceFactory, BiFunctionEx)
See the class javadoc for usage.
Copyright © 2023 Hazelcast, Inc.. All rights reserved.