use of tasks.TimeInstanceAwareCallable in project microservices by pwillhan.
the class ExecutionInstanceAwareExample method main.
public static void main(String[] args) throws Exception {
Config conf = new Config();
HazelcastInstance hz = Hazelcast.newHazelcastInstance(conf);
ExecutorService exec = hz.getExecutorService("exec");
while (true) {
Future<String> timeFuture = exec.submit(new TimeInstanceAwareCallable());
String theTime = timeFuture.get();
System.err.println("The time is: " + theTime);
Thread.sleep(1000);
}
}
use of tasks.TimeInstanceAwareCallable in project microservices by pwillhan.
the class ExecutionOnMemberExample method main.
public static void main(String[] args) throws Exception {
Config conf = new Config();
HazelcastInstance hz = Hazelcast.newHazelcastInstance(conf);
Member thisMember = hz.getCluster().getLocalMember();
IExecutorService exec = hz.getExecutorService("exec");
Callable<String> timeTask = new TimeInstanceAwareCallable();
Member member = thisMember;
Future<String> specificTask = exec.submitToMember(timeTask, member);
String timeFromSpecificMember = specificTask.get(10, TimeUnit.SECONDS);
System.err.println(timeFromSpecificMember);
}
use of tasks.TimeInstanceAwareCallable in project microservices by pwillhan.
the class MultiExecutionExample method main.
public static void main(String[] args) throws Exception {
Config conf = new Config();
HazelcastInstance hz = Hazelcast.newHazelcastInstance(conf);
IExecutorService exec = hz.getExecutorService("exec");
Callable<String> timeTask = new TimeInstanceAwareCallable();
MultiExecutionCallback callback = new MultiExecutionCallback() {
@Override
public void onResponse(Member member, Object theTime) {
System.err.println("Received: " + theTime);
}
@Override
public void onComplete(Map<Member, Object> theTimes) {
for (Object theTime : theTimes.values()) {
System.err.println("Complete: " + theTime);
}
}
};
while (true) {
Set<Member> clusterMembers = hz.getCluster().getMembers();
exec.submitToMembers(timeTask, clusterMembers, callback);
Thread.sleep(1000);
}
}
Aggregations