use of com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation in project hazelcast by hazelcast.
the class ScheduledExecutorServiceProxy method scheduleAtFixedRate.
@Override
public IScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
checkNotNull(command, "Command is null");
checkNotNull(unit, "Unit is null");
attachHazelcastInstance(command);
String name = extractNameOrGenerateOne(command);
int partitionId = getTaskOrKeyPartitionId(command, name);
ScheduledRunnableAdapter<?> adapter = createScheduledRunnableAdapter(command);
TaskDefinition definition = new TaskDefinition(TaskDefinition.Type.AT_FIXED_RATE, name, adapter, initialDelay, period, unit);
return submitOnPartitionSync(name, new ScheduleTaskOperation(getName(), definition), partitionId);
}
use of com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation in project hazelcast by hazelcast.
the class ScheduledExecutorServiceProxy method scheduleOnMembersAtFixedRate.
@Override
public Map<Member, IScheduledFuture<?>> scheduleOnMembersAtFixedRate(Runnable command, Collection<Member> members, long initialDelay, long period, TimeUnit unit) {
checkNotNull(command, "Command is null");
checkNotNull(members, "Members is null");
checkNotNull(unit, "Unit is null");
attachHazelcastInstance(command);
String name = extractNameOrGenerateOne(command);
ScheduledRunnableAdapter<?> adapter = createScheduledRunnableAdapter(command);
Map<Member, IScheduledFuture<?>> futures = new HashMapAdapter<Member, IScheduledFuture<?>>();
for (Member member : members) {
TaskDefinition definition = new TaskDefinition(TaskDefinition.Type.AT_FIXED_RATE, name, adapter, initialDelay, period, unit);
futures.put(member, submitOnMemberSync(name, new ScheduleTaskOperation(getName(), definition), member));
}
return futures;
}
use of com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation 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;
}
Aggregations