Interface CommandDispatcher<C>
-
- Type Parameters:
C- the command context type
- All Superinterfaces:
AutoCloseable
public interface CommandDispatcher<C> extends AutoCloseable
Dispatches commands for execution on a group.- Author:
- Paul Ferraro
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Closes any resources used by this dispatcher.<R> Map<Node,CompletionStage<R>>executeOnGroup(Command<R,? super C> command, Node... excludedMembers)Executes the specified command on all members of the group, optionally excluding some members.<R> CompletionStage<R>executeOnMember(Command<R,? super C> command, Node member)Executes the specified command on the specified group member.CgetContext()Returns the context with which this dispatcher was created.
-
-
-
Method Detail
-
getContext
C getContext()
Returns the context with which this dispatcher was created.- Returns:
- a command execution context
-
executeOnMember
<R> CompletionStage<R> executeOnMember(Command<R,? super C> command, Node member) throws CommandDispatcherException
Executes the specified command on the specified group member. If the member has no corresponding dispatcher, the returned completion stage throws aCancellationException.- Type Parameters:
R- the command execution return type- Parameters:
command- the command to executemember- the group member on which to execute the command- Returns:
- the future result of the command execution
- Throws:
CommandDispatcherException- if the command could not be sent
-
executeOnGroup
<R> Map<Node,CompletionStage<R>> executeOnGroup(Command<R,? super C> command, Node... excludedMembers) throws CommandDispatcherException
Executes the specified command on all members of the group, optionally excluding some members. If a given member has no corresponding dispatcher, its completion stage throws aCancellationException.- Type Parameters:
R- the command execution return type- Parameters:
command- the command to executeexcludedMembers- the members to be excluded from group command execution- Returns:
- a completion stage per member of the group on which the command was executed
- Throws:
CommandDispatcherException- if the command could not be sent
-
close
void close()
Closes any resources used by this dispatcher. Once closed, a dispatcher can no longer execute commands.- Specified by:
closein interfaceAutoCloseable
-
-