use of com.hazelcast.mapreduce.JobTracker in project hazelcast by hazelcast.
the class ClientMapProxy method aggregate.
@Override
public <SuppliedValue, Result> Result aggregate(Supplier<K, V, SuppliedValue> supplier, Aggregation<K, SuppliedValue, Result> aggregation) {
HazelcastInstance hazelcastInstance = getContext().getHazelcastInstance();
JobTracker jobTracker = hazelcastInstance.getJobTracker("hz::aggregation-map-" + name);
return aggregate(supplier, aggregation, jobTracker);
}
use of com.hazelcast.mapreduce.JobTracker in project hazelcast by hazelcast.
the class ClientMultiMapProxy method aggregate.
@Override
public <SuppliedValue, Result> Result aggregate(Supplier<K, V, SuppliedValue> supplier, Aggregation<K, SuppliedValue, Result> aggregation) {
HazelcastInstance hazelcastInstance = getContext().getHazelcastInstance();
JobTracker jobTracker = hazelcastInstance.getJobTracker("hz::aggregation-multimap-" + name);
return aggregate(supplier, aggregation, jobTracker);
}
use of com.hazelcast.mapreduce.JobTracker in project hazelcast by hazelcast.
the class ClientListSetMapReduceTest method testMapReduceWithSet.
@Test(timeout = 60000)
public void testMapReduceWithSet() throws Exception {
Config config = buildConfig();
HazelcastInstance h1 = hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance h2 = hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance h3 = hazelcastFactory.newHazelcastInstance(config);
assertClusterSizeEventually(3, h1);
assertClusterSizeEventually(3, h2);
assertClusterSizeEventually(3, h3);
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
int expectedResult = 0;
ISet<Integer> set = h1.getSet("default");
for (int o = 0; o < 100; o++) {
set.add(o);
expectedResult += o;
}
JobTracker jobTracker = client.getJobTracker("default");
Job<String, Integer> job = jobTracker.newJob(KeyValueSource.fromSet(set));
ICompletableFuture<Map<String, Integer>> ICompletableFuture = job.chunkSize(10).mapper(new ListSetMapReduceTest.ListSetMapper()).combiner(new ListSetMapReduceTest.ListSetCombinerFactory()).reducer(new ListSetMapReduceTest.ListSetReducerFactory()).submit();
Map<String, Integer> result = ICompletableFuture.get();
assertEquals(1, result.size());
for (Map.Entry<String, Integer> entry : result.entrySet()) {
assertEquals(set.getName(), entry.getKey());
assertEquals(expectedResult, (int) entry.getValue());
}
}
use of com.hazelcast.mapreduce.JobTracker in project hazelcast by hazelcast.
the class ClientListSetMapReduceTest method testMapReduceWithList.
@Test(timeout = 60000)
public void testMapReduceWithList() throws Exception {
Config config = buildConfig();
HazelcastInstance h1 = hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance h2 = hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance h3 = hazelcastFactory.newHazelcastInstance(config);
assertClusterSizeEventually(3, h1);
assertClusterSizeEventually(3, h2);
assertClusterSizeEventually(3, h3);
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
int expectedResult = 0;
IList<Integer> list = h1.getList("default");
for (int o = 0; o < 100; o++) {
list.add(o);
expectedResult += o;
}
JobTracker jobTracker = client.getJobTracker("default");
Job<String, Integer> job = jobTracker.newJob(KeyValueSource.fromList(list));
ICompletableFuture<Map<String, Integer>> ICompletableFuture = job.chunkSize(10).mapper(new ListSetMapReduceTest.ListSetMapper()).combiner(new ListSetMapReduceTest.ListSetCombinerFactory()).reducer(new ListSetMapReduceTest.ListSetReducerFactory()).submit();
Map<String, Integer> result = ICompletableFuture.get();
assertEquals(1, result.size());
int count = 0;
for (Map.Entry<String, Integer> entry : result.entrySet()) {
assertEquals(list.getName(), entry.getKey());
assertEquals(expectedResult, (int) entry.getValue());
}
}
use of com.hazelcast.mapreduce.JobTracker in project hazelcast by hazelcast.
the class ClientMapReduceTest method testAsyncMapper.
@Test(timeout = 120000)
public void testAsyncMapper() throws Exception {
Config config = buildConfig();
HazelcastInstance h1 = hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance h2 = hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance h3 = hazelcastFactory.newHazelcastInstance(config);
assertClusterSizeEventually(3, h1);
assertClusterSizeEventually(3, h2);
assertClusterSizeEventually(3, h3);
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
IMap<Integer, Integer> m1 = client.getMap(randomString());
for (int i = 0; i < 100; i++) {
m1.put(i, i);
}
final Map<String, List<Integer>> listenerResults = new HashMap<String, List<Integer>>();
final Semaphore semaphore = new Semaphore(1);
semaphore.acquire();
JobTracker tracker = client.getJobTracker("default");
Job<Integer, Integer> job = tracker.newJob(integerKvSource(m1));
ICompletableFuture<Map<String, List<Integer>>> future = job.mapper(new TestMapper()).submit();
future.andThen(new ExecutionCallback<Map<String, List<Integer>>>() {
@Override
public void onResponse(Map<String, List<Integer>> response) {
listenerResults.putAll(response);
semaphore.release();
}
@Override
public void onFailure(Throwable t) {
semaphore.release();
}
});
semaphore.acquire();
assertEquals(100, listenerResults.size());
for (List<Integer> value : listenerResults.values()) {
assertEquals(1, value.size());
}
}
Aggregations