Search in sources :

Example 1 with JobTracker

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) JobTracker(com.hazelcast.mapreduce.JobTracker)

Example 2 with 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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) JobTracker(com.hazelcast.mapreduce.JobTracker)

Example 3 with 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());
    }
}
Also used : Config(com.hazelcast.config.Config) JobTracker(com.hazelcast.mapreduce.JobTracker) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ListSetMapReduceTest(com.hazelcast.mapreduce.ListSetMapReduceTest) Map(java.util.Map) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest) ListSetMapReduceTest(com.hazelcast.mapreduce.ListSetMapReduceTest)

Example 4 with JobTracker

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());
    }
}
Also used : Config(com.hazelcast.config.Config) JobTracker(com.hazelcast.mapreduce.JobTracker) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ListSetMapReduceTest(com.hazelcast.mapreduce.ListSetMapReduceTest) Map(java.util.Map) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest) ListSetMapReduceTest(com.hazelcast.mapreduce.ListSetMapReduceTest)

Example 5 with JobTracker

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());
    }
}
Also used : HashMap(java.util.HashMap) Config(com.hazelcast.config.Config) JobTracker(com.hazelcast.mapreduce.JobTracker) Semaphore(java.util.concurrent.Semaphore) HazelcastInstance(com.hazelcast.core.HazelcastInstance) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) IMap(com.hazelcast.core.IMap) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

HazelcastInstance (com.hazelcast.core.HazelcastInstance)41 JobTracker (com.hazelcast.mapreduce.JobTracker)41 Test (org.junit.Test)37 Config (com.hazelcast.config.Config)36 SlowTest (com.hazelcast.test.annotation.SlowTest)26 Map (java.util.Map)20 HashMap (java.util.HashMap)18 Semaphore (java.util.concurrent.Semaphore)14 List (java.util.List)10 IMap (com.hazelcast.core.IMap)9 MultiMap (com.hazelcast.core.MultiMap)9 NightlyTest (com.hazelcast.test.annotation.NightlyTest)8 CancellationException (java.util.concurrent.CancellationException)4 ExecutionException (java.util.concurrent.ExecutionException)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 ListSetMapReduceTest (com.hazelcast.mapreduce.ListSetMapReduceTest)2