Class 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 use EmbeddedCacheManager.executor() or CacheStream instead.
    Infinispan's implementation of an 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.

    Since:
    5.0
    Author:
    Vladimir Blagojevic
    • 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
      • 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

      • isShutdown

        protected final java.util.concurrent.atomic.AtomicBoolean isShutdown
        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 {link ThreadPoolExecutor.CallerRunsPolicy)

        Parameters:
        masterCacheNode - Cache node initiating distributed task
        localExecutorService - 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 task
        localExecutorService - ExecutorService to run local tasks
        takeExecutorOwnership - if true ExecutorService.shutdown() and ExecutorService.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 interface DistributedExecutorService
        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 interface java.util.concurrent.ExecutorService
        Overrides:
        submit in class java.util.concurrent.AbstractExecutorService
      • submit

        public <T> java.util.concurrent.CompletableFuture<T> submit​(java.util.concurrent.Callable<T> task)
        Deprecated.
        Specified by:
        submit in interface java.util.concurrent.ExecutorService
        Overrides:
        submit in class java.util.concurrent.AbstractExecutorService
      • shutdown

        public void shutdown()
        Deprecated.
        Specified by:
        shutdown in interface java.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 interface java.util.concurrent.ExecutorService
      • isShutdown

        public boolean isShutdown()
        Deprecated.
        Specified by:
        isShutdown in interface java.util.concurrent.ExecutorService
      • isTerminated

        public boolean isTerminated()
        Deprecated.
        Specified by:
        isTerminated in interface java.util.concurrent.ExecutorService
      • awaitTermination

        public boolean awaitTermination​(long timeout,
                                        java.util.concurrent.TimeUnit unit)
                                 throws java.lang.InterruptedException
        Deprecated.
        Specified by:
        awaitTermination in interface java.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 interface java.util.concurrent.ExecutorService
        Overrides:
        invokeAny in class java.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 interface java.util.concurrent.ExecutorService
        Overrides:
        invokeAny in class java.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 interface java.util.concurrent.Executor
      • newTaskFor

        protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor​(java.lang.Runnable runnable,
                                                                        T value)
        Deprecated.
        Overrides:
        newTaskFor in class java.util.concurrent.AbstractExecutorService
      • newTaskFor

        protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor​(java.util.concurrent.Callable<T> callable)
        Deprecated.
        Overrides:
        newTaskFor in class java.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 interface DistributedExecutorService
        Parameters:
        target - address of Infinispan node selected for execution of the task
        task - 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 interface DistributedExecutorService
        Parameters:
        target - address of Infinispan node selected for execution of the task
        task - 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 interface DistributedExecutorService
        Parameters:
        task - a task to execute across Infinispan cluster
        input - input keys for this task, effective if and only if task is instance of DistributedCallable
        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 interface DistributedExecutorService
        Parameters:
        task - a DistributedTask to execute across Infinispan cluster
        input - input keys for this task, effective if and only if task's callable is instance of DistributedCallable
        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 interface DistributedExecutorService
        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 interface DistributedExecutorService
        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 interface DistributedExecutorService
        Parameters:
        task - a task to execute across Infinispan cluster
        input - input keys for this task, effective if and only if task is instance of DistributedCallable
        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 interface DistributedExecutorService
        Parameters:
        task - a task to execute across Infinispan cluster
        input - input keys for this task, effective if and only if task is instance of DistributedCallable
        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.
      • randomClusterMembers

        protected java.util.List<Address> randomClusterMembers​(java.util.List<Address> members,
                                                               int numNeeded)
        Deprecated.