Class MultiDomainServerState

  • All Implemented Interfaces:
    Iterable<DN>

    public class MultiDomainServerState
    extends Object
    implements Iterable<DN>
    This object is used to store a list of ServerState object, one by replication domain. Globally, it is the generalization of ServerState (that applies to one domain) to a list of domains.

    MultiDomainServerState is also known as "cookie" and is used with the cookie-based changelog.

    • Constructor Detail

      • MultiDomainServerState

        public MultiDomainServerState()
        Creates a new empty object.
      • MultiDomainServerState

        public MultiDomainServerState​(MultiDomainServerState cookie)
        Copy constructor.
        Parameters:
        cookie - the cookie to copy
      • MultiDomainServerState

        public MultiDomainServerState​(String cookie)
                               throws DirectoryException
        Create an object from a string representation.
        Parameters:
        cookie - The provided string representation of the state.
        Throws:
        DirectoryException - when the string has an invalid format
    • Method Detail

      • clear

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

        public boolean update​(DN baseDN,
                              CSN csn)
        Update the ServerState of the provided baseDN with the replication CSN provided.
        Parameters:
        baseDN - The provided baseDN.
        csn - The provided CSN.
        Returns:
        a boolean indicating if the update was meaningful.
      • update

        public void update​(DN baseDN,
                           ServerState serverState)
        Update the ServerState of the provided baseDN with the provided server state.
        Parameters:
        baseDN - The provided baseDN.
        serverState - The provided serverState.
      • replace

        public void replace​(DN baseDN,
                            ServerState serverState)
        Replace the ServerState of the provided baseDN with the provided server state. The provided server state will be owned by this instance, so care must be taken by calling code to duplicate it if needed.
        Parameters:
        baseDN - The provided baseDN.
        serverState - The provided serverState.
      • update

        public void update​(MultiDomainServerState state)
        Update the current object with the provided multi domain server state.
        Parameters:
        state - The provided multi domain server state.
      • getSnapshot

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

        public String toString()
        Returns a string representation of this object.
        Overrides:
        toString in class Object
        Returns:
        The string representation.
      • toString

        public void toString​(StringBuilder buffer)
        Dump a string representation in the provided buffer.
        Parameters:
        buffer - The provided buffer.
      • isEmpty

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

        public ServerState getServerState​(DN baseDN)
        Returns the ServerState associated to the provided replication domain's baseDN.
        Parameters:
        baseDN - the replication domain's baseDN
        Returns:
        the associated ServerState
      • getCSN

        public CSN getCSN​(DN baseDN,
                          int serverId)
        Returns the CSN associated to the provided replication domain's baseDN and serverId.
        Parameters:
        baseDN - the replication domain's baseDN
        serverId - the serverId
        Returns:
        the associated CSN
      • getOldestCSNExcluding

        public org.forgerock.util.Pair<DN,​CSN> getOldestCSNExcluding​(MultiDomainServerState excludedCSNs)
        Returns the oldest Pair<DN, CSN> held in current object, excluding the provided CSNs. Said otherwise, the value returned is the oldest Pair<DN, CSN> included in the current object, that is not part of the excludedCSNs.
        Parameters:
        excludedCSNs - the CSNs that cannot be returned
        Returns:
        the oldest Pair<DN, CSN> included in the current object that is not part of the excludedCSNs, or Pair.EMPTY if no such older CSN exists.
      • removeCSN

        public boolean removeCSN​(DN baseDN,
                                 CSN expectedCSN)
        Removes the mapping to the provided CSN if it is present in this MultiDomainServerState.
        Parameters:
        baseDN - the replication domain's baseDN
        expectedCSN - the CSN to be removed
        Returns:
        true if the CSN could be removed, false otherwise.
      • equalsTo

        public boolean equalsTo​(MultiDomainServerState other)
        Test if this object equals the provided other object.
        Parameters:
        other - The other object with which we want to test equality.
        Returns:
        Returns True if this equals other, else return false.
      • cover

        public boolean cover​(MultiDomainServerState covered)
        Test if this object covers the provided covered object.
        Parameters:
        covered - The provided object.
        Returns:
        true when this covers the provided object.
      • cover

        public boolean cover​(DN baseDN,
                             CSN csn)
        Test if this object covers the provided CSN for the provided baseDN.
        Parameters:
        baseDN - The provided baseDN.
        csn - The provided CSN.
        Returns:
        true when this object covers the provided CSN for the provided baseDN.