Interface CommandDispatcher<M extends GroupMember,C>
- Type Parameters:
M- the member typeC- the command context type
- All Superinterfaces:
AutoCloseable
Dispatches commands for execution on members of a group.
- Author:
- Paul Ferraro
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()default <R,E extends Exception>
Map<M,CompletionStage<R>> dispatchToGroup(Command<R, ? super C, E> command) Executes the specified command on all members of the group, optionally excluding some members.<R,E extends Exception>
Map<M,CompletionStage<R>> dispatchToGroup(Command<R, ? super C, E> command, Set<M> excluding) Executes the specified command on all members of the group, optionally excluding some members.<R,E extends Exception>
CompletionStage<R>dispatchToMember(Command<R, ? super C, E> command, M member) Executes the specified command on the specified group member.Returns the context with which this dispatcher was created.
-
Method Details
-
getContext
C getContext()Returns the context with which this dispatcher was created.- Returns:
- a command execution context
-
dispatchToMember
<R,E extends Exception> CompletionStage<R> dispatchToMember(Command<R, ? super C, throws IOExceptionE> command, M member) 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:
IOException- if the command could not be sent
-
dispatchToGroup
default <R,E extends Exception> Map<M,CompletionStage<R>> dispatchToGroup(Command<R, ? super C, throws IOExceptionE> command) 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 execute- Returns:
- a completion stage per member of the group on which the command was executed
- Throws:
IOException- if the command could not be sent
-
dispatchToGroup
<R,E extends Exception> Map<M,CompletionStage<R>> dispatchToGroup(Command<R, ? super C, throws IOExceptionE> command, Set<M> excluding) 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 executeexcluding- 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:
IOException- if the command could not be sent
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-