Created
May 16, 2015 20:52
-
-
Save enesakar/0d359782695f182be20f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void main(String[] args) throws InterruptedException, ExecutionException { | |
| final HazelcastInstance hz = Hazelcast.newHazelcastInstance(new Config("instance1")); | |
| final HazelcastInstance hz2 = Hazelcast.newHazelcastInstance(new Config("instance2")); | |
| IExecutorService collector = hz.getExecutorService("nameCollector"); | |
| Map<Member, Future<String>> map = collector.submitToAllMembers(new GetInstanceNameCallable()); | |
| for (Future<String> future : map.values()) { | |
| System.out.println(future.get()); | |
| } | |
| } | |
| static class GetInstanceNameCallable implements HazelcastInstanceAware, Callable<String>, Serializable { | |
| HazelcastInstance instance; | |
| @Override | |
| public String call() throws Exception { | |
| return instance.getName(); | |
| } | |
| @Override | |
| public void setHazelcastInstance(HazelcastInstance hazelcastInstance) { | |
| this.instance = hazelcastInstance; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment