use of com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation in project hazelcast by hazelcast.
the class ScheduledExecutorSubmitToAddressMessageTask method prepareOperation.
@Override
protected Operation prepareOperation() {
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 ScheduleTaskOperation(parameters.schedulerName, def);
}
use of com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation in project hazelcast by hazelcast.
the class ScheduledExecutorSubmitToPartitionMessageTask method prepareOperation.
@Override
protected Operation prepareOperation() {
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 ScheduleTaskOperation(parameters.schedulerName, def);
}
use of com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation in project hazelcast by hazelcast.
the class ScheduledExecutorServiceProxy 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");
attachHazelcastInstance(command);
String name = extractNameOrGenerateOne(command);
int partitionId = getKeyPartitionId(key);
TaskDefinition definition = new TaskDefinition(TaskDefinition.Type.SINGLE_RUN, name, command, delay, 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 schedule.
@Override
public <V> IScheduledFuture<V> schedule(Callable<V> command, long delay, TimeUnit unit) {
checkNotNull(command, "Command is null");
checkNotNull(unit, "Unit is null");
attachHazelcastInstance(command);
String name = extractNameOrGenerateOne(command);
int partitionId = getTaskOrKeyPartitionId(command, name);
TaskDefinition<V> definition = new TaskDefinition<V>(TaskDefinition.Type.SINGLE_RUN, name, command, delay, 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 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");
attachHazelcastInstance(command);
String name = extractNameOrGenerateOne(command);
int partitionId = getKeyPartitionId(key);
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);
}
Aggregations