use of com.hazelcast.scheduledexecutor.impl.TaskDefinition in project hazelcast by hazelcast.
the class ClientScheduledExecutorProxy method scheduleOnKeyOwnerAtFixedRate.
@Override
public IScheduledFuture<?> scheduleOnKeyOwnerAtFixedRate(Runnable command, Object key, long initialDelay, long period, TimeUnit unit) {
checkNotNull(command, "Command is null");
checkNotNull(key, "Key is null");
checkNotNull(unit, "Unit is null");
String name = extractNameOrGenerateOne(command);
int partitionId = getKeyPartitionId(key);
Callable adapter = createScheduledRunnableAdapter(command);
TaskDefinition definition = new TaskDefinition(TaskDefinition.Type.AT_FIXED_RATE, name, adapter, initialDelay, period, unit);
return scheduleOnPartition(name, definition, partitionId);
}
use of com.hazelcast.scheduledexecutor.impl.TaskDefinition in project hazelcast by hazelcast.
the class ClientScheduledExecutorProxy 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");
String name = extractNameOrGenerateOne(command);
Map<Member, IScheduledFuture<V>> futures = new HashMap<Member, IScheduledFuture<V>>();
for (Member member : members) {
TaskDefinition definition = new TaskDefinition(TaskDefinition.Type.SINGLE_RUN, name, command, delay, unit);
futures.put(member, (IScheduledFuture<V>) scheduleOnMember(name, member, definition));
}
return futures;
}
use of com.hazelcast.scheduledexecutor.impl.TaskDefinition in project hazelcast by hazelcast.
the class ScheduledExecutorSubmitToPartitionMessageTask method getParameters.
@Override
public Object[] getParameters() {
Callable callable = serializationService.toObject(parameters.task);
TaskDefinition def = new TaskDefinition(TaskDefinition.Type.getById(parameters.type), parameters.taskName, callable, parameters.initialDelayInMillis, parameters.periodInMillis, TimeUnit.MILLISECONDS);
return new Object[] { parameters.schedulerName, def };
}
use of com.hazelcast.scheduledexecutor.impl.TaskDefinition in project hazelcast by hazelcast.
the class ClientScheduledExecutorProxy method scheduleOnKeyOwner.
@Override
public <V> IScheduledFuture<V> scheduleOnKeyOwner(Callable<V> command, Object key, long delay, TimeUnit unit) {
checkNotNull(command, "Command is null");
checkNotNull(key, "Key is null");
checkNotNull(unit, "Unit is null");
String name = extractNameOrGenerateOne(command);
int partitionId = getKeyPartitionId(key);
TaskDefinition definition = new TaskDefinition(TaskDefinition.Type.SINGLE_RUN, name, command, delay, unit);
return scheduleOnPartition(name, definition, partitionId);
}
use of com.hazelcast.scheduledexecutor.impl.TaskDefinition in project hazelcast by hazelcast.
the class ClientScheduledExecutorProxy 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");
String name = extractNameOrGenerateOne(command);
Callable adapter = createScheduledRunnableAdapter(command);
Map<Member, IScheduledFuture<?>> futures = new HashMap<Member, IScheduledFuture<?>>();
for (Member member : members) {
TaskDefinition definition = new TaskDefinition(TaskDefinition.Type.AT_FIXED_RATE, name, adapter, initialDelay, period, unit);
futures.put(member, scheduleOnMember(name, member, definition));
}
return futures;
}
Aggregations