From 6e14a8394d193af0fa32b83d3cc424787d41eadd Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 26 Jun 2014 13:19:57 +0000
Subject: [PATCH] OPENDJ-1453 (CR-3870) Replica offline messages should be synced with updates
---
opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java b/opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java
index 2a9d974..52b3f2f 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java
@@ -707,18 +707,39 @@
throws ChangelogException
{
final Set<Integer> serverIds = getDomainMap(baseDN).keySet();
+ final ChangelogState state = dbEnv.readChangelogState();
final Map<DBCursor<UpdateMsg>, Void> cursors = new HashMap<DBCursor<UpdateMsg>, Void>(serverIds.size());
for (int serverId : serverIds)
{
// get the last already sent CSN from that server to get a cursor
final CSN lastCSN = startAfterServerState != null ? startAfterServerState.getCSN(serverId) : null;
- cursors.put(getCursorFrom(baseDN, serverId, lastCSN), null);
+ final DBCursor<UpdateMsg> replicaDBCursor = getCursorFrom(baseDN, serverId, lastCSN);
+ final CSN offlineCSN = getOfflineCSN(state, baseDN, serverId, startAfterServerState);
+ cursors.put(new ReplicaOfflineCursor(replicaDBCursor, offlineCSN), null);
}
// recycle exhausted cursors,
// because client code will not manage the cursors itself
return new CompositeDBCursor<Void>(cursors, true);
}
+ private CSN getOfflineCSN(final ChangelogState state, DN baseDN, int serverId,
+ ServerState startAfterServerState)
+ {
+ final List<CSN> domain = state.getOfflineReplicas().get(baseDN);
+ if (domain != null)
+ {
+ for (CSN offlineCSN : domain)
+ {
+ if (serverId == offlineCSN.getServerId()
+ && !startAfterServerState.cover(offlineCSN))
+ {
+ return offlineCSN;
+ }
+ }
+ }
+ return null;
+ }
+
/** {@inheritDoc} */
@Override
public DBCursor<UpdateMsg> getCursorFrom(final DN baseDN, final int serverId, final CSN startAfterCSN)
--
Gitblit v1.10.0