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()orCacheStreaminstead.Infinispan's implementation of anExecutorServiceandDistributedExecutorService. 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,Runnableand/orDistributedCallablesubmitted must be eitherSerializableorExternalizable. Also the value returned from a callable must beSerializableorExternalizable. Unfortunately if the value returned is not serializable then aNotSerializableExceptionwill be thrown.- Since:
- 5.0
- Author:
- Vladimir Blagojevic
-
-
Field Summary
Fields Modifier and Type Field Description protected AdvancedCachecacheDeprecated.protected org.infinispan.commands.CancellationServicecancellationServiceDeprecated.protected org.infinispan.commands.CommandsFactoryfactoryDeprecated.protected AtomicBooleanisShutdownDeprecated.protected ExecutorServicelocalExecutorServiceDeprecated.protected MarshallermarshallerDeprecated.static DistributedTaskFailoverPolicyNO_FAILOVERDeprecated.static DistributedTaskFailoverPolicyRANDOM_NODE_FAILOVERDeprecated.protected RpcManagerrpcDeprecated.protected booleantakeExecutorOwnershipDeprecated.
-
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 booleanawaitTermination(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 ExecutorServicecreateLocalExecutor(Cache<?,?> masterCacheNode)Deprecated.voidexecute(Runnable command)Deprecated.protected <T> List<Address>executionCandidates(DistributedTask<T> task)Deprecated.protected List<Address>getMembers()Deprecated.<T> TinvokeAny(Collection<? extends Callable<T>> tasks)Deprecated.<T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)Deprecated.booleanisShutdown()Deprecated.booleanisTerminated()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 AddressselectExecutionNode(List<Address> candidates)Deprecated.protected <T> AddressselectExecutionNode(DistributedTask<T> task)Deprecated.voidshutdown()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
ThreadPoolExecutorconfigured 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:DistributedExecutorServiceReturns DistributedTaskBuilder for this DistributedExecutorService and a given Callable. As it name implies clients can use DistributedTaskBuilder to create DistributedTask instances.- Specified by:
createDistributedTaskBuilderin 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:
submitin interfaceExecutorService- Overrides:
submitin classAbstractExecutorService
-
submit
public <T> CompletableFuture<T> submit(Callable<T> task)
Deprecated.- Specified by:
submitin interfaceExecutorService- Overrides:
submitin classAbstractExecutorService
-
shutdown
public void shutdown()
Deprecated.- Specified by:
shutdownin interfaceExecutorService
-
executionCandidates
protected <T> List<Address> executionCandidates(DistributedTask<T> task)
Deprecated.
-
shutdownNow
public List<Runnable> shutdownNow()
Deprecated.- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()
Deprecated.- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()
Deprecated.- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedExceptionDeprecated.- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
Deprecated.- Specified by:
invokeAnyin interfaceExecutorService- Overrides:
invokeAnyin classAbstractExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Deprecated.- Specified by:
invokeAnyin interfaceExecutorService- Overrides:
invokeAnyin classAbstractExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
execute
public void execute(Runnable command)
Deprecated.
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
Deprecated.- Overrides:
newTaskForin classAbstractExecutorService
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable)
Deprecated.- Overrides:
newTaskForin classAbstractExecutorService
-
submit
public <T> CompletableFuture<T> submit(Address target, Callable<T> task)
Deprecated.Description copied from interface:DistributedExecutorServiceSubmits the given Callable task for execution on the specified target Infinispan node.- Specified by:
submitin 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:DistributedExecutorServiceSubmits the given DistributedTask for execution on the specified target Infinispan node.- Specified by:
submitin 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:DistributedExecutorServiceSubmits 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:
submitin 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:DistributedExecutorServiceSubmits 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:
submitin 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:DistributedExecutorServiceSubmits the given Callable task for execution on all available Infinispan nodes.- Specified by:
submitEverywherein 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:DistributedExecutorServiceSubmits the given DistributedTask for execution on all available Infinispan nodes.- Specified by:
submitEverywherein 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:DistributedExecutorServiceSubmits 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:
submitEverywherein 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:DistributedExecutorServiceSubmits 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:
submitEverywherein 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.
-
-