com.hazelcast.executor.impl
Class ExecutorServiceProxy

java.lang.Object
  extended by com.hazelcast.spi.AbstractDistributedObject<DistributedExecutorService>
      extended by com.hazelcast.executor.impl.ExecutorServiceProxy
All Implemented Interfaces:
DistributedObject, IExecutorService, Executor, ExecutorService

public class ExecutorServiceProxy
extends AbstractDistributedObject<DistributedExecutorService>
implements IExecutorService


Field Summary
static int SYNC_DELAY_MS
           
static int SYNC_FREQUENCY
           
 
Fields inherited from class com.hazelcast.spi.AbstractDistributedObject
PARTITIONING_STRATEGY
 
Constructor Summary
ExecutorServiceProxy(String name, NodeEngine nodeEngine, DistributedExecutorService service)
           
 
Method Summary
 boolean awaitTermination(long timeout, TimeUnit unit)
           
 void execute(Runnable command)
           
 void execute(Runnable command, MemberSelector memberSelector)
          Executes a task on a randomly selected member.
 void executeOnAllMembers(Runnable command)
          Executes a task on all of the known cluster members.
 void executeOnKeyOwner(Runnable command, Object key)
          Executes a task on the owner of the specified key.
 void executeOnMember(Runnable command, Member member)
          Executes a task on the specified member.
 void executeOnMembers(Runnable command, Collection<Member> members)
          Executes a task on each of the specified members.
 void executeOnMembers(Runnable command, MemberSelector memberSelector)
          Executes a task on each of the selected members.
 LocalExecutorStats getLocalExecutorStats()
          Returns local statistics related to this executor service.
 String getName()
          Returns the unique name for this DistributedObject.
 String getServiceName()
          Returns the service name for this object.
<T> List<Future<T>>
invokeAll(Collection<? extends Callable<T>> tasks)
           
<T> List<Future<T>>
invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
           
<T> T
invokeAny(Collection<? extends Callable<T>> tasks)
           
<T> T
invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
           
 boolean isShutdown()
           
 boolean isTerminated()
           
 void shutdown()
           
 List<Runnable> shutdownNow()
           
<T> Future<T>
submit(Callable<T> task)
           
<T> void
submit(Callable<T> task, ExecutionCallback<T> callback)
          Submits a task to a random member.
<T> Future<T>
submit(Callable<T> task, MemberSelector memberSelector)
          Submits a task to a randomly selected member and returns a Future representing that task.
<T> void
submit(Callable<T> task, MemberSelector memberSelector, ExecutionCallback<T> callback)
          Submits task to a randomly selected member.
 Future<?> submit(Runnable task)
           
 void submit(Runnable task, ExecutionCallback callback)
          Submits a task to a random member.
 void submit(Runnable task, MemberSelector memberSelector, ExecutionCallback callback)
          Submits a task to randomly selected members.
<T> Future<T>
submit(Runnable task, T result)
           
<T> Map<Member,Future<T>>
submitToAllMembers(Callable<T> task)
          Submits task to all cluster members and returns a map of Member-Future pairs representing pending completion of the task on each member.
<T> void
submitToAllMembers(Callable<T> task, MultiExecutionCallback callback)
          Submits task to all the cluster members.
 void submitToAllMembers(Runnable task, MultiExecutionCallback callback)
          Submits task to all the cluster members.
<T> Future<T>
submitToKeyOwner(Callable<T> task, Object key)
          Submits a task to the owner of the specified key and returns a Future representing that task.
<T> void
submitToKeyOwner(Callable<T> task, Object key, ExecutionCallback<T> callback)
          Submits task to the owner of the specified key.
 void submitToKeyOwner(Runnable task, Object key, ExecutionCallback callback)
          Submits a task to the owner of the specified key.
<T> Future<T>
submitToMember(Callable<T> task, Member member)
          Submits a task to the specified member and returns a Future representing that task.
