Class DefaultRaftMember

java.lang.Object
io.atomix.raft.cluster.impl.DefaultRaftMember
All Implemented Interfaces:
RaftMember, AutoCloseable

public final class DefaultRaftMember extends Object implements RaftMember, AutoCloseable
Cluster member.
  • Constructor Details

  • Method Details

    • memberId

      public MemberId memberId()
      Description copied from interface: RaftMember
      Returns the member node ID.
      Specified by:
      memberId in interface RaftMember
      Returns:
      The member node ID.
    • hash

      public int hash()
      Description copied from interface: RaftMember
      Returns the member hash.
      Specified by:
      hash in interface RaftMember
      Returns:
      The member hash.
    • addTypeChangeListener

      public void addTypeChangeListener(Consumer<RaftMember.Type> listener)
      Description copied from interface: RaftMember
      Adds a listener to be called when the member's type changes.

      The type change callback will be called when the local server receives notification of the change in type to this member. Type changes may occur at different times from the perspective of different servers but are guaranteed to occur in the same order on all servers.

      Specified by:
      addTypeChangeListener in interface RaftMember
      Parameters:
      listener - The listener to be called when the member's type changes.
    • promote

      public CompletableFuture<Void> promote()
      Description copied from interface: RaftMember
      Promotes the member to the next highest type.

      If the member is promoted to RaftMember.Type.ACTIVE the Raft quorum size will increase.

      Specified by:
      promote in interface RaftMember
      Returns:
      A completable future to be completed once the member has been promoted.
    • promote

      public CompletableFuture<Void> promote(RaftMember.Type type)
      Description copied from interface: RaftMember
      Promotes the member to the given type.

      If the member is promoted to RaftMember.Type.ACTIVE the Raft quorum size will increase.

      Specified by:
      promote in interface RaftMember
      Parameters:
      type - The type to which to promote the member.
      Returns:
      A completable future to be completed once the member has been promoted.
    • demote

      public CompletableFuture<Void> demote()
      Description copied from interface: RaftMember
      Demotes the member to the next lowest type.

      If the member is an RaftMember.Type.ACTIVE member then demoting it will impact the Raft quorum size.

      Specified by:
      demote in interface RaftMember
      Returns:
      A completable future to be completed once the member has been demoted.
    • demote

      public CompletableFuture<Void> demote(RaftMember.Type type)
      Description copied from interface: RaftMember
      Demotes the member to the given type.

      If the member is an RaftMember.Type.ACTIVE member then demoting it will impact the Raft quorum size.

      Specified by:
      demote in interface RaftMember
      Parameters:
      type - The type to which to demote the member.
      Returns:
      A completable future to be completed once the member has been demoted.
    • remove

      public CompletableFuture<Void> remove()
      Description copied from interface: RaftMember
      Removes the member from the configuration.

      If the member is a part of the current Raft quorum (is an RaftMember.Type.ACTIVE member) then the quorum will be impacted by removing the member.

      Specified by:
      remove in interface RaftMember
      Returns:
      A completable future to be completed once the member has been removed from the configuration.
    • getLastUpdated

      public Instant getLastUpdated()
      Description copied from interface: RaftMember
      Returns the time at which the member was updated.

      The member update time is not guaranteed to be consistent across servers or consistent across server restarts. The update time is guaranteed to be monotonically increasing.

      Specified by:
      getLastUpdated in interface RaftMember
      Returns:
      The time at which the member was updated.
    • getType

      public RaftMember.Type getType()
      Description copied from interface: RaftMember
      Returns the member type.

      The member type is indicative of the member's level of participation in the Raft consensus algorithm and asynchronous replication within the cluster. Member types may change throughout the lifetime of the cluster. Types can be changed by promoting or demoting the member. Member types for a given member are guaranteed to change in the same order on all nodes, but the type of a member may be different from the perspective of different nodes at any given time.

      Specified by:
      getType in interface RaftMember
      Returns:
      The member type.
    • update

      public DefaultRaftMember update(RaftMember.Type type, Instant time)
      Updates the member type.
      Parameters:
      type - The member type.
      Returns:
      The member.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object