Class DefaultExecutorService
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- org.infinispan.distexec.DefaultExecutorService
-
- All Implemented Interfaces:
java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
,DistributedExecutorService
public class DefaultExecutorService extends java.util.concurrent.AbstractExecutorService implements DistributedExecutorService
Deprecated.since 9.1 Please useEmbeddedCacheManager.executor()
orCacheStream
instead.Infinispan's implementation of anExecutorService
andDistributedExecutorService
. 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/orDistributedCallable
submitted must be eitherSerializable
orExternalizable
. Also the value returned from a callable must beSerializable
orExternalizable
. Unfortunately if the value returned is not serializable then aNotSerializableException
will be thrown.- Since:
- 5.0
- Author:
- Vladimir Blagojevic
-
-
Field Summary
Fields Modifier and Type Field Description protected AdvancedCache
cache
Deprecated.protected org.infinispan.commands.CancellationService
cancellationService
Deprecated.protected org.infinispan.commands.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 Summary
Constructors Constructor 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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, org.infinispan.commands.read.DistributedExecuteCommand<T> c, java.util.List<K> inputKeys, Address target, int failoverCount)
Deprecated.protected <T,K>
org.infinispan.distexec.DefaultExecutorService.DistributedTaskPart<T>createDistributedTaskPart(DistributedTask<T> task, org.infinispan.commands.read.DistributedExecuteCommand<T> c, 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.lang.Runnable runnable, T value)
Deprecated.protected <T> java.util.concurrent.RunnableFuture<T>
newTaskFor(java.util.concurrent.Callable<T> callable)
Deprecated.protected java.util.List<Address>
randomClusterMembers(java.util.List<Address> members, int numNeeded)
Deprecated.protected Address
selectExecutionNode(java.util.List<Address> candidates)
Deprecated.protected <T> Address
selectExecutionNode(DistributedTask<T> task)
Deprecated.void
shutdown()
Deprecated.java.util.List<java.lang.Runnable>
shutdownNow()
Deprecated.<T> java.util.concurrent.CompletableFuture<T>
submit(java.lang.Runnable task, T result)
Deprecated.<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(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.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.-
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, submit
-
-
-
-
Field Detail
-
NO_FAILOVER
public static final DistributedTaskFailoverPolicy NO_FAILOVER
Deprecated.
-
RANDOM_NODE_FAILOVER
public static final DistributedTaskFailoverPolicy RANDOM_NODE_FAILOVER
Deprecated.
-
isShutdown
protected final java.util.concurrent.atomic.AtomicBoolean isShutdown
Deprecated.
-
cache
protected final AdvancedCache cache
Deprecated.
-
rpc
protected final RpcManager rpc
Deprecated.
-
factory
protected final org.infinispan.commands.CommandsFactory factory
Deprecated.
-
marshaller
protected final Marshaller marshaller
Deprecated.
-
localExecutorService
protected final java.util.concurrent.ExecutorService localExecutorService
Deprecated.
-
cancellationService
protected final org.infinispan.commands.CancellationService cancellationService
Deprecated.
-
takeExecutorOwnership
protected final boolean takeExecutorOwnership
Deprecated.
-
-
Constructor Detail
-
DefaultExecutorService
public DefaultExecutorService(Cache<?,?> masterCacheNode)
Deprecated.Creates a new DefaultExecutorService given a master cache node for local task execution. All distributed task executions will be initiated from this Infinispan cache node- Parameters:
masterCacheNode
- Cache node initiating distributed task
-
DefaultExecutorService
public 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. All distributed task executions will be initiated from this Infinispan cache node.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 {linkThreadPoolExecutor.CallerRunsPolicy
)- Parameters:
masterCacheNode
- Cache node initiating distributed tasklocalExecutorService
- ExecutorService to run local tasks
-
DefaultExecutorService
public 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. All distributed task executions will be initiated from this Infinispan cache node.- Parameters:
masterCacheNode
- Cache node initiating distributed tasklocalExecutorService
- ExecutorService to run local taskstakeExecutorOwnership
- if trueExecutorService.shutdown()
andExecutorService.shutdownNow()
method will shutdown localExecutorService as well
-
-
Method Detail
-
createLocalExecutor
public static java.util.concurrent.ExecutorService createLocalExecutor(Cache<?,?> masterCacheNode)
Deprecated.
-
createDistributedTaskBuilder
public <T> DistributedTaskBuilder<T> createDistributedTaskBuilder(java.util.concurrent.Callable<T> callable)
Deprecated.Description copied from interface:DistributedExecutorService
Returns DistributedTaskBuilder for this DistributedExecutorService and a given Callable. As it name implies clients can use DistributedTaskBuilder to create DistributedTask instances.- Specified by:
createDistributedTaskBuilder
in interfaceDistributedExecutorService
- Parameters:
callable
- the execution unit of DistributedTask- Returns:
- DistributedTaskBuilder to create
DistributedTask
-
submit
public <T> java.util.concurrent.CompletableFuture<T> submit(java.lang.Runnable task, T result)
Deprecated.- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
- Overrides:
submit
in classjava.util.concurrent.AbstractExecutorService
-
submit
public <T> java.util.concurrent.CompletableFuture<T> submit(java.util.concurrent.Callable<T> task)
Deprecated.- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
- Overrides:
submit
in classjava.util.concurrent.AbstractExecutorService
-
shutdown
public void shutdown()
Deprecated.- Specified by:
shutdown
in interfacejava.util.concurrent.ExecutorService
-
getMembers
protected java.util.List<Address> getMembers()
Deprecated.
-
executionCandidates
protected <T> java.util.List<Address> executionCandidates(DistributedTask<T> task)
Deprecated.
-
shutdownNow
public java.util.List<java.lang.Runnable> shutdownNow()
Deprecated.- Specified by:
shutdownNow
in interfacejava.util.concurrent.ExecutorService
-
isShutdown
public boolean isShutdown()
Deprecated.- Specified by:
isShutdown
in interfacejava.util.concurrent.ExecutorService
-
isTerminated
public boolean isTerminated()
Deprecated.- Specified by:
isTerminated
in interfacejava.util.concurrent.ExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Deprecated.- Specified by:
awaitTermination
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
invokeAny
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
Deprecated.- Specified by:
invokeAny
in interfacejava.util.concurrent.ExecutorService
- Overrides:
invokeAny
in classjava.util.concurrent.AbstractExecutorService
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
-
invokeAny
public <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
Deprecated.- Specified by:
invokeAny
in interfacejava.util.concurrent.ExecutorService
- Overrides:
invokeAny
in classjava.util.concurrent.AbstractExecutorService
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
-
execute
public void execute(java.lang.Runnable command)
Deprecated.- Specified by:
execute
in interfacejava.util.concurrent.Executor
-
newTaskFor
protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.lang.Runnable runnable, T value)
Deprecated.- Overrides:
newTaskFor
in classjava.util.concurrent.AbstractExecutorService
-
newTaskFor
protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.util.concurrent.Callable<T> callable)
Deprecated.- Overrides:
newTaskFor
in classjava.util.concurrent.AbstractExecutorService
-
submit
public <T> java.util.concurrent.CompletableFuture<T> submit(Address target, java.util.concurrent.Callable<T> task)
Deprecated.Description copied from interface:DistributedExecutorService
Submits the given Callable task for execution on the specified target Infinispan node.- Specified by:
submit
in interfaceDistributedExecutorService
- Parameters:
target
- address of Infinispan node selected for execution of the tasktask
- a task to execute on selected Infinispan node- Returns:
- a Future representing pending completion of the task
-
submit
public <T> java.util.concurrent.CompletableFuture<T> submit(Address target, DistributedTask<T> task)
Deprecated.Description copied from interface:DistributedExecutorService
Submits the given DistributedTask for execution on the specified target Infinispan node.- Specified by:
submit
in interfaceDistributedExecutorService
- Parameters:
target
- address of Infinispan node selected for execution of the tasktask
- a task to execute on selected Infinispan node- Returns:
- a Future representing pending completion of the task
-
submit
public <T,K> java.util.concurrent.CompletableFuture<T> submit(java.util.concurrent.Callable<T> task, K... input)
Deprecated.Description copied from interface:DistributedExecutorService
Submits the given Callable task for execution on a single Infinispan node.Execution 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.
- Specified by:
submit
in interfaceDistributedExecutorService
- Parameters:
task
- a task to execute across Infinispan clusterinput
- input keys for this task, effective if and only if task is instance ofDistributedCallable
- Returns:
- a Future representing pending completion of the task
-
submit
public <T,K> java.util.concurrent.CompletableFuture<T> submit(DistributedTask<T> task, K... input)
Deprecated.Description copied from interface:DistributedExecutorService
Submits the given DistributedTask for execution on a single Infinispan node.Execution 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.
- Specified by:
submit
in interfaceDistributedExecutorService
- Parameters:
task
- a DistributedTask to execute across Infinispan clusterinput
- input keys for this task, effective if and only if task's callable is instance ofDistributedCallable
- Returns:
- a Future representing pending completion of the task
-
submitEverywhere
public <T> java.util.List<java.util.concurrent.CompletableFuture<T>> submitEverywhere(java.util.concurrent.Callable<T> task)
Deprecated.Description copied from interface:DistributedExecutorService
Submits the given Callable task for execution on all available Infinispan nodes.- Specified by:
submitEverywhere
in interfaceDistributedExecutorService
- Parameters:
task
- a task to execute across Infinispan cluster- Returns:
- a list of Futures, one future per Infinispan cluster node where task was executed
-
submitEverywhere
public <T> java.util.List<java.util.concurrent.CompletableFuture<T>> submitEverywhere(DistributedTask<T> task)
Deprecated.Description copied from interface:DistributedExecutorService
Submits the given DistributedTask for execution on all available Infinispan nodes.- Specified by:
submitEverywhere
in interfaceDistributedExecutorService
- Parameters:
task
- a task to execute across Infinispan cluster- Returns:
- a list of Futures, one future per Infinispan cluster node where task was executed
-
submitEverywhere
public <T,K> java.util.List<java.util.concurrent.CompletableFuture<T>> submitEverywhere(java.util.concurrent.Callable<T> task, K... input)
Deprecated.Description copied from interface:DistributedExecutorService
Submits the given Callable task for execution on all available Infinispan nodes using input keys specified by K input.Execution 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
- Specified by:
submitEverywhere
in interfaceDistributedExecutorService
- Parameters:
task
- a task to execute across Infinispan clusterinput
- input keys for this task, effective if and only if task is instance ofDistributedCallable
- Returns:
- a list of Futures, one future per Infinispan cluster node where task was executed
-
submitEverywhere
public <T,K> java.util.List<java.util.concurrent.CompletableFuture<T>> submitEverywhere(DistributedTask<T> task, K... input)
Deprecated.Description copied from interface:DistributedExecutorService
Submits the given DistributedTask for execution on all available Infinispan nodes using input keys specified by K input.Execution 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
- Specified by:
submitEverywhere
in interfaceDistributedExecutorService
- Parameters:
task
- a task to execute across Infinispan clusterinput
- input keys for this task, effective if and only if task is instance ofDistributedCallable
- Returns:
- a list of Futures, one future per Infinispan cluster node where task was executed
-
clone
protected <T> java.util.concurrent.Callable<T> clone(java.util.concurrent.Callable<T> task)
Deprecated.
-
createDistributedTaskPart
protected <T,K> org.infinispan.distexec.DefaultExecutorService.DistributedTaskPart<T> createDistributedTaskPart(DistributedTask<T> task, org.infinispan.commands.read.DistributedExecuteCommand<T> c, java.util.List<K> inputKeys, Address target, int failoverCount)
Deprecated.
-
createDistributedTaskPart
protected <T,K> org.infinispan.distexec.DefaultExecutorService.DistributedTaskPart<T> createDistributedTaskPart(DistributedTask<T> task, org.infinispan.commands.read.DistributedExecuteCommand<T> c, Address target, int failoverCount)
Deprecated.
-
selectExecutionNode
protected Address selectExecutionNode(java.util.List<Address> candidates)
Deprecated.
-
selectExecutionNode
protected <T> Address selectExecutionNode(DistributedTask<T> task)
Deprecated.
-
randomClusterMembers
protected java.util.List<Address> randomClusterMembers(java.util.List<Address> members, int numNeeded)
Deprecated.
-
keysToExecutionNodes
protected <K> java.util.Map<Address,java.util.List<K>> keysToExecutionNodes(DistributedTaskExecutionPolicy policy, K... input)
Deprecated.
-
-