Iterator<Integer> lsiStateItr = this.LDAPStates.keySet().iterator();
while (lsiStateItr.hasNext())
{
Integer lsiSid = lsiStateItr.next();
ServerState lsiState = this.LDAPStates.get(lsiSid);
Long lsiMissingChanges = (long)0;
if (lsiState != null)
{
Iterator<Integer> lsjMaxItr = this.maxCNs.keySet().iterator();
while (lsjMaxItr.hasNext())
{
Integer lsjSid = lsjMaxItr.next();
ChangeNumber lsjMaxCN = this.maxCNs.get(lsjSid);
ChangeNumber lsiLastCN = lsiState.getMaxChangeNumber(lsjSid);
int missingChangesLsiLsj =
ChangeNumber.diffSeqNum(lsjMaxCN, lsiLastCN);
mds +=
"+ diff("+lsjMaxCN+"-"
+lsiLastCN+")="+missingChangesLsiLsj;
// Regarding a DS that is generating changes. If it is a local DS1,
// we get its server state, store it, then retrieve server states of
// remote DSs. When a remote server state is coming, it may contain
// a change number for DS1 which is newer than the one we locally
// stored in the server state of DS1. To prevent seeing DS1 has
// missing changes whereas it is wrong, we replace the value with 0
// if it is a low value. We cannot overwrite big values as they may be
// useful for a local server retrieving changes it generated earlier,
// when it is recovering from an old snapshot and the local RS is
// sending him the changes it is missing.
if (lsjSid.equals(lsiSid)) {
if (missingChangesLsiLsj <= 50)
{
missingChangesLsiLsj = 0;
mds += " (diff replaced by 0 as for server id " + lsiSid + ")";
}
}
lsiMissingChanges += missingChangesLsiLsj;
}
}
mds += "=" + lsiMissingChanges;
this.missingChanges.put(lsiSid,lsiMissingChanges);
}
// Computes the missing changes counters for RS :
// Sum the difference of sequence numbers for each element in the States.
for (int lsiSid : RSStates.keySet())
{
ServerState lsiState = this.RSStates.get(lsiSid);
Long lsiMissingChanges = (long)0;
if (lsiState != null)
{
Iterator<Integer> lsjMaxItr = this.maxCNs.keySet().iterator();
while (lsjMaxItr.hasNext())
{
int lsjSid = lsjMaxItr.next();
ChangeNumber lsjMaxCN = this.maxCNs.get(lsjSid);
ChangeNumber lsiLastCN = lsiState.getMaxChangeNumber(lsjSid);
int missingChangesLsiLsj =
ChangeNumber.diffSeqNum(lsjMaxCN, lsiLastCN);
mds +=