Skip to content

Instantly share code, notes, and snippets.

@enesakar
Created May 16, 2015 20:52
Show Gist options
  • Select an option

  • Save enesakar/0d359782695f182be20f to your computer and use it in GitHub Desktop.

Select an option

Save enesakar/0d359782695f182be20f to your computer and use it in GitHub Desktop.
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