Search in sources :

Example 6 with TaskDefinition

use of com.hazelcast.scheduledexecutor.impl.TaskDefinition in project hazelcast by hazelcast.

the class ClientScheduledExecutorProxy method scheduleAtFixedRate.

@Override
public IScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
    checkNotNull(command, "Command is null");
    checkNotNull(unit, "Unit is null");
    String name = extractNameOrGenerateOne(command);
    int partitionId = getTaskOrKeyPartitionId(command, name);
    Callable adapter = createScheduledRunnableAdapter(command);
    TaskDefinition definition = new TaskDefinition(TaskDefinition.Type.AT_FIXED_RATE, name, adapter, initialDelay, period, unit);
    return scheduleOnPartition(name, definition, partitionId);
}
Also used : TaskDefinition(com.hazelcast.scheduledexecutor.impl.TaskDefinition) Callable(java.util.concurrent.Callable)

Example 7 with TaskDefinition

use of com.hazelcast.scheduledexecutor.impl.TaskDefinition in project hazelcast by hazelcast.

the class ScheduledExecutorSubmitToAddressMessageTask 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, parameters.address, def };
}
Also used : TaskDefinition(com.hazelcast.scheduledexecutor.impl.TaskDefinition) Callable(java.util.concurrent.Callable)

Example 8 with TaskDefinition

use of com.hazelcast.scheduledexecutor.impl.TaskDefinition 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);
}
Also used : TaskDefinition(com.hazelcast.scheduledexecutor.impl.TaskDefinition) ScheduleTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation) Callable(java.util.concurrent.Callable)

Example 9 with TaskDefinition

use of com.hazelcast.scheduledexecutor.impl.TaskDefinition 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);
}
Also used : TaskDefinition(com.hazelcast.scheduledexecutor.impl.TaskDefinition) ScheduleTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation) Callable(java.util.concurrent.Callable)

Aggregations

TaskDefinition (com.hazelcast.scheduledexecutor.impl.TaskDefinition)9 Callable (java.util.concurrent.Callable)7 Member (com.hazelcast.core.Member)2 IScheduledFuture (com.hazelcast.scheduledexecutor.IScheduledFuture)2 ScheduleTaskOperation (com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation)2 HashMap (java.util.HashMap)2