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/ECLServerWriter.java | 36 +++++++++++++++++++++---------------
1 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerWriter.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerWriter.java
index 97974ca..4d9bc65 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerWriter.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerWriter.java
@@ -35,6 +35,7 @@
import org.opends.server.replication.protocol.DoneMsg;
import org.opends.server.replication.protocol.ECLUpdateMsg;
import org.opends.server.replication.protocol.Session;
+import org.opends.server.replication.service.DSRSShutdownSync;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -50,7 +51,7 @@
* This class defines a server writer, which is used to send changes to a
* directory server.
*/
-public class ECLServerWriter extends ServerWriter
+class ECLServerWriter extends ServerWriter
{
/**
* The tracer object for the debug logger.
@@ -62,7 +63,7 @@
private final ReplicationServerDomain replicationServerDomain;
private boolean suspended;
private volatile boolean shutdown;
- private PersistentSearch mypsearch;
+ private final PersistentSearch mypsearch;
/**
* Create a ServerWriter.
@@ -72,10 +73,10 @@
* @param replicationServerDomain the ReplicationServerDomain of this
* ServerWriter.
*/
- public ECLServerWriter(Session session, ECLServerHandler handler,
+ ECLServerWriter(Session session, ECLServerHandler handler,
ReplicationServerDomain replicationServerDomain)
{
- super(session, handler, replicationServerDomain);
+ super(session, handler, replicationServerDomain, new DSRSShutdownSync());
setName("Replication ECL Writer Thread for operation " +
handler.getOperationId());
@@ -85,21 +86,26 @@
this.replicationServerDomain = replicationServerDomain;
this.suspended = false;
this.shutdown = false;
+ this.mypsearch = findPersistentSearch(handler);
+ }
- // Look for the psearch object related to this operation, the one that
- // will be notified with new entries to be returned.
- ECLWorkflowElement wfe =
- (ECLWorkflowElement) DirectoryServer
- .getWorkflowElement(ECLWorkflowElement.ECL_WORKFLOW_ELEMENT);
+ /**
+ * Look for the persistent search object related to this operation, the one
+ * that will be notified with new entries to be returned.
+ */
+ private PersistentSearch findPersistentSearch(ECLServerHandler handler)
+ {
+ ECLWorkflowElement wfe = (ECLWorkflowElement)
+ DirectoryServer.getWorkflowElement(ECLWorkflowElement.ECL_WORKFLOW_ELEMENT);
for (PersistentSearch psearch : wfe.getPersistentSearches())
{
if (psearch.getSearchOperation().toString().equals(
handler.getOperationId()))
{
- mypsearch = psearch;
- break;
+ return psearch;
}
}
+ return null;
}
/**
@@ -107,7 +113,7 @@
* waiting for the startCLSessionMsg. Then it may be
* suspended between 2 jobs, each job being a separate search.
*/
- public synchronized void suspendWriter()
+ private synchronized void suspendWriter()
{
suspended = true;
}
@@ -115,7 +121,7 @@
/**
* Resume the writer.
*/
- public synchronized void resumeWriter()
+ synchronized void resumeWriter()
{
suspended = false;
notify();
@@ -187,7 +193,7 @@
* @throws IOException when raised (connection closure)
* @throws InterruptedException when raised
*/
- public void doIt() throws IOException, InterruptedException
+ private void doIt() throws IOException, InterruptedException
{
while (true)
{
@@ -237,7 +243,7 @@
/**
* Shutdown the writer.
*/
- public synchronized void shutdownWriter()
+ synchronized void shutdownWriter()
{
shutdown = true;
notify();
--
Gitblit v1.10.0