Hazelcast Distributed Executor Service KeyOwner
Posted
by
János Veres
on Stack Overflow
See other posts from Stack Overflow
or by János Veres
Published on 2013-10-29T21:51:24Z
Indexed on
2013/10/29
21:53 UTC
Read the original article
Hit count: 342
I have problem understanding the concept of Hazelcast Distributed Execution. It is said to be able to perform the execution on the owner instance of a specific key.
From Documentation:
<T> Future<T> submitToKeyOwner(Callable<T> task, Object key)
Submits task to owner of the specified key and returns a Future representing that task.
Parameters:
task - task
key - key
Returns:
a Future representing pending completion of the task
I believe that I'm not alone to have a cluster built with multiple maps which might actually use the same key for different purposes, holding different objects (e.g. something along the following setup):
IMap<String, ObjectTypeA> firstMap = HazelcastInstance.getMap("firstMap");
IMap<String, ObjectTypeA_AppendixClass> secondMap = HazelcastInstance.getMap("secondMap");
To me it seems quite confusing what documentation says about the owner of a key. My real frustration is that I don't know WHICH - in which map - key does it refer to?
The documentation also gives a "demo" of this approach:
import com.hazelcast.core.Member;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.IExecutorService;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.Set;
import com.hazelcast.config.Config;
public void echoOnTheMemberOwningTheKey(String input, Object key) throws Exception {
Callable<String> task = new Echo(input);
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
IExecutorService executorService = hz.getExecutorService("default");
Future<String> future = executorService.submitToKeyOwner(task, key);
String echoResult = future.get();
}
Here's a link to the documentation site: Hazelcast MultiHTML Documentation 3.0 - Distributed Execution
Did any of you guys figure out in the past what key does it want?
© Stack Overflow or respective owner