Record Class MemberState

java.lang.Object
java.lang.Record
io.camunda.zeebe.dynamic.config.state.MemberState
Record Components:
version - version of the state.
state - current state of the member
partitions - state of all partitions that the member is replicating

public record MemberState(long version, Instant lastUpdated, MemberState.State state, Map<Integer,PartitionState> partitions) extends Record
Represents the state of a member in the cluster.

Version is incremented every time the state is updated. This is used to resolve conflicts when the members receive gossip updates out of order. Only a member can update its own state. This prevents any conflicting concurrent updates.

  • Constructor Details

    • MemberState

      public MemberState(long version, Instant lastUpdated, MemberState.State state, Map<Integer,PartitionState> partitions)
      Creates an instance of a MemberState record class.
      Parameters:
      version - the value for the version record component
      lastUpdated - the value for the lastUpdated record component
      state - the value for the state record component
      partitions - the value for the partitions record component
  • Method Details

    • initializeAsActive

      public static MemberState initializeAsActive(Map<Integer,PartitionState> initialPartitions)
    • uninitialized

      public static MemberState uninitialized()
    • toJoining

      public MemberState toJoining()
    • toActive

      public MemberState toActive()
    • toLeaving

      public MemberState toLeaving()
    • toLeft

      public MemberState toLeft()
    • addPartition

      public MemberState addPartition(int partitionId, PartitionState partitionState)
    • updatePartition

      public MemberState updatePartition(int partitionId, UnaryOperator<PartitionState> partitionStateUpdater)
    • removePartition

      public MemberState removePartition(int partitionId)
    • hasPartition

      public boolean hasPartition(int partitionId)
    • getPartition

      public PartitionState getPartition(int partitionId)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • version

      public long version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • lastUpdated

      public Instant lastUpdated()
      Returns the value of the lastUpdated record component.
      Returns:
      the value of the lastUpdated record component
    • state

      public MemberState.State state()
      Returns the value of the state record component.
      Returns:
      the value of the state record component
    • partitions

      public Map<Integer,PartitionState> partitions()
      Returns the value of the partitions record component.
      Returns:
      the value of the partitions record component