public class ExecutorServiceProxy extends AbstractDistributedObject<DistributedExecutorService> implements IExecutorService
Modifier and Type | Field and Description |
---|---|
static int |
SYNC_DELAY_MS |
static int |
SYNC_FREQUENCY |
PARTITIONING_STRATEGY
Constructor and Description |
---|
ExecutorServiceProxy(String name,
NodeEngine nodeEngine,
DistributedExecutorService service) |
Modifier and Type | Method and Description |
---|---|
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() |
destroy, equals, getDistributedObjectName, getNameAsPartitionAwareData, getNodeEngine, getOperationService, getPartitionId, getPartitionKey, getService, hashCode, invalidate, invokeOnPartition, postDestroy, preDestroy, toData
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
destroy, getPartitionKey
public static final int SYNC_FREQUENCY
public static final int SYNC_DELAY_MS
public ExecutorServiceProxy(String name, NodeEngine nodeEngine, DistributedExecutorService service)
public void execute(Runnable command, MemberSelector memberSelector)
IExecutorService
execute
in interface IExecutorService
command
- the task that is executed on a randomly selected membermemberSelector
- memberSelectorpublic void executeOnMembers(Runnable command, MemberSelector memberSelector)
IExecutorService
executeOnMembers
in interface IExecutorService
command
- a task executed on each of the selected membersmemberSelector
- memberSelectorpublic <T> Future<T> submit(Callable<T> task, MemberSelector memberSelector)
IExecutorService
submit
in interface IExecutorService
T
- the result type of callabletask
- task submitted to a randomly selected membermemberSelector
- memberSelectorpublic <T> Map<Member,Future<T>> submitToMembers(Callable<T> task, MemberSelector memberSelector)
IExecutorService
submitToMembers
in interface IExecutorService
T
- the result type of callabletask
- the task submitted to selected membersmemberSelector
- memberSelectorpublic void submit(Runnable task, MemberSelector memberSelector, ExecutionCallback callback)
IExecutorService
ExecutionCallback.onResponse(Object)
or ExecutionCallback.onFailure(Throwable)
.submit
in interface IExecutorService
task
- the task submitted to randomly selected membersmemberSelector
- memberSelectorcallback
- callbackpublic void submitToMembers(Runnable task, MemberSelector memberSelector, MultiExecutionCallback callback)
IExecutorService
MultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,
MultiExecutionCallback.onComplete(java.util.Map)
will be called.submitToMembers
in interface IExecutorService
task
- the task submitted to the selected membersmemberSelector
- memberSelectorcallback
- callbackpublic <T> void submit(Callable<T> task, MemberSelector memberSelector, ExecutionCallback<T> callback)
IExecutorService
ExecutionCallback.onResponse(Object)
or ExecutionCallback.onFailure(Throwable)
.submit
in interface IExecutorService
T
- the result type of callabletask
- the task submitted to a randomly selected membermemberSelector
- memberSelectorcallback
- callbackpublic <T> void submitToMembers(Callable<T> task, MemberSelector memberSelector, MultiExecutionCallback callback)
IExecutorService
MultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,
MultiExecutionCallback.onComplete(java.util.Map)
will be called.submitToMembers
in interface IExecutorService
T
- the result type of callabletask
- the task submitted to the selected membersmemberSelector
- memberSelectorcallback
- callbackpublic void executeOnKeyOwner(Runnable command, Object key)
IExecutorService
executeOnKeyOwner
in interface IExecutorService
command
- a task executed on the owner of the specified keykey
- the specified keypublic void executeOnMember(Runnable command, Member member)
IExecutorService
executeOnMember
in interface IExecutorService
command
- the task executed on the specified membermember
- the specified memberpublic void executeOnMembers(Runnable command, Collection<Member> members)
IExecutorService
executeOnMembers
in interface IExecutorService
command
- the task executed on the specified membersmembers
- the specified memberspublic void executeOnAllMembers(Runnable command)
IExecutorService
executeOnAllMembers
in interface IExecutorService
command
- a task executed on all of the known cluster memberspublic Future<?> submit(Runnable task)
submit
in interface ExecutorService
public <T> Future<T> submit(Runnable task, T result)
submit
in interface ExecutorService
public <T> Future<T> submit(Callable<T> task)
submit
in interface ExecutorService
public <T> Future<T> submitToKeyOwner(Callable<T> task, Object key)
IExecutorService
submitToKeyOwner
in interface IExecutorService
T
- the result type of callabletask
- task submitted to the owner of the specified keykey
- the specified keypublic <T> Future<T> submitToMember(Callable<T> task, Member member)
IExecutorService
submitToMember
in interface IExecutorService
T
- the result type of callabletask
- the task submitted to the specified membermember
- the specified memberpublic <T> Map<Member,Future<T>> submitToMembers(Callable<T> task, Collection<Member> members)
IExecutorService
submitToMembers
in interface IExecutorService
T
- the result type of callabletask
- the task submitted to given membersmembers
- the given memberspublic <T> Map<Member,Future<T>> submitToAllMembers(Callable<T> task)
IExecutorService
submitToAllMembers
in interface IExecutorService
T
- the result type of callabletask
- the task submitted to all cluster memberspublic void submit(Runnable task, ExecutionCallback callback)
IExecutorService
ExecutionCallback.onResponse(Object)
or ExecutionCallback.onFailure(Throwable)
.submit
in interface IExecutorService
task
- a task submitted to a random membercallback
- callbackpublic void submitToKeyOwner(Runnable task, Object key, ExecutionCallback callback)
IExecutorService
ExecutionCallback.onResponse(Object)
or ExecutionCallback.onFailure(Throwable)
.submitToKeyOwner
in interface IExecutorService
task
- task submitted to the owner of the specified keykey
- the specified keycallback
- callbackpublic void submitToMember(Runnable task, Member member, ExecutionCallback callback)
IExecutorService
ExecutionCallback.onResponse(Object)
or ExecutionCallback.onFailure(Throwable)
.submitToMember
in interface IExecutorService
task
- the task submitted to the specified membermember
- the specified membercallback
- callbackpublic void submitToMembers(Runnable task, Collection<Member> members, MultiExecutionCallback callback)
IExecutorService
MultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,
MultiExecutionCallback.onComplete(java.util.Map)
will be called.submitToMembers
in interface IExecutorService
task
- the task submitted to the specified membersmembers
- the specified memberscallback
- callbackpublic void submitToAllMembers(Runnable task, MultiExecutionCallback callback)
IExecutorService
MultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,
MultiExecutionCallback.onComplete(java.util.Map)
will be called.submitToAllMembers
in interface IExecutorService
task
- the task submitted to all the cluster memberscallback
- callbackpublic <T> void submit(Callable<T> task, ExecutionCallback<T> callback)
IExecutorService
ExecutionCallback.onResponse(Object)
or ExecutionCallback.onFailure(Throwable)
.submit
in interface IExecutorService
T
- the result type of callabletask
- the task submitted to a random membercallback
- callbackpublic <T> void submitToKeyOwner(Callable<T> task, Object key, ExecutionCallback<T> callback)
IExecutorService
ExecutionCallback.onResponse(Object)
or ExecutionCallback.onFailure(Throwable)
.submitToKeyOwner
in interface IExecutorService
T
- the result type of callabletask
- the task submitted to the owner of the specified keykey
- the specified keycallback
- callbackpublic <T> void submitToMember(Callable<T> task, Member member, ExecutionCallback<T> callback)
IExecutorService
ExecutionCallback.onResponse(Object)
or ExecutionCallback.onFailure(Throwable)
.submitToMember
in interface IExecutorService
T
- the result type of callabletask
- the task submitted to the specified membermember
- the specified membercallback
- callbackpublic <T> void submitToMembers(Callable<T> task, Collection<Member> members, MultiExecutionCallback callback)
IExecutorService
MultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,
MultiExecutionCallback.onComplete(java.util.Map)
will be called.submitToMembers
in interface IExecutorService
T
- the result type of callabletask
- the task submitted to the specified membersmembers
- the specified memberscallback
- callbackpublic <T> void submitToAllMembers(Callable<T> task, MultiExecutionCallback callback)
IExecutorService
MultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,
MultiExecutionCallback.onComplete(java.util.Map)
will be called.submitToAllMembers
in interface IExecutorService
T
- the result type of callabletask
- the task submitted to all the cluster memberscallback
- callbackpublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
invokeAny
in interface ExecutorService
InterruptedException
ExecutionException
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny
in interface ExecutorService
InterruptedException
ExecutionException
TimeoutException
protected void throwNotActiveException()
throwNotActiveException
in class AbstractDistributedObject<DistributedExecutorService>
public boolean isShutdown()
isShutdown
in interface ExecutorService
public boolean isTerminated()
isTerminated
in interface ExecutorService
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
awaitTermination
in interface ExecutorService
InterruptedException
public void shutdown()
shutdown
in interface ExecutorService
public List<Runnable> shutdownNow()
shutdownNow
in interface ExecutorService
public LocalExecutorStats getLocalExecutorStats()
IExecutorService
getLocalExecutorStats
in interface IExecutorService
public String getServiceName()
DistributedObject
getServiceName
in interface DistributedObject
getServiceName
in class AbstractDistributedObject<DistributedExecutorService>
public String getName()
DistributedObject
DistributedObjectUtil.getName(DistributedObject)
because this might be also a PrefixedDistributedObject
.getName
in interface DistributedObject
public String toString()
toString
in class AbstractDistributedObject<DistributedExecutorService>
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.