Class MultiDomainServerState
- java.lang.Object
-
- org.opends.server.replication.common.MultiDomainServerState
-
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 Summary
Constructors Constructor Description MultiDomainServerState()Creates a new empty object.MultiDomainServerState(String cookie)Create an object from a string representation.MultiDomainServerState(MultiDomainServerState cookie)Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Empty the object..booleancover(DN baseDN, CSN csn)Test if this object covers the provided CSN for the provided baseDN.booleancover(MultiDomainServerState covered)Test if this object covers the provided covered object.booleanequalsTo(MultiDomainServerState other)Test if this object equals the provided other object.CSNgetCSN(DN baseDN, int serverId)Returns the CSN associated to the provided replication domain's baseDN and serverId.org.forgerock.util.Pair<DN,CSN>getOldestCSNExcluding(MultiDomainServerState excludedCSNs)Returns the oldest Pair<DN, CSN> held in current object, excluding the provided CSNs.ServerStategetServerState(DN baseDN)Returns the ServerState associated to the provided replication domain's baseDN.Map<DN,List<CSN>>getSnapshot()Returns a snapshot of this object.booleanisEmpty()Tests if the state is empty.Iterator<DN>iterator()booleanremoveCSN(DN baseDN, CSN expectedCSN)Removes the mapping to the provided CSN if it is present in this MultiDomainServerState.voidreplace(DN baseDN, ServerState serverState)Replace the ServerState of the provided baseDN with the provided server state.StringtoString()Returns a string representation of this object.voidtoString(StringBuilder buffer)Dump a string representation in the provided buffer.booleanupdate(DN baseDN, CSN csn)Update the ServerState of the provided baseDN with the replicationCSNprovided.voidupdate(DN baseDN, ServerState serverState)Update the ServerState of the provided baseDN with the provided server state.voidupdate(MultiDomainServerState state)Update the current object with the provided multi domain server state.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
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 replicationCSNprovided.- 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.
-
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 baseDNserverId- 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.EMPTYif 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 baseDNexpectedCSN- 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.
-
-