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 ScheduledExecutorServiceProxy method accumulateTaskHandlersAsScheduledFutures.
@SuppressWarnings("unchecked")
private <V> void accumulateTaskHandlersAsScheduledFutures(Map<Member, List<IScheduledFuture<V>>> accumulator, Map<?, ?> taskHandlersMap) {
ClusterService clusterService = getNodeEngine().getClusterService();
IPartitionService partitionService = getNodeEngine().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();
List<IScheduledFuture<V>> futures = new ArrayList<IScheduledFuture<V>>();
for (ScheduledTaskHandler handler : handlers) {
IScheduledFuture future = new ScheduledFutureProxy(handler);
attachHazelcastInstance(future);
futures.add(future);
}
if (accumulator.containsKey(owner)) {
List<IScheduledFuture<V>> memberFutures = accumulator.get(owner);
memberFutures.addAll(futures);
} else {
accumulator.put(owner, futures);
}
}
}
use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.
the class ScheduledTaskHandlerImpl method readData.
@Override
public void readData(ObjectDataInput in) throws IOException {
ScheduledTaskHandler handler = of(in.readUTF());
this.address = handler.getAddress();
this.partitionId = handler.getPartitionId();
this.schedulerName = handler.getSchedulerName();
this.taskName = handler.getTaskName();
}
use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.
the class GetAllScheduledOnMemberOperation method run.
@Override
public void run() throws Exception {
List<ScheduledTaskHandler> handlers = new ArrayList<ScheduledTaskHandler>();
DistributedScheduledExecutorService service = getService();
populateScheduledForHolder(handlers, service, MEMBER_BIN);
response = handlers;
}
use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.
the class GetAllScheduledOnPartitionOperation method run.
@Override
public void run() throws Exception {
List<ScheduledTaskHandler> handlers = new ArrayList<ScheduledTaskHandler>();
DistributedScheduledExecutorService service = getService();
populateScheduledForHolder(handlers, service, getPartitionId());
response = handlers;
}
Aggregations