Class ServerState
- java.lang.Object
-
- org.opends.server.replication.common.ServerState
-
-
Constructor Summary
Constructors Constructor Description ServerState()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Empty the ServerState.static int
countNbChanges(ServerState ss1, ServerState ss2)
Unreliably computes the number of changes a first server state has in advance compared to a second server state.boolean
cover(CSN covered)
Checks that the CSN given as a parameter is in this ServerState.boolean
cover(ServerState covered)
Check that all the CSNs in the covered serverState are also in this serverState.ServerState
duplicate()
Make a duplicate of this state.boolean
equals(Object obj)
CSN
getCSN(ReplicaId replicaId)
Returns theCSN
contained in this server state which corresponds to the provided replica ID.Map<ReplicaId,CSN>
getReplicaIdToCSNMap()
Returns a copy of this ServerState's content as a Map of replicaId to CSN.Set<CSN>
getSnapshot()
Returns a snapshot of this object.int
hashCode()
boolean
isEmpty()
Tests if the state is empty.Iterator<CSN>
iterator()
boolean
removeCSN(CSN expectedCSN)
Removes the mapping to the provided CSN if it is present in this ServerState.String
toString()
Return the text representation of ServerState.boolean
update(CSN csn)
Forward update the Server State with a CSN.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
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.
-
getCSN
public CSN getCSN(ReplicaId replicaId)
Returns theCSN
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.
-
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.
-
countNbChanges
public static int countNbChanges(ServerState ss1, ServerState ss2) throws IllegalArgumentException
Unreliably computes the number of changes a first server state has in advance compared to a second server state.Note: this method used to be more reliable for a single replication domain, i.e. until OPENDJ-4977. Before that, each replication domains had its own unique server id, and so the CSN could trivially follow a global ordering across domains. After OPENDJ-4977, a single server would have a single server id shared by all its replication domains, which means the sequence numbers are now incremented per server instead of per replication domains. The end result is that this {#countNbChanges} method can no longer give accurate results per replication domain, which implies a replica could now be "degraded" much faster, impacted by another replication domain that is a "noisy neighbour", independent of the number of changes that are happening in its replication domain.
Maybe dropping the DEGRADED status (based on this unreliable count) and replacing it by the LATE status (time-based) would be simpler.
- Parameters:
ss1
- The server state supposed to be newer than the second oness2
- The server state supposed to be older than the first one- Returns:
- The difference of changes (sum of the differences for each replica id changes). 0 If no gap between 2 states.
- Throws:
IllegalArgumentException
- If one of the passed state is null
-
-