java.lang.Object
java.util.AbstractCollection<CSN>
org.forgerock.opendj.server.leaderbasedreplication.ReplicaState
All Implemented Interfaces:
Iterable<CSN>, Collection<CSN>

public final class ReplicaState extends AbstractCollection<CSN>
The replication state of a replica. The state is defined as a list of StreamIds.
  • Constructor Details

    • ReplicaState

      public ReplicaState()
      Creates a new empty ReplicaState.
    • ReplicaState

      public ReplicaState(ReplicaState state)
      Creates a new ReplicaState with the provided state.
      Parameters:
      state - the state
  • Method Details

    • get

      public CSN get(StreamId streamId)
      Returns the CSN associated with the provided StreamId.
      Parameters:
      streamId - the streamId
      Returns:
      the CSN associated with the provided StreamId
    • isEmpty

      public boolean isEmpty()
      Returns if the streamId is empty.
      Specified by:
      isEmpty in interface Collection<CSN>
      Overrides:
      isEmpty in class AbstractCollection<CSN>
      Returns:
      if the streamId is empty
    • iterator

      public Iterator<CSN> iterator()
      Specified by:
      iterator in interface Collection<CSN>
      Specified by:
      iterator in interface Iterable<CSN>
      Specified by:
      iterator in class AbstractCollection<CSN>
    • streamIds

      public Set<StreamId> streamIds()
      Returns the StreamIds in the state.
      Returns:
      the StreamIds in the state
    • size

      public int size()
      Specified by:
      size in interface Collection<CSN>
      Specified by:
      size in class AbstractCollection<CSN>
    • put

      public void put(CSN csn)
      Adds a StreamId starting with the provided CSN to the state.
      Parameters:
      csn - the CSN starting the Stream
    • putIfMoreRecent

      public void putIfMoreRecent(ReplicaState another)
      Updates the current state with all the StreamIds from the provided state.
      Parameters:
      another - the state to update from
    • putIfMoreRecent

      public boolean putIfMoreRecent(CSN csn)
      Updates the current state with the provided CSN, creating the StreamId if necessary.
      Parameters:
      csn - the update CSN
      Returns:
      if the StreamId was updated
    • getStreamsByReplicaId

      public Map<ReplicaId,SortedSet<StreamId>> getStreamsByReplicaId()
      Returns the StreamIds for each replica.
      Returns:
      the StreamIds for each replica
    • toJson

      public JsonValue toJson()
      Returns the JSON representation of this ReplicaState.
      Returns:
      the JSON representation of this ReplicaState
    • toJsonSimplified

      public JsonValue toJsonSimplified(Topology.DomainState domainState)
      Returns the simplified JSON representation of this ReplicaState.
      Parameters:
      domainState - the domain state
      Returns:
      the simplified JSON representation of this ReplicaState
    • fromJson

      public static ReplicaState fromJson(String value)
      Returns a ReplicaState from the provided JSON representation.
      Parameters:
      value - the JSON string representation of the ReplicaState
      Returns:
      a ReplicaState from the provided JSON representation
    • toString

      public String toString()
      Overrides:
      toString in class AbstractCollection<CSN>
    • prettyPrint

      public String prettyPrint()
      Returns a pretty-printed string representation of this ReplicaState.
      Returns:
      a pretty-printed string representation of this ReplicaState
    • retainOldestCsns

      public void retainOldestCsns(ReplicaState other)
      Update this ServerState with the oldest CSN for each replica versus the provided ServerState. If a replica is not present in the other ServerState, it will be removed from this ServerState.
      Parameters:
      other - The other ServerState
    • purge

      public void purge(CSN purgeCsn, ReplicaId callingReplicaId)
      Purge the state by deleting streams (excepting the newest for each replica) which have an older CSN than the provided CSN.
      Parameters:
      purgeCsn - the CSN to purge from
      callingReplicaId - the replica calling the purge