Class ServerState

java.lang.Object
org.opends.server.replication.common.ServerState
All Implemented Interfaces:
Iterable<CSN>

public final class ServerState extends Object implements Iterable<CSN>
This class is used to associate ReplicaIds with CSNs.

For example, it is exchanged with the replication servers at connection establishment time to communicate "which CSNs was last seen by a replicaId".

  • Constructor Details

    • ServerState

      public ServerState()
  • Method Details

    • clear

      public void clear()
      Empty the ServerState. After this call the Server State will be in the same state as if it was just created.
    • update

      public boolean update(CSN csn)
      Forward update the Server State with a CSN. The provided CSN will be put on the current object only if it is newer than the existing CSN for the same replicaId or if there is no existing CSN.
      Parameters:
      csn - The committed CSN.
      Returns:
      a boolean indicating if the update was meaningful.
    • removeCSN

      public boolean removeCSN(CSN expectedCSN)
      Removes the mapping to the provided CSN if it is present in this ServerState.
      Parameters:
      expectedCSN - the CSN to be removed
      Returns:
      true if the CSN could be removed, false otherwise.
    • getSnapshot

      public Set<CSN> getSnapshot()
      Returns a snapshot of this object.
      Returns:
      an unmodifiable List representing a snapshot of this object.
    • toString

      public String toString()
      Return the text representation of ServerState.
      Overrides:
      toString in class Object
      Returns:
      the text representation of ServerState
    • getCSN

      public CSN getCSN(ReplicaId replicaId)
      Returns the CSN contained in this server state which corresponds to the provided replica ID.
      Parameters:
      replicaId - The replica ID.
      Returns:
      The CSN contained in this server state which corresponds to the provided replica ID.
    • getReplicaIdToCSNMap

      public Map<ReplicaId,CSN> getReplicaIdToCSNMap()
      Returns a copy of this ServerState's content as a Map of replicaId to CSN.
      Returns:
      a copy of this ServerState's content as a Map of replicaId to CSN.
    • iterator

      public Iterator<CSN> iterator()
      Specified by:
      iterator in interface Iterable<CSN>
    • cover

      public boolean cover(ServerState covered)
      Check that all the CSNs in the covered serverState are also in this serverState.
      Parameters:
      covered - The ServerState that needs to be checked.
      Returns:
      A boolean indicating if this ServerState covers the ServerState given in parameter.
    • cover

      public boolean cover(CSN covered)
      Checks that the CSN given as a parameter is in this ServerState.
      Parameters:
      covered - The CSN that should be checked.
      Returns:
      A boolean indicating if this ServerState contains the CSN given in parameter.
    • isEmpty

      public boolean isEmpty()
      Tests if the state is empty.
      Returns:
      True if the state is empty.
    • duplicate

      public ServerState duplicate()
      Make a duplicate of this state.
      Returns:
      The duplicate of this state.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object