use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.
the class ClientScheduledExecutorProxy method getAllScheduledFutures.
@Override
public <V> Map<Member, List<IScheduledFuture<V>>> getAllScheduledFutures() {
ClientMessage request = ScheduledExecutorGetAllScheduledFuturesCodec.encodeRequest(getName());
final ClientInvocationFuture future = new ClientInvocation(getClient(), request).invoke();
ClientMessage response;
try {
response = future.get();
} catch (Exception e) {
throw rethrow(e);
}
Collection<Map.Entry<Member, List<ScheduledTaskHandler>>> urnsPerMember = ScheduledExecutorGetAllScheduledFuturesCodec.decodeResponse(response).handlers;
Map<Member, List<IScheduledFuture<V>>> tasksMap = new HashMap<Member, List<IScheduledFuture<V>>>();
for (Map.Entry<Member, List<ScheduledTaskHandler>> entry : urnsPerMember) {
List<IScheduledFuture<V>> memberTasks = new ArrayList<IScheduledFuture<V>>();
for (ScheduledTaskHandler scheduledTaskHandler : entry.getValue()) {
memberTasks.add(new ClientScheduledFutureProxy(scheduledTaskHandler, getContext()));
}
tasksMap.put(entry.getKey(), memberTasks);
}
return tasksMap;
}
use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.
the class ScheduledExecutorGetAllScheduledMessageTask method accumulateTaskHandlersAsUrnValues.
@SuppressWarnings("unchecked")
private void accumulateTaskHandlersAsUrnValues(Map<Member, List<ScheduledTaskHandler>> accumulator, Map<?, ?> taskHandlersMap) {
ClusterService clusterService = nodeEngine.getClusterService();
IPartitionService partitionService = nodeEngine.getPartitionService();
for (Map.Entry<?, ?> entry : taskHandlersMap.entrySet()) {
Member owner;
Object key = entry.getKey();
if (key instanceof Number) {
owner = clusterService.getMember(partitionService.getPartitionOwner((Integer) key));
} else {
owner = (Member) key;
}
List<ScheduledTaskHandler> handlers = (List<ScheduledTaskHandler>) entry.getValue();
if (accumulator.containsKey(owner)) {
List<ScheduledTaskHandler> memberUrns = accumulator.get(owner);
memberUrns.addAll(handlers);
} else {
accumulator.put(owner, handlers);
}
}
}
use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.
the class ScheduledExecutorWaitNotifyKeyTest method equals_fail_withDiffDistObject.
@Test
public void equals_fail_withDiffDistObject() throws Exception {
ScheduledTaskHandler handlerA = ScheduledTaskHandlerImpl.of(1, "MyScheduler", "MyTask");
String myTaskURN = handlerA.toUrn();
ScheduledTaskHandler handlerB = ScheduledTaskHandlerImpl.of(1, "MyScheduler", "MyTask2");
String myTask2URN = handlerB.toUrn();
ScheduledExecutorWaitNotifyKey keyA = new ScheduledExecutorWaitNotifyKey("myScheduler", myTaskURN);
ScheduledExecutorWaitNotifyKey keyB = new ScheduledExecutorWaitNotifyKey("myWrongScheduler", myTask2URN);
assertFalse(keyA.equals(keyB));
}
use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.
the class ScheduledExecutorWaitNotifyKeyTest method hashcode_fail_withDiffURN.
@Test
public void hashcode_fail_withDiffURN() throws Exception {
ScheduledTaskHandler handlerA = ScheduledTaskHandlerImpl.of(1, "MyScheduler", "MyTask");
String myTaskURN = handlerA.toUrn();
ScheduledTaskHandler handlerB = ScheduledTaskHandlerImpl.of(1, "MyScheduler", "MyTask2");
String myTask2URN = handlerB.toUrn();
ScheduledExecutorWaitNotifyKey keyA = new ScheduledExecutorWaitNotifyKey("myScheduler", myTaskURN);
ScheduledExecutorWaitNotifyKey keyB = new ScheduledExecutorWaitNotifyKey("myScheduler", myTask2URN);
assertNotEquals(keyA.hashCode(), keyB.hashCode());
}
use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.
the class ScheduledExecutorWaitNotifyKeyTest method equals_fail_withDiffURN.
@Test
public void equals_fail_withDiffURN() throws Exception {
ScheduledTaskHandler handlerA = ScheduledTaskHandlerImpl.of(1, "MyScheduler", "MyTask");
String myTaskURN = handlerA.toUrn();
ScheduledTaskHandler handlerB = ScheduledTaskHandlerImpl.of(1, "MyScheduler", "MyTask2");
String myTask2URN = handlerB.toUrn();
ScheduledExecutorWaitNotifyKey keyA = new ScheduledExecutorWaitNotifyKey("myScheduler", myTaskURN);
ScheduledExecutorWaitNotifyKey keyB = new ScheduledExecutorWaitNotifyKey("myScheduler", myTask2URN);
assertFalse(keyA.equals(keyB));
}
Aggregations