From 763640e8f9698113b2c001a71a718eecb60ac30c Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 03 Jul 2014 15:19:12 +0000
Subject: [PATCH] OPENDJ-1453 (CR-3938) Replica offline messages should be synced with updates
---
opendj-sdk/opends/src/server/org/opends/server/replication/server/ServerWriter.java | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ServerWriter.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ServerWriter.java
index 1de2e40..e807306 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ServerWriter.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ServerWriter.java
@@ -32,8 +32,10 @@
import org.opends.server.api.DirectoryThread;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.replication.common.ServerStatus;
+import org.opends.server.replication.protocol.ReplicaOfflineMsg;
import org.opends.server.replication.protocol.Session;
import org.opends.server.replication.protocol.UpdateMsg;
+import org.opends.server.replication.service.DSRSShutdownSync;
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.loggers.ErrorLogger.*;
@@ -55,8 +57,7 @@
private final Session session;
private final ServerHandler handler;
private final ReplicationServerDomain replicationServerDomain;
-
-
+ private final DSRSShutdownSync dsrsShutdownSync;
/**
* Create a ServerWriter. Then ServerWriter then waits on the ServerHandler
@@ -68,9 +69,11 @@
* handler for which the ServerWriter is created.
* @param replicationServerDomain
* The ReplicationServerDomain of this ServerWriter.
+ * @param dsrsShutdownSync Synchronization object for shutdown of combined DS/RS instances.
*/
public ServerWriter(Session session, ServerHandler handler,
- ReplicationServerDomain replicationServerDomain)
+ ReplicationServerDomain replicationServerDomain,
+ DSRSShutdownSync dsrsShutdownSync)
{
// Session may be null for ECLServerWriter.
super("Replication server RS(" + handler.getReplicationServerId()
@@ -80,6 +83,7 @@
this.session = session;
this.handler = handler;
this.replicationServerDomain = replicationServerDomain;
+ this.dsrsShutdownSync = dsrsShutdownSync;
}
/**
@@ -98,7 +102,9 @@
Message errMessage = null;
try
{
- while (true)
+ boolean shutdown = false;
+ while (!shutdown
+ || !dsrsShutdownSync.canShutdown(replicationServerDomain.getBaseDN()))
{
final UpdateMsg updateMsg = replicationServerDomain.take(this.handler);
if (updateMsg == null)
@@ -106,12 +112,16 @@
// this connection is closing
errMessage = Message.raw(
"Connection closure: null update returned by domain.");
- return;
+ shutdown = true;
}
else if (!isUpdateMsgFiltered(updateMsg))
{
// Publish the update to the remote server using a protocol version it supports
session.publish(updateMsg);
+ if (updateMsg instanceof ReplicaOfflineMsg)
+ {
+ dsrsShutdownSync.replicaOfflineMsgForwarded(replicationServerDomain.getBaseDN());
+ }
}
}
}
--
Gitblit v1.10.0