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/plugin/PendingChanges.java | 30 ++++++++++++++++++++++++++----
1 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/plugin/PendingChanges.java b/opends/src/server/org/opends/server/replication/plugin/PendingChanges.java
index 42ee696..834cf0c 100644
--- a/opends/src/server/org/opends/server/replication/plugin/PendingChanges.java
+++ b/opends/src/server/org/opends/server/replication/plugin/PendingChanges.java
@@ -33,6 +33,8 @@
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.common.CSNGenerator;
import org.opends.server.replication.protocol.LDAPUpdateMsg;
+import org.opends.server.replication.protocol.ReplicaOfflineMsg;
+import org.opends.server.replication.protocol.UpdateMsg;
import org.opends.server.replication.service.ReplicationDomain;
import org.opends.server.types.operation.PluginOperation;
@@ -136,6 +138,20 @@
}
/**
+ * Add a replica offline message to the pending list.
+ */
+ public synchronized void putReplicaOfflineMsg()
+ {
+ final CSN offlineCSN = csnGenerator.newCSN();
+ final PendingChange pendingChange =
+ new PendingChange(offlineCSN, null, new ReplicaOfflineMsg(offlineCSN));
+ pendingChange.setCommitted(true);
+
+ pendingChanges.put(offlineCSN, pendingChange);
+ pushCommittedChanges();
+ }
+
+ /**
* Push all committed local changes to the replicationServer service.
*/
synchronized void pushCommittedChanges()
@@ -152,20 +168,26 @@
while (firstChange != null && firstChange.isCommitted())
{
final PluginOperation op = firstChange.getOp();
- if (op != null && !op.isSynchronizationOperation())
+ final UpdateMsg msg = firstChange.getMsg();
+ if (msg instanceof LDAPUpdateMsg
+ && op != null
+ && !op.isSynchronizationOperation())
{
- final LDAPUpdateMsg updateMsg = firstChange.getMsg();
if (!recoveringOldChanges)
{
- domain.publish(updateMsg);
+ domain.publish(msg);
}
else
{
// do not push updates until the RS catches up.
// @see #setRecovering(boolean)
- domain.getServerState().update(updateMsg.getCSN());
+ domain.getServerState().update(msg.getCSN());
}
}
+ else if (msg instanceof ReplicaOfflineMsg)
+ {
+ domain.publish(msg);
+ }
// false warning: firstEntry will not be null if firstChange is not null
pendingChanges.remove(firstEntry.getKey());
--
Gitblit v1.10.0