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 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 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:
        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 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:
        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:
        close in interface AutoCloseable