Package com.hazelcast.durableexecutor
Interface DurableExecutorService
-
- All Superinterfaces:
DistributedObject
,java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
public interface DurableExecutorService extends java.util.concurrent.ExecutorService, DistributedObject
Durable implementation ofExecutorService
. DurableExecutor provides additional methods like executing tasks on a member who is owner of a specific key DurableExecutor also provides a way to retrieve the result of an execution with the given taskId.- See Also:
Supports split brain protection since 3.10 in cluster versions 3.10 and higher.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
disposeResult(long taskId)
Disposes the result with the given taskIdvoid
executeOnKeyOwner(java.lang.Runnable command, java.lang.Object key)
Executes a task on the owner of the specified key.<T> java.util.concurrent.Future<T>
retrieveAndDisposeResult(long taskId)
Retrieves and disposes the result with the given taskId<T> java.util.concurrent.Future<T>
retrieveResult(long taskId)
Retrieves the result with the given taskIdDurableExecutorServiceFuture<?>
submit(java.lang.Runnable task)
Submits a Runnable task for execution and returns a Future representing that task.<T> DurableExecutorServiceFuture<T>
submit(java.lang.Runnable task, T result)
Submits a Runnable task for execution and returns a Future representing that task.<T> DurableExecutorServiceFuture<T>
submit(java.util.concurrent.Callable<T> task)
Submits a value-returning task for execution and returns a Future representing the pending results of the task.DurableExecutorServiceFuture<?>
submitToKeyOwner(java.lang.Runnable task, java.lang.Object key)
Submits a task to the owner of the specified key and returns a Future representing that task.<T> DurableExecutorServiceFuture<T>
submitToKeyOwner(java.util.concurrent.Callable<T> task, java.lang.Object key)
Submits a task to the owner of the specified key and returns a Future representing that task.-
Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getDestroyContextForTenant, getName, getPartitionKey, getServiceName
-
-
-
-
Method Detail
-
submit
@Nonnull <T> DurableExecutorServiceFuture<T> submit(@Nonnull java.util.concurrent.Callable<T> task)
Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future'sget
method will return the task's result upon successful completion.If you would like to immediately block waiting for a task, you can use constructions of the form
result = exec.submit(aCallable).get();
Note: The
Executors
class includes a set of methods that can convert some other common closure-like objects, for example,PrivilegedAction
toCallable
form so they can be submitted.- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
- Type Parameters:
T
- the type of the task's result- Parameters:
task
- the task to submit- Returns:
- a Future representing pending completion of the task
- Throws:
java.util.concurrent.RejectedExecutionException
- if the task cannot be scheduled for executionjava.lang.NullPointerException
- if the task is null
-
submit
@Nonnull <T> DurableExecutorServiceFuture<T> submit(@Nonnull java.lang.Runnable task, T result)
Submits a Runnable task for execution and returns a Future representing that task. The Future'sget
method will return the given result upon successful completion.- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
- Type Parameters:
T
- the type of the result- Parameters:
task
- the task to submitresult
- the result to return- Returns:
- a Future representing pending completion of the task
- Throws:
java.util.concurrent.RejectedExecutionException
- if the task cannot be scheduled for executionjava.lang.NullPointerException
- if the task is null
-
submit
@Nonnull DurableExecutorServiceFuture<?> submit(@Nonnull java.lang.Runnable task)
Submits a Runnable task for execution and returns a Future representing that task. The Future'sget
method will returnnull
upon successful completion.- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
- Parameters:
task
- the task to submit- Returns:
- a Future representing pending completion of the task
- Throws:
java.util.concurrent.RejectedExecutionException
- if the task cannot be scheduled for executionjava.lang.NullPointerException
- if the task is null
-
retrieveResult
<T> java.util.concurrent.Future<T> retrieveResult(long taskId)
Retrieves the result with the given taskId- Type Parameters:
T
- the type of the task's result- Parameters:
taskId
- combination of partitionId and sequence- Returns:
- a Future representing pending completion of the task
-
disposeResult
void disposeResult(long taskId)
Disposes the result with the given taskId- Parameters:
taskId
- combination of partitionId and sequence
-
retrieveAndDisposeResult
<T> java.util.concurrent.Future<T> retrieveAndDisposeResult(long taskId)
Retrieves and disposes the result with the given taskId- Type Parameters:
T
- the type of the task's result- Parameters:
taskId
- combination of partitionId and sequence- Returns:
- a Future representing pending completion of the task
-
executeOnKeyOwner
void executeOnKeyOwner(@Nonnull java.lang.Runnable command, @Nonnull java.lang.Object key)
Executes a task on the owner of the specified key.- Parameters:
command
- a task executed on the owner of the specified keykey
- the specified key
-
submitToKeyOwner
<T> DurableExecutorServiceFuture<T> submitToKeyOwner(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull java.lang.Object key)
Submits a task to the owner of the specified key and returns a Future representing that task.- Type Parameters:
T
- the return type of the task- Parameters:
task
- task submitted to the owner of the specified keykey
- the specified key- Returns:
- a Future representing pending completion of the task
-
submitToKeyOwner
DurableExecutorServiceFuture<?> submitToKeyOwner(@Nonnull java.lang.Runnable task, @Nonnull java.lang.Object key)
Submits a task to the owner of the specified key and returns a Future representing that task.- Parameters:
task
- task submitted to the owner of the specified keykey
- the specified key- Returns:
- a Future representing pending completion of the task
-
-