Package com.hazelcast.core
Interface IExecutorService
-
- All Superinterfaces:
DistributedObject
,java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
public interface IExecutorService extends java.util.concurrent.ExecutorService, DistributedObject
Distributed implementation ofExecutorService
. IExecutorService provides additional methods like executing tasks on a specific member, on a member who is owner of a specific key, executing a tasks on multiple members and listening execution result using a callback. Supports split brain protectionSplitBrainProtectionConfig
since 3.10 in cluster versions 3.10 and higher.- See Also:
ExecutorService
,ExecutionCallback
,MultiExecutionCallback
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
execute(java.lang.Runnable command, MemberSelector memberSelector)
Executes a task on a randomly selected member.void
executeOnAllMembers(java.lang.Runnable command)
Executes a task on all of the known cluster members.void
executeOnKeyOwner(java.lang.Runnable command, java.lang.Object key)
Executes a task on the owner of the specified key.void
executeOnMember(java.lang.Runnable command, Member member)
Executes a task on the specified member.void
executeOnMembers(java.lang.Runnable command, MemberSelector memberSelector)
Executes a task on each of the selected members.void
executeOnMembers(java.lang.Runnable command, java.util.Collection<Member> members)
Executes a task on each of the specified members.LocalExecutorStats
getLocalExecutorStats()
Returns local statistics related to this executor service.<T> void
submit(java.lang.Runnable task, MemberSelector memberSelector, ExecutionCallback<T> callback)
Submits a task to randomly selected members.<T> void
submit(java.lang.Runnable task, ExecutionCallback<T> callback)
Submits a task to a random member.<T> java.util.concurrent.Future<T>
submit(java.util.concurrent.Callable<T> task, MemberSelector memberSelector)
Submits a task to a randomly selected member and returns a Future representing that task.<T> void
submit(java.util.concurrent.Callable<T> task, MemberSelector memberSelector, ExecutionCallback<T> callback)
Submits task to a randomly selected member.<T> void
submit(java.util.concurrent.Callable<T> task, ExecutionCallback<T> callback)
Submits a task to a random member.void
submitToAllMembers(java.lang.Runnable task, MultiExecutionCallback callback)
Submits task to all the cluster members.<T> java.util.Map<Member,java.util.concurrent.Future<T>>
submitToAllMembers(java.util.concurrent.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(java.util.concurrent.Callable<T> task, MultiExecutionCallback callback)
Submits task to all the cluster members.<T> void
submitToKeyOwner(java.lang.Runnable task, java.lang.Object key, ExecutionCallback<T> callback)
Submits a task to the owner of the specified key.<T> java.util.concurrent.Future<T>
submitToKeyOwner(java.util.concurrent.Callable<T> task, java.lang.Object key)
Submits a task to the owner of the specified key and returns a Future representing that task.<T> void
submitToKeyOwner(java.util.concurrent.Callable<T> task, java.lang.Object key, ExecutionCallback<T> callback)
Submits task to the owner of the specified key.<T> void
submitToMember(java.lang.Runnable task, Member member, ExecutionCallback<T> callback)
Submits a task to the specified member.<T> java.util.concurrent.Future<T>
submitToMember(java.util.concurrent.Callable<T> task, Member member)
Submits a task to the specified member and returns a Future representing that task.<T> void
submitToMember(java.util.concurrent.Callable<T> task, Member member, ExecutionCallback<T> callback)
Submits a task to the specified member.void
submitToMembers(java.lang.Runnable task, MemberSelector memberSelector, MultiExecutionCallback callback)
Submits task to the selected members.void
submitToMembers(java.lang.Runnable task, java.util.Collection<Member> members, MultiExecutionCallback callback)
Submits a task to the specified members.<T> java.util.Map<Member,java.util.concurrent.Future<T>>
submitToMembers(java.util.concurrent.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(java.util.concurrent.Callable<T> task, MemberSelector memberSelector, MultiExecutionCallback callback)
Submits task to the selected members.<T> java.util.Map<Member,java.util.concurrent.Future<T>>
submitToMembers(java.util.concurrent.Callable<T> task, java.util.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(java.util.concurrent.Callable<T> task, java.util.Collection<Member> members, MultiExecutionCallback callback)
Submits a task to the specified members.-
Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getDestroyContextForTenant, getName, getPartitionKey, getServiceName
-
-
-
-
Method Detail
-
execute
void execute(@Nonnull java.lang.Runnable command, @Nonnull MemberSelector memberSelector)
Executes a task on a randomly selected member.- Parameters:
command
- the task that is executed on a randomly selected membermemberSelector
- memberSelector- Throws:
java.util.concurrent.RejectedExecutionException
- if no member is selected
-
executeOnKeyOwner
void executeOnKeyOwner(@Nonnull java.lang.Runnable command, @Nonnull java.lang.Object key)
Executes a task on the owner of the specified key.- Parameters:
command
- a task executed on the owner of the specified keykey
- the specified key
-
executeOnMember
void executeOnMember(@Nonnull java.lang.Runnable command, @Nonnull Member member)
Executes a task on the specified member.- Parameters:
command
- the task executed on the specified membermember
- the specified member
-
executeOnMembers
void executeOnMembers(@Nonnull java.lang.Runnable command, @Nonnull java.util.Collection<Member> members)
Executes a task on each of the specified members.- Parameters:
command
- the task executed on the specified membersmembers
- the specified members
-
executeOnMembers
void executeOnMembers(@Nonnull java.lang.Runnable command, @Nonnull MemberSelector memberSelector)
Executes a task on each of the selected members.- Parameters:
command
- a task executed on each of the selected membersmemberSelector
- memberSelector- Throws:
java.util.concurrent.RejectedExecutionException
- if no member is selected
-
executeOnAllMembers
void executeOnAllMembers(@Nonnull java.lang.Runnable command)
Executes a task on all of the known cluster members.- Parameters:
command
- a task executed on all of the known cluster members
-
submit
<T> java.util.concurrent.Future<T> submit(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull MemberSelector memberSelector)
Submits a task to a randomly selected member and returns a Future representing that task.- Type Parameters:
T
- the result type of callable- Parameters:
task
- task submitted to a randomly selected membermemberSelector
- memberSelector- Returns:
- a Future representing pending completion of the task
- Throws:
java.util.concurrent.RejectedExecutionException
- if no member is selected
-
submitToKeyOwner
<T> java.util.concurrent.Future<T> submitToKeyOwner(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull java.lang.Object key)
Submits a task to the owner of the specified key and returns a Future representing that task.- Type Parameters:
T
- the result type of callable- Parameters:
task
- task submitted to the owner of the specified keykey
- the specified key- Returns:
- a Future representing pending completion of the task
-
submitToMember
<T> java.util.concurrent.Future<T> submitToMember(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull Member member)
Submits a task to the specified member and returns a Future representing that task.- Type Parameters:
T
- the result type of callable- Parameters:
task
- the task submitted to the specified membermember
- the specified member- Returns:
- a Future representing pending completion of the task
-
submitToMembers
<T> java.util.Map<Member,java.util.concurrent.Future<T>> submitToMembers(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull java.util.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- Type Parameters:
T
- the result type of callable- Parameters:
task
- the task submitted to given membersmembers
- the given members- Returns:
- map of Member-Future pairs representing pending completion of the task on each member
-
submitToMembers
<T> java.util.Map<Member,java.util.concurrent.Future<T>> submitToMembers(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull 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.- Type Parameters:
T
- the result type of callable- Parameters:
task
- the task submitted to selected membersmemberSelector
- memberSelector- Returns:
- map of Member-Future pairs representing pending completion of the task on each member
- Throws:
java.util.concurrent.RejectedExecutionException
- if no member is selected
-
submitToAllMembers
<T> java.util.Map<Member,java.util.concurrent.Future<T>> submitToAllMembers(@Nonnull java.util.concurrent.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.- Type Parameters:
T
- the result type of callable- 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
<T> void submit(@Nonnull java.lang.Runnable task, @Nullable ExecutionCallback<T> callback)
Submits a task to a random member. Caller will be notified of the result of the task byExecutionCallback.onResponse(Object)
orExecutionCallback.onFailure(Throwable)
.- Type Parameters:
T
- the response type of callback- Parameters:
task
- a task submitted to a random membercallback
- callback
-
submit
<T> void submit(@Nonnull java.lang.Runnable task, @Nonnull MemberSelector memberSelector, @Nullable ExecutionCallback<T> callback)
Submits a task to randomly selected members. Caller will be notified for the result of the task byExecutionCallback.onResponse(Object)
orExecutionCallback.onFailure(Throwable)
.- Type Parameters:
T
- the response type of callback- Parameters:
task
- the task submitted to randomly selected membersmemberSelector
- memberSelectorcallback
- callback- Throws:
java.util.concurrent.RejectedExecutionException
- if no member is selected
-
submitToKeyOwner
<T> void submitToKeyOwner(@Nonnull java.lang.Runnable task, @Nonnull java.lang.Object key, @Nonnull ExecutionCallback<T> callback)
Submits a task to the owner of the specified key. Caller will be notified for the result of the task byExecutionCallback.onResponse(Object)
orExecutionCallback.onFailure(Throwable)
.- Type Parameters:
T
- the response type of callback- Parameters:
task
- task submitted to the owner of the specified keykey
- the specified keycallback
- callback
-
submitToMember
<T> void submitToMember(@Nonnull java.lang.Runnable task, @Nonnull Member member, @Nullable ExecutionCallback<T> callback)
Submits a task to the specified member. Caller will be notified for the result of the task byExecutionCallback.onResponse(Object)
orExecutionCallback.onFailure(Throwable)
.- Type Parameters:
T
- the response type of callback- Parameters:
task
- the task submitted to the specified membermember
- the specified membercallback
- callback
-
submitToMembers
void submitToMembers(@Nonnull java.lang.Runnable task, @Nonnull java.util.Collection<Member> members, @Nonnull MultiExecutionCallback callback)
Submits a task to the specified members. Caller will be notified for the result of the each task byMultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,MultiExecutionCallback.onComplete(java.util.Map)
will be called.- Parameters:
task
- the task submitted to the specified membersmembers
- the specified memberscallback
- callback
-
submitToMembers
void submitToMembers(@Nonnull java.lang.Runnable task, @Nonnull MemberSelector memberSelector, @Nonnull MultiExecutionCallback callback)
Submits task to the selected members. Caller will be notified for the result of the each task byMultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,MultiExecutionCallback.onComplete(java.util.Map)
will be called.- Parameters:
task
- the task submitted to the selected membersmemberSelector
- memberSelectorcallback
- callback- Throws:
java.util.concurrent.RejectedExecutionException
- if no member is selected
-
submitToAllMembers
void submitToAllMembers(@Nonnull java.lang.Runnable task, @Nonnull MultiExecutionCallback callback)
Submits task to all the cluster members. Caller will be notified for the result of each task byMultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,MultiExecutionCallback.onComplete(java.util.Map)
will be called.- Parameters:
task
- the task submitted to all the cluster memberscallback
- callback
-
submit
<T> void submit(@Nonnull java.util.concurrent.Callable<T> task, @Nullable ExecutionCallback<T> callback)
Submits a task to a random member. Caller will be notified for the result of the task byExecutionCallback.onResponse(Object)
orExecutionCallback.onFailure(Throwable)
.- Type Parameters:
T
- the result type of callable- Parameters:
task
- the task submitted to a random membercallback
- callback
-
submit
<T> void submit(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull MemberSelector memberSelector, @Nullable ExecutionCallback<T> callback)
Submits task to a randomly selected member. Caller will be notified for the result of the task byExecutionCallback.onResponse(Object)
orExecutionCallback.onFailure(Throwable)
.- Type Parameters:
T
- the result type of callable- Parameters:
task
- the task submitted to a randomly selected membermemberSelector
- memberSelectorcallback
- callback- Throws:
java.util.concurrent.RejectedExecutionException
- if no member is selected
-
submitToKeyOwner
<T> void submitToKeyOwner(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull java.lang.Object key, @Nullable ExecutionCallback<T> callback)
Submits task to the owner of the specified key. Caller will be notified for the result of the task byExecutionCallback.onResponse(Object)
orExecutionCallback.onFailure(Throwable)
.- Type Parameters:
T
- the result type of callable- Parameters:
task
- the task submitted to the owner of the specified keykey
- the specified keycallback
- callback
-
submitToMember
<T> void submitToMember(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull Member member, @Nullable ExecutionCallback<T> callback)
Submits a task to the specified member. Caller will be notified for the result of the task byExecutionCallback.onResponse(Object)
orExecutionCallback.onFailure(Throwable)
.- Type Parameters:
T
- the result type of callable- Parameters:
task
- the task submitted to the specified membermember
- the specified membercallback
- callback
-
submitToMembers
<T> void submitToMembers(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull java.util.Collection<Member> members, @Nonnull MultiExecutionCallback callback)
Submits a task to the specified members. Caller will be notified for the result of each task byMultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,MultiExecutionCallback.onComplete(java.util.Map)
will be called.- Type Parameters:
T
- the result type of callable- Parameters:
task
- the task submitted to the specified membersmembers
- the specified memberscallback
- callback
-
submitToMembers
<T> void submitToMembers(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull MemberSelector memberSelector, @Nonnull MultiExecutionCallback callback)
Submits task to the selected members. Caller will be notified for the result of each task byMultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,MultiExecutionCallback.onComplete(java.util.Map)
will be called.- Type Parameters:
T
- the result type of callable- Parameters:
task
- the task submitted to the selected membersmemberSelector
- memberSelectorcallback
- callback- Throws:
java.util.concurrent.RejectedExecutionException
- if no member is selected
-
submitToAllMembers
<T> void submitToAllMembers(@Nonnull java.util.concurrent.Callable<T> task, @Nonnull MultiExecutionCallback callback)
Submits task to all the cluster members. Caller will be notified for the result of the each task byMultiExecutionCallback.onResponse(Member, Object)
, and when all tasks are completed,MultiExecutionCallback.onComplete(java.util.Map)
will be called.- Type Parameters:
T
- the result type of callable- Parameters:
task
- the task submitted to all the cluster memberscallback
- callback
-
getLocalExecutorStats
LocalExecutorStats getLocalExecutorStats()
Returns local statistics related to this executor service.- Returns:
- local statistics related to this executor service
-
-