Class DefaultExecutorService
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- org.infinispan.distexec.DefaultExecutorService
-
- All Implemented Interfaces:
Executor
,ExecutorService
,DistributedExecutorService
public class DefaultExecutorService extends 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 AtomicBoolean
isShutdown
Deprecated.protected 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, 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, 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, TimeUnit unit)
Deprecated.protected <T> Callable<T>
clone(Callable<T> task)
Deprecated.<T> DistributedTaskBuilder<T>
createDistributedTaskBuilder(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, 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 ExecutorService
createLocalExecutor(Cache<?,?> masterCacheNode)
Deprecated.void
execute(Runnable command)
Deprecated.protected <T> List<Address>
executionCandidates(DistributedTask<T> task)
Deprecated.protected List<Address>
getMembers()
Deprecated.<T> T
invokeAny(Collection<? extends Callable<T>> tasks)
Deprecated.<T> T
invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
Deprecated.boolean
isShutdown()
Deprecated.boolean
isTerminated()
Deprecated.protected <K> Map<Address,List<K>>
keysToExecutionNodes(DistributedTaskExecutionPolicy policy, K... input)
Deprecated.protected <T> RunnableFuture<T>
newTaskFor(Runnable runnable, T value)
Deprecated.protected <T> RunnableFuture<T>
newTaskFor(Callable<T> callable)
Deprecated.protected List<Address>
randomClusterMembers(List<Address> members, int numNeeded)
Deprecated.protected Address
selectExecutionNode(List<Address> candidates)
Deprecated.protected <T> Address
selectExecutionNode(DistributedTask<T> task)
Deprecated.void
shutdown()
Deprecated.List<Runnable>
shutdownNow()
Deprecated.<T> CompletableFuture<T>
submit(Runnable task, T result)
Deprecated.<T> CompletableFuture<T>
submit(Callable<T> task)
Deprecated.<T,K>
CompletableFuture<T>submit(Callable<T> task, K... input)
Deprecated.Submits the given Callable task for execution on a single Infinispan node.<T,K>
CompletableFuture<T>submit(DistributedTask<T> task, K... input)
Deprecated.Submits the given DistributedTask for execution on a single Infinispan node.<T> CompletableFuture<T>
submit(Address target, Callable<T> task)
Deprecated.Submits the given Callable task for execution on the specified target Infinispan node.<T> CompletableFuture<T>
submit(Address target, DistributedTask<T> task)
Deprecated.Submits the given DistributedTask for execution on the specified target Infinispan node.<T> List<CompletableFuture<T>>
submitEverywhere(Callable<T> task)
Deprecated.Submits the given Callable task for execution on all available Infinispan nodes.<T,K>
List<CompletableFuture<T>>submitEverywhere(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> List<CompletableFuture<T>>
submitEverywhere(DistributedTask<T> task)
Deprecated.Submits the given DistributedTask for execution on all available Infinispan nodes.<T,K>
List<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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.ExecutorService
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 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 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, 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, 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 ExecutorService createLocalExecutor(Cache<?,?> masterCacheNode)
Deprecated.
-
createDistributedTaskBuilder
public <T> DistributedTaskBuilder<T> createDistributedTaskBuilder(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> CompletableFuture<T> submit(Runnable task, T result)
Deprecated.- Specified by:
submit
in interfaceExecutorService
- Overrides:
submit
in classAbstractExecutorService
-
submit
public <T> CompletableFuture<T> submit(Callable<T> task)
Deprecated.- Specified by:
submit
in interfaceExecutorService
- Overrides:
submit
in classAbstractExecutorService
-
shutdown
public void shutdown()
Deprecated.- Specified by:
shutdown
in interfaceExecutorService
-
executionCandidates
protected <T> List<Address> executionCandidates(DistributedTask<T> task)
Deprecated.
-
shutdownNow
public List<Runnable> shutdownNow()
Deprecated.- Specified by:
shutdownNow
in interfaceExecutorService
-
isShutdown
public boolean isShutdown()
Deprecated.- Specified by:
isShutdown
in interfaceExecutorService
-
isTerminated
public boolean isTerminated()
Deprecated.- Specified by:
isTerminated
in interfaceExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
Deprecated.- Specified by:
awaitTermination
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
Deprecated.- Specified by:
invokeAny
in interfaceExecutorService
- Overrides:
invokeAny
in classAbstractExecutorService
- Throws:
InterruptedException
ExecutionException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Deprecated.- Specified by:
invokeAny
in interfaceExecutorService
- Overrides:
invokeAny
in classAbstractExecutorService
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
execute
public void execute(Runnable command)
Deprecated.
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
Deprecated.- Overrides:
newTaskFor
in classAbstractExecutorService
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable)
Deprecated.- Overrides:
newTaskFor
in classAbstractExecutorService
-
submit
public <T> CompletableFuture<T> submit(Address target, 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> 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> CompletableFuture<T> submit(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> 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> List<CompletableFuture<T>> submitEverywhere(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> List<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> List<CompletableFuture<T>> submitEverywhere(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> List<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
-
createDistributedTaskPart
protected <T,K> org.infinispan.distexec.DefaultExecutorService.DistributedTaskPart<T> createDistributedTaskPart(DistributedTask<T> task, org.infinispan.commands.read.DistributedExecuteCommand<T> c, 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 <T> Address selectExecutionNode(DistributedTask<T> task)
Deprecated.
-
randomClusterMembers
protected List<Address> randomClusterMembers(List<Address> members, int numNeeded)
Deprecated.
-
keysToExecutionNodes
protected <K> Map<Address,List<K>> keysToExecutionNodes(DistributedTaskExecutionPolicy policy, K... input)
Deprecated.
-
-