use of com.hazelcast.connector.map.AsyncMap in project hazelcast by hazelcast.
the class Hz3EnrichmentTest method testMapUsingIMap.
@Test
public void testMapUsingIMap() {
IMap<Object, Object> map = hz3.getMap("test-map");
map.put(1, "a");
map.put(2, "b");
HazelcastInstance hz = createHazelcastInstance();
IList<String> results = hz.getList("result-list");
Pipeline p = Pipeline.create();
ServiceFactory<Hz3MapAdapter, AsyncMap<Integer, String>> hz3MapSF = hz3MapServiceFactory("test-map", HZ3_CLIENT_CONFIG);
BiFunctionEx<? super Map<Integer, String>, ? super Integer, String> mapFn = mapUsingIMap(FunctionEx.identity(), (Integer i, String s) -> s);
BatchStage<String> mapStage = p.readFrom(TestSources.items(1, 2, 3)).mapUsingService(hz3MapSF, mapFn);
mapStage.writeTo(Sinks.list(results));
JobConfig config = getJobConfig(mapStage.name());
hz.getJet().newJob(p, config).join();
assertThat(results).containsOnly("a", "b");
}
use of com.hazelcast.connector.map.AsyncMap in project hazelcast by hazelcast.
the class Hz3EnrichmentTest method testMapUsingIMapAsync.
@Test
public void testMapUsingIMapAsync() {
IMap<Object, Object> map = hz3.getMap("test-map");
map.put(1, "a");
map.put(2, "b");
HazelcastInstance hz = createHazelcastInstance();
IList<String> results = hz.getList("result-list");
Pipeline p = Pipeline.create();
ServiceFactory<Hz3MapAdapter, AsyncMap<Integer, String>> hz3MapSF = hz3MapServiceFactory("test-map", HZ3_CLIENT_CONFIG);
BiFunctionEx<? super AsyncMap<Integer, String>, ? super Integer, CompletableFuture<String>> mapFn = mapUsingIMapAsync(FunctionEx.identity(), (Integer i, String s) -> s);
BatchStage<String> mapStage = p.readFrom(TestSources.items(1, 2, 3)).mapUsingServiceAsync(hz3MapSF, mapFn);
mapStage.writeTo(Sinks.list(results));
JobConfig config = getJobConfig(mapStage.name());
hz.getJet().newJob(p, config).join();
assertThat(results).containsOnly("a", "b");
}
use of com.hazelcast.connector.map.AsyncMap in project hazelcast by hazelcast.
the class Hz3EnrichmentTest method when_enrichFromInstanceDown_then_shouldThrowJetException.
@Test
public void when_enrichFromInstanceDown_then_shouldThrowJetException() {
HazelcastInstance hz = createHazelcastInstance();
IList<String> results = hz.getList("result-list");
Pipeline p = Pipeline.create();
ServiceFactory<Hz3MapAdapter, AsyncMap<Integer, String>> hz3MapSF = hz3MapServiceFactory("test-map", HZ3_DOWN_CLIENT_CONFIG);
BiFunctionEx<? super Map<Integer, String>, ? super Integer, String> mapFn = mapUsingIMap(FunctionEx.identity(), (Integer i, String s) -> s);
BatchStage<String> mapStage = p.readFrom(TestSources.items(1, 2, 3)).mapUsingService(hz3MapSF, mapFn);
mapStage.writeTo(Sinks.list(results));
JobConfig config = getJobConfig(mapStage.name());
Job job = hz.getJet().newJob(p, config);
assertThatThrownBy(() -> job.join()).hasStackTraceContaining(JetException.class.getName()).hasStackTraceContaining("Unable to connect to any cluster");
}
Aggregations