From 27328d01b7e1ec22316d62de94b1788f3a83c11f Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 04 Oct 2013 12:46:34 +0000
Subject: [PATCH] OPENDJ-1116 Introduce abstraction for the changelog DB
---
opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java | 39 +++++++++++++++++++--------------------
1 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
index 9c9e6c5..ae79eba 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -1307,14 +1307,13 @@
/**
* Count the number of changes in the replication changelog for the provided
* serverID, between 2 provided CSNs.
- * @param serverId Identifier of the server for which to compute the count.
* @param from lower limit CSN.
* @param to upper limit CSN.
* @return the number of changes.
*/
- public long getCount(int serverId, CSN from, CSN to)
+ public long getCount(CSN from, CSN to)
{
- return domainDB.getCount(baseDN, serverId, from, to);
+ return domainDB.getCount(baseDN, from.getServerId(), from, to);
}
/**
@@ -2593,9 +2592,8 @@
if (eligibleCSN != null)
{
- for (int serverId : latestState)
+ for (CSN mostRecentDbCSN : latestState)
{
- CSN mostRecentDbCSN = latestState.getCSN(serverId);
try {
// Is the most recent change in the Db newer than eligible CSN ?
// if yes (like csn15 in the example above, then we have to go back
@@ -2603,9 +2601,12 @@
if (eligibleCSN.olderOrEqual(mostRecentDbCSN))
{
// let's try to seek the first change <= eligibleCSN
- CSN newCSN = domainDB.getCSNAfter(baseDN, serverId, eligibleCSN);
+ CSN newCSN = domainDB.getCSNAfter(baseDN,
+ mostRecentDbCSN.getServerId(), eligibleCSN);
result.update(newCSN);
- } else {
+ }
+ else
+ {
// for this serverId, all changes in the ChangelogDb are holder
// than eligibleCSN, the most recent in the db is our guy.
result.update(mostRecentDbCSN);
@@ -2653,14 +2654,11 @@
CSN eligibleCSN = null;
final ServerState newestCSNs = domainDB.getDomainNewestCSNs(baseDN);
- for (final int serverId : newestCSNs)
+ for (final CSN changelogNewestCSN : newestCSNs)
{
- // Consider this producer (DS/db).
- final CSN changelogNewestCSN = newestCSNs.getCSN(serverId);
-
// Should it be considered for eligibility ?
- CSN heartbeatLastCSN =
- getChangeTimeHeartbeatState().getCSN(serverId);
+ int serverId = changelogNewestCSN.getServerId();
+ CSN heartbeatLastCSN = getChangeTimeHeartbeatState().getCSN(serverId);
// If the most recent UpdateMsg or CLHeartbeatMsg received is very old
// then the domain is considered down and not considered for eligibility
@@ -2804,10 +2802,9 @@
{
long res = 0;
- for (int serverId : getLatestServerState())
+ for (CSN startCSN : getLatestServerState())
{
- CSN startCSN = startState.getCSN(serverId);
- long serverIdRes = getCount(serverId, startCSN, endCSN);
+ long serverIdRes = getCount(startCSN, endCSN);
// The startPoint is excluded when counting the ECL eligible changes
if (startCSN != null && serverIdRes > 0)
@@ -2831,10 +2828,12 @@
public long getEligibleCount(CSN startCSN, CSN endCSN)
{
long res = 0;
- for (int serverId : getLatestServerState()) {
- CSN lStartCSN =
- new CSN(startCSN.getTime(), startCSN.getSeqnum(), serverId);
- res += getCount(serverId, lStartCSN, endCSN);
+ for (CSN csn : getLatestServerState())
+ {
+ int serverId = csn.getServerId();
+ CSN lStartCSN = new CSN(startCSN.getTime(), startCSN.getSeqnum(),
+ serverId);
+ res += getCount(lStartCSN, endCSN);
}
return res;
}
--
Gitblit v1.10.0