<T> void
submitToMember(Callable<T> task, Member member, ExecutionCallback<T> callback)
          Submits a task to the specified member.
 void submitToMember(Runnable task, Member member, ExecutionCallback callback)
          Submits a task to the specified member.
<T> Map<Member,Future<T>>
submitToMembers(Callable<T> task, Collection<Member> members)
          Submits a task to given members and returns map of Member-Future pairs representing pending completion of the task on each member
<T> void
submitToMembers(Callable<T> task, Collection<Member> members, MultiExecutionCallback callback)
          Submits a task to the specified members.
<T> Map<Member,Future<T>>
submitToMembers(Callable<T> task, MemberSelector memberSelector)
          Submits a task to selected members and returns a map of Member-Future pairs representing pending completion of the task on each member.
<T> void
submitToMembers(Callable<T> task, MemberSelector memberSelector, MultiExecutionCallback callback)
          Submits task to the selected members.
 void submitToMembers(Runnable task, Collection<Member> members, MultiExecutionCallback callback)
          Submits a task to the specified members.
 void submitToMembers(Runnable task, MemberSelector memberSelector, MultiExecutionCallback callback)
          Submits task to the selected members.
protected  void throwNotActiveException()
           
 String toString()
           
 
Methods inherited from class com.hazelcast.spi.AbstractDistributedObject
destroy, equals, getId, getNameAsPartitionAwareData, getNodeEngine, getPartitionKey, getService, hashCode, invalidate, postDestroy
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getId, getPartitionKey
 

Field Detail

SYNC_FREQUENCY

public static final int SYNC_FREQUENCY
See Also:
Constant Field Values

SYNC_DELAY_MS

public static final int SYNC_DELAY_MS
See Also:
Constant Field Values
Constructor Detail

ExecutorServiceProxy

public ExecutorServiceProxy(String name,
                            NodeEngine nodeEngine,
                            DistributedExecutorService service)
Method Detail

execute

public void execute(Runnable command,
                    MemberSelector memberSelector)
Description copied from interface: IExecutorService
Executes a task on a randomly selected member.

Specified by:
execute in interface IExecutorService
Parameters:
command - the task that is executed on a randomly selected member
memberSelector - memberSelector

executeOnMembers

public void executeOnMembers(Runnable command,
                             MemberSelector memberSelector)
Description copied from interface: IExecutorService
Executes a task on each of the selected members.

Specified by:
executeOnMembers in interface IExecutorService
Parameters:
command - a task executed on each of the selected members
memberSelector - memberSelector

submit

public <T> Future<T> submit(Callable<T> task,
                            MemberSelector memberSelector)
Description copied from interface: IExecutorService
Submits a task to a randomly selected member and returns a Future representing that task.

Specified by:
submit in interface IExecutorService
Parameters:
task - task submitted to a randomly selected member
memberSelector - memberSelector
Returns:
a Future representing pending completion of the task

submitToMembers

public <T> Map<Member,Future<T>> submitToMembers(Callable<T> task,
                                                 MemberSelector memberSelector)
Description copied from interface: IExecutorService
Submits a task to selected members and returns a map of Member-Future pairs representing pending completion of the task on each member.

Specified by:
submitToMembers in interface IExecutorService
Parameters:
task - the task submitted to selected members
memberSelector - memberSelector
Returns:
map of Member-Future pairs representing pending completion of the task on each member

submit

public void submit(Runnable task,
                   MemberSelector memberSelector,
                   ExecutionCallback callback)
Description copied from interface: IExecutorService
Submits a task to randomly selected members. Caller will be notified for the result of the task by ExecutionCallback.onResponse(Object) or ExecutionCallback.onFailure(Throwable).

Specified by:
submit in interface IExecutorService
Parameters:
task - the task submitted to randomly selected members
memberSelector - memberSelector
callback - callback

submitToMembers

public void submitToMembers(Runnable task,
                            MemberSelector memberSelector,
                            MultiExecutionCallback callback)
