Search in sources :

Example 6 with IScheduledFuture

use of com.hazelcast.scheduledexecutor.IScheduledFuture in project hazelcast by hazelcast.

the class ScheduledExecutorServiceProxy method scheduleOnMembers.

@Override
public <V> Map<Member, IScheduledFuture<V>> scheduleOnMembers(Callable<V> command, Collection<Member> members, long delay, TimeUnit unit) {
    checkNotNull(command, "Command is null");
    checkNotNull(members, "Members is null");
    checkNotNull(unit, "Unit is null");
    attachHazelcastInstance(command);
    String name = extractNameOrGenerateOne(command);
    Map<Member, IScheduledFuture<V>> futures = new HashMap<Member, IScheduledFuture<V>>();
    for (Member member : members) {
        TaskDefinition<V> definition = new TaskDefinition<V>(TaskDefinition.Type.SINGLE_RUN, name, command, delay, unit);
        futures.put(member, (IScheduledFuture<V>) submitOnMemberSync(name, new ScheduleTaskOperation(getName(), definition), member));
    }
    return futures;
}
Also used : IScheduledFuture(com.hazelcast.scheduledexecutor.IScheduledFuture) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ScheduleTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation) Member(com.hazelcast.core.Member)

Aggregations

Member (com.hazelcast.core.Member)6 IScheduledFuture (com.hazelcast.scheduledexecutor.IScheduledFuture)6 HashMap (java.util.HashMap)5 ScheduledTaskHandler (com.hazelcast.scheduledexecutor.ScheduledTaskHandler)2 TaskDefinition (com.hazelcast.scheduledexecutor.impl.TaskDefinition)2 ScheduleTaskOperation (com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Map (java.util.Map)2 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)1 ClientInvocationFuture (com.hazelcast.client.spi.impl.ClientInvocationFuture)1 ClusterService (com.hazelcast.internal.cluster.ClusterService)1 HashMapAdapter (com.hazelcast.mapreduce.impl.HashMapAdapter)1 AbstractDistributedObject (com.hazelcast.spi.AbstractDistributedObject)1 IPartitionService (com.hazelcast.spi.partition.IPartitionService)1 Callable (java.util.concurrent.Callable)1