use of com.hazelcast.console.Echo in project hazelcast by hazelcast.
the class ClientConsoleApp method executeOnMembers.
private void executeOnMembers(String[] args) {
// executeOnMembers <echo-string>
try {
IExecutorService executorService = hazelcast.getExecutorService("default");
Echo task = new Echo(args[1]);
Map<Member, Future<String>> results = executorService.submitToAllMembers(task);
for (Future f : results.values()) {
println(f.get());
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
use of com.hazelcast.console.Echo in project hazelcast by hazelcast.
the class ClientConsoleApp method doExecute.
private void doExecute(boolean onKey, boolean onMember, String[] args) {
// executeOnKey <echo-string> <key>
try {
IExecutorService executorService = hazelcast.getExecutorService("default");
Echo callable = new Echo(args[1]);
Future<String> future;
if (onKey) {
String key = args[2];
future = executorService.submitToKeyOwner(callable, key);
} else if (onMember) {
int memberIndex = Integer.parseInt(args[2]);
List<Member> members = new LinkedList(hazelcast.getCluster().getMembers());
if (memberIndex >= members.size()) {
throw new IndexOutOfBoundsException("Member index: " + memberIndex + " must be smaller than " + members.size());
}
Member member = members.get(memberIndex);
future = executorService.submitToMember(callable, member);
} else {
future = executorService.submit(callable);
}
println("Result: " + future.get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
Aggregations