Description copied from interface: IExecutorService
Submits task to the selected members. Caller will be notified for the result of the each task by MultiExecutionCallback.onResponse(Member, Object), and when all tasks are completed, MultiExecutionCallback.onComplete(java.util.Map) will be called.

Specified by:
submitToMembers in interface IExecutorService
Parameters:
task - the task submitted to the selected members
memberSelector - memberSelector
callback - callback

submit

public <T> void submit(Callable<T> task,
                       MemberSelector memberSelector,
                       ExecutionCallback<T> callback)
Description copied from interface: IExecutorService
Submits task to a randomly selected member. Caller will be notified for the result of the task by ExecutionCallback.onResponse(Object) or ExecutionCallback.onFailure(Throwable).

Specified by:
submit in interface IExecutorService
Parameters:
task - the task submitted to a randomly selected member
memberSelector - memberSelector
callback - callback

submitToMembers

public <T> void submitToMembers(Callable<T> task,
                                MemberSelector memberSelector,
                                MultiExecutionCallback callback)
Description copied from interface: IExecutorService
Submits task to the selected members. Caller will be notified for the result of each task by MultiExecutionCallback.onResponse(Member, Object), and when all tasks are completed, MultiExecutionCallback.onComplete(java.util.Map) will be called.

Specified by:
submitToMembers in interface IExecutorService
Parameters:
task - the task submitted to the selected members
memberSelector - memberSelector
callback - callback

execute

public void execute(Runnable command)
Specified by:
execute in interface Executor

executeOnKeyOwner

public void executeOnKeyOwner(Runnable command,
                              Object key)
Description copied from interface: IExecutorService
Executes a task on the owner of the specified key.

Specified by:
executeOnKeyOwner in interface IExecutorService
Parameters:
command - a task executed on the owner of the specified key
key - the specified key

executeOnMember

public void executeOnMember(Runnable command,
                            Member member)
Description copied from interface: IExecutorService
Executes a task on the specified member.

Specified by:
executeOnMember in interface IExecutorService
Parameters:
command - the task executed on the specified member
member - the specified member

executeOnMembers

public void executeOnMembers(Runnable command,
                             Collection<Member> members)
Description copied from interface: IExecutorService
Executes a task on each of the specified members.

Specified by:
executeOnMembers in interface IExecutorService
Parameters:
command - the task executed on the specified members
members - the specified members

executeOnAllMembers

public void executeOnAllMembers(Runnable command)
Description copied from interface: IExecutorService
Executes a task on all of the known cluster members.

Specified by:
executeOnAllMembers in interface IExecutorService
Parameters:
command - a task executed on all of the known cluster members

submit

public Future<?> submit(Runnable task)
Specified by:
submit in interface ExecutorService

submit

public <T> Future<T> submit(Runnable task,
                            T result)
Specified by:
submit in interface ExecutorService

submit

public <T> Future<T> submit(Callable<T> task)
Specified by:
submit in interface ExecutorService

submitToKeyOwner

public <T> Future<T> submitToKeyOwner(Callable<T> task,
                                      Object key)
Description copied from interface: IExecutorService
Submits a task to the owner of the specified key and returns a Future representing that task.

Specified by:
submitToKeyOwner in interface IExecutorService
Parameters:
task - task submitted to the owner of the specified key
key - the specified key
Returns:
a Future representing pending completion of the task

submitToMember

public <T> Future<T> submitToMember(Callable<T> task,
                                    Member member)
Description copied from interface: IExecutorService
Submits a task to the specified member and returns a Future representing that task.

Specified by:
submitToMember in interface IExecutorService
Parameters:
task - the task submitted to the specified member
member - the specified member
Returns:
a Future representing pending completion of the task

submitToMembers

public <T> Map<Member,Future<T>> submitToMembers(Callable<T> task,
                                                 Collection<Member> members)
