Interface Group<T extends NodeState>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void add​(GroupListener<T> listener)
      Registers a listener which will be called when the cluster membership changes or the group is connected or disconnected.
      void close()
      A member should be closed to release acquired resources used to monitor the group membership.
      T getLastState()
      Gets the last state.
      boolean isConnected()
      Are we connected with the cluster?
      boolean isMaster()
      Check if we are the master.
      T master()
      Retrieve the master node.
      Map<String,​T> members()
      Get the list of members connected to this group.
      void remove​(GroupListener<T> listener)
      Removes a previously added listener.
      List<T> slaves()
      Retrieve the list of slaves.
      void start()
      Start this member
      void update​(T state)
      Update the state of this group member.
    • Method Detail

      • isConnected

        boolean isConnected()
        Are we connected with the cluster?
      • start

        void start()
        Start this member
      • close

        void close()
            throws IOException
        A member should be closed to release acquired resources used to monitor the group membership. When the member is closed, any memberships registered via this Group will be removed from the group.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Throws:
        IOException
      • add

        void add​(GroupListener<T> listener)
        Registers a listener which will be called when the cluster membership changes or the group is connected or disconnected.
      • remove

        void remove​(GroupListener<T> listener)
        Removes a previously added listener.
      • update

        void update​(T state)
        Update the state of this group member. If the state is null, the member will leave the group. This method can be called even if the group is not started, in which case the state will be stored and updated when the group becomes started.
        Parameters:
        state - the new state of this group member
      • members

        Map<String,​T> members()
        Get the list of members connected to this group.
      • isMaster

        boolean isMaster()
        Check if we are the master.
      • master

        T master()
        Retrieve the master node.
      • slaves

        List<T> slaves()
        Retrieve the list of slaves.
      • getLastState

        T getLastState()
        Gets the last state.

        This can be used by clients to access that last state, such as when the clients is being added as a listener but wants to retrieve the last state to be up to date when the client is added.

        Returns:
        the state, or null if no last state yet.