Interface CommandDispatcher<M extends GroupMember,C>

Type Parameters:
C - the command context type
All Superinterfaces:
AutoCloseable, Registration

public interface CommandDispatcher<M extends GroupMember,C> extends Registration
Dispatches commands for execution on members of a group.
Author:
Paul Ferraro
  • 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,E> command, M member) throws IOException
      Executes the specified command on the specified group member. If the member has no corresponding dispatcher, the returned completion stage throws a CancellationException.
      Type Parameters:
      R - the command execution return type
      Parameters:
      command - the command to execute
      member - 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,E> command) throws IOException
      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 a CancellationException.
      Type Parameters:
      R - the command execution return type
      Parameters:
      command - the command to execute
      excludedMembers - 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
    • dispatchToGroup

      <R, E extends Exception> Map<M,CompletionStage<R>> dispatchToGroup(Command<R,? super C,E> command, Set<M> excluding) throws IOException
      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 a CancellationException.
      Type Parameters:
      R - the command execution return type
      Parameters:
      command - the command to execute
      excludedMembers - 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