Search in sources :

Example 1 with ScheduleTaskOperation

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

Example 2 with ScheduleTaskOperation

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

Example 3 with ScheduleTaskOperation

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);
}
Also used : ScheduleTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation)

Example 4 with ScheduleTaskOperation

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);
}
Also used : ScheduleTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation)

Example 5 with ScheduleTaskOperation

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);
}
Also used : ScheduleTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation)

Aggregations

ScheduleTaskOperation (com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation)8 Member (com.hazelcast.core.Member)2 IScheduledFuture (com.hazelcast.scheduledexecutor.IScheduledFuture)2 TaskDefinition (com.hazelcast.scheduledexecutor.impl.TaskDefinition)2 Callable (java.util.concurrent.Callable)2 HashMapAdapter (com.hazelcast.mapreduce.impl.HashMapAdapter)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1