EmbeddedCacheManager.executor() or CacheStream instead.public class DefaultExecutorService extends java.util.concurrent.AbstractExecutorService implements DistributedExecutorService
ExecutorService and DistributedExecutorService.
This ExecutorService provides methods to submit tasks for an execution on a cluster of Infinispan
nodes.
Note that due to potential task migration to another nodes every Callable,
Runnable and/or DistributedCallable submitted must be either Serializable
or Externalizable. Also the value returned from a callable must be Serializable
or Externalizable. Unfortunately if the value returned is not serializable then a
NotSerializableException will be thrown.
| Modifier and Type | Field and Description |
|---|---|
protected AdvancedCache |
cache
Deprecated.
|
protected CancellationService |
cancellationService
Deprecated.
|
protected CommandsFactory |
factory
Deprecated.
|
protected java.util.concurrent.atomic.AtomicBoolean |
isShutdown
Deprecated.
|
protected java.util.concurrent.ExecutorService |
localExecutorService
Deprecated.
|
protected Marshaller |
marshaller
Deprecated.
|
static DistributedTaskFailoverPolicy |
NO_FAILOVER
Deprecated.
|
static DistributedTaskFailoverPolicy |
RANDOM_NODE_FAILOVER
Deprecated.
|
protected RpcManager |
rpc
Deprecated.
|
protected boolean |
takeExecutorOwnership
Deprecated.
|
| Constructor and Description |
|---|
DefaultExecutorService(Cache<?,?> masterCacheNode)
Deprecated.
Creates a new DefaultExecutorService given a master cache node for local task execution.
|
DefaultExecutorService(Cache<?,?> masterCacheNode,
java.util.concurrent.ExecutorService localExecutorService)
Deprecated.
Creates a new DefaultExecutorService given a master cache node and an ExecutorService for
parallel execution of tasks ran on this node.
|
DefaultExecutorService(Cache<?,?> masterCacheNode,
java.util.concurrent.ExecutorService localExecutorService,
boolean takeExecutorOwnership)
Deprecated.
Creates a new DefaultExecutorService given a master cache node and an ExecutorService for
parallel execution of task ran on this node.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
Deprecated.
|
protected <T> java.util.concurrent.Callable<T> |
clone(java.util.concurrent.Callable<T> task)
Deprecated.
|
<T> DistributedTaskBuilder<T> |
createDistributedTaskBuilder(java.util.concurrent.Callable<T> callable)
Deprecated.
Returns DistributedTaskBuilder for this DistributedExecutorService and a given Callable.
|
protected <T,K> org.infinispan.distexec.DefaultExecutorService.DistributedTaskPart<T> |
createDistributedTaskPart(DistributedTask<T> task,
DistributedExecuteCommand<T> c,
Address target,
int failoverCount)
Deprecated.
|
protected <T,K> org.infinispan.distexec.DefaultExecutorService.DistributedTaskPart<T> |
createDistributedTaskPart(DistributedTask<T> task,
DistributedExecuteCommand<T> c,
java.util.List<K> inputKeys,
Address target,
int failoverCount)
Deprecated.
|
static java.util.concurrent.ExecutorService |
createLocalExecutor(Cache<?,?> masterCacheNode)
Deprecated.
|
void |
execute(java.lang.Runnable command)
Deprecated.
|
protected <T> java.util.List<Address> |
executionCandidates(DistributedTask<T> task)
Deprecated.
|
protected java.util.List<Address> |
getMembers()
Deprecated.
|
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
Deprecated.
|
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
Deprecated.
|
boolean |
isShutdown()
Deprecated.
|
boolean |
isTerminated()
Deprecated.
|
protected <K> java.util.Map<Address,java.util.List<K>> |
keysToExecutionNodes(DistributedTaskExecutionPolicy policy,
K... input)
Deprecated.
|
protected <T> java.util.concurrent.RunnableFuture<T> |
newTaskFor(java.util.concurrent.Callable<T> callable)
Deprecated.
|
protected <T> java.util.concurrent.RunnableFuture<T> |
newTaskFor(java.lang.Runnable runnable,
T value)
Deprecated.
|
protected java.util.List<Address> |
randomClusterMembers(java.util.List<Address> members,
int numNeeded)
Deprecated.
|
protected <T> Address |
selectExecutionNode(DistributedTask<T> task)
Deprecated.
|
protected Address |
selectExecutionNode(java.util.List<Address> candidates)
Deprecated.
|
void |
shutdown()
Deprecated.
|
java.util.List<java.lang.Runnable> |
shutdownNow()
Deprecated.
|
<T> java.util.concurrent.CompletableFuture<T> |
submit(Address target,
java.util.concurrent.Callable<T> task)
Deprecated.
Submits the given Callable task for execution on the specified target Infinispan node.
|
<T> java.util.concurrent.CompletableFuture<T> |
submit(Address target,
DistributedTask<T> task)
Deprecated.
Submits the given DistributedTask for execution on the specified target Infinispan node.
|
<T> java.util.concurrent.CompletableFuture<T> |
submit(java.util.concurrent.Callable<T> task)
Deprecated.
|
<T,K> java.util.concurrent.CompletableFuture<T> |
submit(java.util.concurrent.Callable<T> task,
K... input)
Deprecated.
Submits the given Callable task for execution on a single Infinispan node.
|
<T,K> java.util.concurrent.CompletableFuture<T> |
submit(DistributedTask<T> task,
K... input)
Deprecated.
Submits the given DistributedTask for execution on a single Infinispan node.
|
<T> java.util.concurrent.CompletableFuture<T> |
submit(java.lang.Runnable task,
T result)
Deprecated.
|
<T> java.util.List<java.util.concurrent.CompletableFuture<T>> |
submitEverywhere(java.util.concurrent.Callable<T> task)
Deprecated.
Submits the given Callable task for execution on all available Infinispan nodes.
|
<T,K> java.util.List<java.util.concurrent.CompletableFuture<T>> |
submitEverywhere(java.util.concurrent.Callable<T> task,
K... input)
Deprecated.
Submits the given Callable task for execution on all available Infinispan nodes using input
keys specified by K input.
|
<T> java.util.List<java.util.concurrent.CompletableFuture<T>> |
submitEverywhere(DistributedTask<T> task)
Deprecated.
Submits the given DistributedTask for execution on all available Infinispan nodes.
|
<T,K> java.util.List<java.util.concurrent.CompletableFuture<T>> |
submitEverywhere(DistributedTask<T> task,
K... input)
Deprecated.
Submits the given DistributedTask for execution on all available Infinispan nodes using input
keys specified by K input.
|
invokeAll, invokeAll, submitpublic static final DistributedTaskFailoverPolicy NO_FAILOVER
public static final DistributedTaskFailoverPolicy RANDOM_NODE_FAILOVER
protected final java.util.concurrent.atomic.AtomicBoolean isShutdown
protected final AdvancedCache cache
protected final RpcManager rpc
protected final CommandsFactory factory
protected final Marshaller marshaller
protected final java.util.concurrent.ExecutorService localExecutorService
protected final CancellationService cancellationService
protected final boolean takeExecutorOwnership
public DefaultExecutorService(Cache<?,?> masterCacheNode)
masterCacheNode - Cache node initiating distributed taskpublic DefaultExecutorService(Cache<?,?> masterCacheNode, java.util.concurrent.ExecutorService localExecutorService)
Note that DefaultExecutorService will not shutdown client supplied localExecutorService once
this DefaultExecutorService is shutdown. Lifecycle management of a supplied ExecutorService is
left to the client
Also note that client supplied ExecutorService should not execute tasks in the caller's thread
( i.e rejectionHandler of ThreadPoolExecutor configured with {link
ThreadPoolExecutor.CallerRunsPolicy)
masterCacheNode - Cache node initiating distributed tasklocalExecutorService - ExecutorService to run local taskspublic DefaultExecutorService(Cache<?,?> masterCacheNode, java.util.concurrent.ExecutorService localExecutorService, boolean takeExecutorOwnership)
masterCacheNode - Cache node initiating distributed tasklocalExecutorService - ExecutorService to run local taskstakeExecutorOwnership - if true ExecutorService.shutdown() and
ExecutorService.shutdownNow() method will shutdown
localExecutorService as wellpublic static java.util.concurrent.ExecutorService createLocalExecutor(Cache<?,?> masterCacheNode)
public <T> DistributedTaskBuilder<T> createDistributedTaskBuilder(java.util.concurrent.Callable<T> callable)
DistributedExecutorServicecreateDistributedTaskBuilder in interface DistributedExecutorServicecallable - the execution unit of DistributedTaskDistributedTaskpublic <T> java.util.concurrent.CompletableFuture<T> submit(java.lang.Runnable task,
T result)
submit in interface java.util.concurrent.ExecutorServicesubmit in class java.util.concurrent.AbstractExecutorServicepublic <T> java.util.concurrent.CompletableFuture<T> submit(java.util.concurrent.Callable<T> task)
submit in interface java.util.concurrent.ExecutorServicesubmit in class java.util.concurrent.AbstractExecutorServicepublic void shutdown()
shutdown in interface java.util.concurrent.ExecutorServiceprotected java.util.List<Address> getMembers()
protected <T> java.util.List<Address> executionCandidates(DistributedTask<T> task)
public java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow in interface java.util.concurrent.ExecutorServicepublic boolean isShutdown()
isShutdown in interface java.util.concurrent.ExecutorServicepublic boolean isTerminated()
isTerminated in interface java.util.concurrent.ExecutorServicepublic boolean awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
awaitTermination in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionpublic <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
invokeAny in interface java.util.concurrent.ExecutorServiceinvokeAny in class java.util.concurrent.AbstractExecutorServicejava.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
invokeAny in interface java.util.concurrent.ExecutorServiceinvokeAny in class java.util.concurrent.AbstractExecutorServicejava.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionpublic void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executorprotected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.lang.Runnable runnable,
T value)
newTaskFor in class java.util.concurrent.AbstractExecutorServiceprotected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.util.concurrent.Callable<T> callable)
newTaskFor in class java.util.concurrent.AbstractExecutorServicepublic <T> java.util.concurrent.CompletableFuture<T> submit(Address target, java.util.concurrent.Callable<T> task)
DistributedExecutorServicesubmit in interface DistributedExecutorServicetarget - address of Infinispan node selected for execution of the tasktask - a task to execute on selected Infinispan nodepublic <T> java.util.concurrent.CompletableFuture<T> submit(Address target, DistributedTask<T> task)
DistributedExecutorServicesubmit in interface DistributedExecutorServicetarget - address of Infinispan node selected for execution of the tasktask - a task to execute on selected Infinispan nodepublic <T,K> java.util.concurrent.CompletableFuture<T> submit(java.util.concurrent.Callable<T> task,
K... input)
DistributedExecutorServiceExecution environment will chose an arbitrary node N hosting some or all of the keys specified as input. If all keys are not available locally at node N they will be retrieved from the cluster.
submit in interface DistributedExecutorServicetask - a task to execute across Infinispan clusterinput - input keys for this task, effective if and only if task is instance of DistributedCallablepublic <T,K> java.util.concurrent.CompletableFuture<T> submit(DistributedTask<T> task, K... input)
DistributedExecutorServiceExecution environment will chose an arbitrary node N hosting some or all of the keys specified as input. If all keys are not available locally at node N they will be retrieved from the cluster.
submit in interface DistributedExecutorServicetask - a DistributedTask to execute across Infinispan clusterinput - input keys for this task, effective if and only if task's callable is instance of
DistributedCallablepublic <T> java.util.List<java.util.concurrent.CompletableFuture<T>> submitEverywhere(java.util.concurrent.Callable<T> task)
DistributedExecutorServicesubmitEverywhere in interface DistributedExecutorServicetask - a task to execute across Infinispan clusterpublic <T> java.util.List<java.util.concurrent.CompletableFuture<T>> submitEverywhere(DistributedTask<T> task)
DistributedExecutorServicesubmitEverywhere in interface DistributedExecutorServicetask - a task to execute across Infinispan clusterpublic <T,K> java.util.List<java.util.concurrent.CompletableFuture<T>> submitEverywhere(java.util.concurrent.Callable<T> task,
K... input)
DistributedExecutorServiceExecution environment will chose all nodes in Infinispan cluster where input keys are local, migrate given Callable instance to those nodes, execute it and return result as a list of Futures
submitEverywhere in interface DistributedExecutorServicetask - a task to execute across Infinispan clusterinput - input keys for this task, effective if and only if task is instance of DistributedCallablepublic <T,K> java.util.List<java.util.concurrent.CompletableFuture<T>> submitEverywhere(DistributedTask<T> task, K... input)
DistributedExecutorServiceExecution environment will chose all nodes in Infinispan cluster where input keys are local, migrate given Callable instance to those nodes, execute it and return result as a list of Futures
submitEverywhere in interface DistributedExecutorServicetask - a task to execute across Infinispan clusterinput - input keys for this task, effective if and only if task is instance of DistributedCallableprotected <T> java.util.concurrent.Callable<T> clone(java.util.concurrent.Callable<T> task)
protected <T,K> org.infinispan.distexec.DefaultExecutorService.DistributedTaskPart<T> createDistributedTaskPart(DistributedTask<T> task, DistributedExecuteCommand<T> c, java.util.List<K> inputKeys, Address target, int failoverCount)
protected <T,K> org.infinispan.distexec.DefaultExecutorService.DistributedTaskPart<T> createDistributedTaskPart(DistributedTask<T> task, DistributedExecuteCommand<T> c, Address target, int failoverCount)
protected Address selectExecutionNode(java.util.List<Address> candidates)
protected <T> Address selectExecutionNode(DistributedTask<T> task)
protected java.util.List<Address> randomClusterMembers(java.util.List<Address> members, int numNeeded)
protected <K> java.util.Map<Address,java.util.List<K>> keysToExecutionNodes(DistributedTaskExecutionPolicy policy, K... input)