Giriş
Şu satırı dahil ederiz
import com.hazelcast.core.IExecutorService;
Şunlar kullanılabilir. Çok karışık bir metodlar çorbası var. Bazı metodlar ExecutionCallback alıyor bazıları, MemberSelector alıyor, çoğu void dönüyor, bazıları Future dönüyor.
void executevoid execute //MemberSelector : random member void executeOnKeyOwner //Object void executeOnMember //Member void executeOnMembers //Collection<Member> void executeOnAllMembers void submit //ExecutionCallback : random member void submit //MemberSelector + ExecutionCallback : random members void submitToMembers //MemberSelector + ExecutionCallback void submitToKeyOwner //Object + ExecutionCallback void submitToMember //Member + ExecutionCallback void submitToMembers //Collection<Member> + MultiExecutionCallback void submitToAllMembers //MultiExecutionCallback Future<?> submit Future<T> submit
executeOnKeyOwner metodu
Şöyle yaparız
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(); Map mapA = hazelcastInstance.getMap("mapA"); Map mapB = hazelcastInstance.getMap("mapB"); Map mapC = hazelcastInstance.getMap("mapC"); // since map names are different, operation will be manipulating // different entries, but the operation will take place on the // same member since the keys ("key1") are the same mapA.put("key1", value); mapB.get("key1"); mapC.remove("key1"); // lock operation will still execute on the same member // of the cluster since the key ("key1") is same hazelcastInstance.getLock("key1").lock(); // distributed execution will execute the 'runnable' on the // same member since "key1" is passed as the key. hazelcastInstance.getExecutorService().executeOnKeyOwner(runnable, "key1");
Hiç yorum yok:
Yorum Gönder