Description copied from interface: IExecutorService
Submits a task to given members and returns map of Member-Future pairs representing pending completion of the task on each member

Specified by:
submitToMembers in interface IExecutorService
Parameters:
task - the task submitted to given members
members - the given members
Returns:
map of Member-Future pairs representing pending completion of the task on each member

submitToAllMembers

public <T> Map<Member,Future<T>> submitToAllMembers(Callable<T> task)
Description copied from interface: IExecutorService
Submits task to all cluster members and returns a map of Member-Future pairs representing pending completion of the task on each member.

Specified by:
submitToAllMembers in interface IExecutorService
Parameters:
task - the task submitted to all cluster members
Returns:
map of Member-Future pairs representing pending completion of the task on each member

submit

public void submit(Runnable task,
                   ExecutionCallback callback)
Description copied from interface: IExecutorService
Submits a task to a random member. Caller will be notified of the result of the task by ExecutionCallback.onResponse(Object) or ExecutionCallback.onFailure(Throwable).

Specified by:
submit in interface IExecutorService
Parameters:
task - a task submitted to a random member
callback - callback

submitToKeyOwner

public void submitToKeyOwner(Runnable task,
                             Object key,
                             ExecutionCallback callback)
Description copied from interface: IExecutorService
Submits a task to the owner of the specified key. Caller will be notified for the result of the task by ExecutionCallback.onResponse(Object) or ExecutionCallback.onFailure(Throwable).

Specified by:
submitToKeyOwner in interface IExecutorService
Parameters:
task - task submitted to the owner of the specified key
key - the specified key
callback - callback

submitToMember

public void submitToMember(Runnable task,
                           Member member,
                           ExecutionCallback callback)
Description copied from interface: IExecutorService
Submits a task to the specified member. Caller will be notified for the result of the task by ExecutionCallback.onResponse(Object) or ExecutionCallback.onFailure(Throwable).

Specified by:
submitToMember in interface IExecutorService
Parameters:
task - the task submitted to the specified member
member - the specified member
callback - callback

submitToMembers

public void submitToMembers(Runnable task,
                            Collection<Member> members,
                            MultiExecutionCallback callback)
Description copied from interface: IExecutorService
Submits a task to the specified members. Caller will be notified for the result of the each task by MultiExecutionCallback.onResponse(Member, Object), and when all tasks are completed, MultiExecutionCallback.onComplete(java.util.Map) will be called.

Specified by:
submitToMembers in interface IExecutorService
Parameters:
task - the task submitted to the specified members
members - the specified members
callback - callback

submitToAllMembers

public void submitToAllMembers(Runnable task,
                               MultiExecutionCallback callback)
Description copied from interface: IExecutorService
Submits task to all the cluster members. Caller will be notified for the result of each task by MultiExecutionCallback.onResponse(Member, Object), and when all tasks are completed, MultiExecutionCallback.onComplete(java.util.Map) will be called.

Specified by:
submitToAllMembers in interface IExecutorService
Parameters:
task - the task submitted to all the cluster members
callback - callback

submit

public <T> void submit(Callable<T> task,
                       ExecutionCallback<T> callback)
Description copied from interface: IExecutorService
Submits a task to a random member. Caller will be notified for the result of the task by ExecutionCallback.onResponse(Object) or ExecutionCallback.onFailure(Throwable).

Specified by:
submit in interface IExecutorService
Parameters:
task - the task submitted to a random member
callback - callback

submitToKeyOwner

public <T> void submitToKeyOwner(Callable<T> task,
                                 Object key,
                                 ExecutionCallback<T> callback)
Description copied from interface: IExecutorService
Submits task to the owner of the specified key. Caller will be notified for the result of the task by ExecutionCallback.onResponse(Object) or ExecutionCallback.onFailure(Throwable).

Specified by:
submitToKeyOwner in interface IExecutorService
Parameters:
task - the task submitted to the owner of the specified key
callback - callback

submitToMember

public <T> void submitToMember(Callable<T> task,
                               Member member,
                               ExecutionCallback<T> callback)
Description copied from interface: IExecutorService
Submits a task to the specified member. Caller will be notified for the result of the task by ExecutionCallback.onResponse(Object) or ExecutionCallback.onFailure(Throwable).

Specified by:
submitToMember in interface IExecutorService
Parameters:
task - the task submitted to the specified member
callback - callback

submitToMembers

public <T> void submitToMembers(Callable<T> task,
                                Collection<Member> members,
                                MultiExecutionCallback callback)
Description copied from interface: IExecutorService
Submits a task to the specified members. Caller will be notified for the result of each task by MultiExecutionCallback.onResponse(Member, Object), and when all tasks are completed, MultiExecutionCallback.onComplete(java.util.Map) will be called.

Specified by:
submitToMembers in interface IExecutorService
Parameters:
task - the task submitted to the specified members
members - the specified members
callback - callback

submitToAllMembers

public <T> void submitToAllMembers(Callable<T> task,
                                   MultiExecutionCallback callback)
Description copied from interface: IExecutorService
Submits task to all the cluster members. Caller will be notified for the result of the each task by MultiExecutionCallback.onResponse(Member, Object), and when all tasks are completed, MultiExecutionCallback.onComplete(java.util.Map) will be called.

Specified by:
submitToAllMembers in interface IExecutorService
Parameters:
task - the task submitted to all the cluster members
callback - callback

invokeAll

public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
                          throws InterruptedException
Specified by:
invokeAll in interface ExecutorService
Throws:
InterruptedException

invokeAll

public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks,
                                     long timeout,
                                     TimeUnit unit)
                          throws InterruptedException
Specified by:
invokeAll in interface ExecutorService
Throws:
InterruptedException

invokeAny

public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
            throws InterruptedException,
                   ExecutionException
Specified by:
invokeAny in interface ExecutorService
Throws:
InterruptedException
ExecutionException

invokeAny

public <T> T invokeAny(Collection<? extends Callable<T>> tasks,
                       long timeout,
                       TimeUnit unit)
            throws InterruptedException,
                   ExecutionException,
                   TimeoutException
Specified by:
invokeAny in interface ExecutorService
Throws:
InterruptedException
ExecutionException
TimeoutException

throwNotActiveException

protected void throwNotActiveException()
Overrides:
throwNotActiveException in class AbstractDistributedObject<DistributedExecutorService>

isShutdown

public boolean isShutdown()
Specified by:
isShutdown in interface ExecutorService

isTerminated

public boolean isTerminated()
Specified by:
isTerminated in interface ExecutorService

awaitTermination

public boolean awaitTermination(long timeout,
                                TimeUnit unit)
                         throws InterruptedException
Specified by:
awaitTermination in interface ExecutorService
Throws:
InterruptedException

shutdown

public void shutdown()
Specified by:
shutdown in interface ExecutorService

shutdownNow

public List<Runnable> shutdownNow()
Specified by:
shutdownNow in interface ExecutorService

getLocalExecutorStats

public LocalExecutorStats getLocalExecutorStats()
Description copied from interface: IExecutorService
Returns local statistics related to this executor service.

Specified by:
getLocalExecutorStats in interface IExecutorService
Returns:
local statistics related to this executor service

getServiceName

public String getServiceName()
Description copied from interface: DistributedObject
Returns the service name for this object.

Specified by:
getServiceName in interface DistributedObject
Specified by:
getServiceName in class AbstractDistributedObject<DistributedExecutorService>
Returns:
the service name for this object.

getName

public String getName()
Description copied from interface: DistributedObject
Returns the unique name for this DistributedObject. The returned value will never be null.

Specified by:
getName in interface DistributedObject
Returns:
the unique name for this object.

toString

public String toString()
Overrides:
toString in class AbstractDistributedObject<DistributedExecutorService>


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.