From 9d89382aa31ab562458df1095f77cd081b64f66a Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Wed, 16 Sep 2009 10:26:07 +0000
Subject: [PATCH] Fix a regression introduced by fix for 4223 During the creation of a replicationServerDomain, wait for the replication server to connect to other replication servers only if the creation was initiated by a directory server.
---
opendj-sdk/opends/src/server/org/opends/server/replication/server/DataServerHandler.java | 2
opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServer.java | 44 ++++++++++++++++-----
opendj-sdk/opends/src/server/org/opends/server/replication/server/MessageHandler.java | 21 +++++++++-
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java | 2
opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java | 23 +++++------
5 files changed, 64 insertions(+), 28 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/DataServerHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/DataServerHandler.java
index 8a2fe99..1eda9a1 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/DataServerHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/DataServerHandler.java
@@ -475,7 +475,7 @@
processStartFromRemote(inServerStartMsg);
// Get or Create the ReplicationServerDomain
- replicationServerDomain = getDomain(true);
+ replicationServerDomain = getDomain(true, true);
localGenerationId = replicationServerDomain.getGenerationId();
oldGenerationId = localGenerationId;
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/MessageHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/MessageHandler.java
index c8395f8..9025357 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/MessageHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/MessageHandler.java
@@ -239,15 +239,32 @@
/**
* Returns the Replication Server Domain to which belongs this handler.
- * @param createIfNotExist Creates the domain if it does not exist.
+ *
+ * @param createIfNotExist Creates the domain if it does not exist.
+ *
* @return The replication server domain.
*/
public ReplicationServerDomain getDomain(boolean createIfNotExist)
{
+ return getDomain(createIfNotExist, false);
+ }
+
+ /**
+ * Returns the Replication Server Domain to which belongs this handler.
+ *
+ * @param createIfNotExist Creates the domain if it does not exist.
+ * @param waitConnections Waits for the Connections with other RS to
+ * be established before returning.
+ * @return The replication server domain.
+ */
+ public ReplicationServerDomain getDomain(
+ boolean createIfNotExist, boolean waitConnections)
+ {
if (replicationServerDomain==null)
{
replicationServerDomain =
- replicationServer.getReplicationServerDomain(serviceId,createIfNotExist);
+ replicationServer.getReplicationServerDomain(
+ serviceId, createIfNotExist, waitConnections);
}
return replicationServerDomain;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServer.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
index 9ccb5ca..8c3dcd5 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -687,6 +687,25 @@
public ReplicationServerDomain getReplicationServerDomain(String baseDn,
boolean create)
{
+ return getReplicationServerDomain(baseDn, create, false);
+ }
+
+ /**
+ * Get the ReplicationServerDomain associated to the base DN given in
+ * parameter.
+ *
+ * @param baseDn The base Dn for which the ReplicationServerDomain must be
+ * returned.
+ * @param create Specifies whether to create the ReplicationServerDomain if
+ * it does not already exist.
+ * @param waitConnections Waits for the Connections with other RS to
+ * be established before returning.
+ * @return The ReplicationServerDomain associated to the base DN given in
+ * parameter.
+ */
+ public ReplicationServerDomain getReplicationServerDomain(String baseDn,
+ boolean create, boolean waitConnections)
+ {
ReplicationServerDomain replicationServerDomain;
synchronized (baseDNs)
@@ -698,18 +717,21 @@
baseDNs.put(baseDn, replicationServerDomain);
synchronized (domainMonitor)
{
- synchronized (this)
+ if (waitConnections)
{
- // kick up the connect thread so that this new domain
- // gets connected to all the Replication Servers.
- this.notify();
- }
- try
- {
- // wait for the connect thread to signal that it finished its job
- domainMonitor.wait(500);
- } catch (InterruptedException e)
- {
+ synchronized (this)
+ {
+ // kick up the connect thread so that this new domain
+ // gets connected to all the Replication Servers.
+ this.notify();
+ }
+ try
+ {
+ // wait for the connect thread to signal that it finished its job
+ domainMonitor.wait(500);
+ } catch (InterruptedException e)
+ {
+ }
}
}
}
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 3e8dd62..5cc04e7 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
@@ -3061,24 +3061,21 @@
try
{
storeReceivedCTHeartbeat(msg.getChangeNumber());
-
- // If we are the first replication server warned,
- // then forwards the reset message to the remote replication servers
- for (ReplicationServerHandler rsHandler : replicationServers.values())
+ if (senderHandler.isDataServer())
{
- try
+ // If we are the first replication server warned,
+ // then forwards the reset message to the remote replication servers
+ for (ReplicationServerHandler rsHandler : replicationServers.values())
{
- // After we'll have sent the message , the remote RS will adopt
- // the new genId
- if (senderHandler.isDataServer())
+ try
{
rsHandler.send(msg);
+ } catch (IOException e)
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ logError(ERR_CHANGELOG_ERROR_SENDING_MSG.get(rsHandler.getName()));
+ stopServer(rsHandler);
}
- } catch (IOException e)
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- logError(ERR_CHANGELOG_ERROR_SENDING_MSG.get(rsHandler.getName()));
- stopServer(rsHandler);
}
}
}
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java
index 9016f5a..6ec1f80 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java
@@ -155,7 +155,7 @@
for (DSInfo serverInfo : domain1.getReplicasList())
{
if (serverInfo.getDsId() == domain2ServerId)
- assertTrue(serverInfo.getStatus() == ServerStatus.BAD_GEN_ID_STATUS);
+ assertEquals(serverInfo.getStatus(), ServerStatus.BAD_GEN_ID_STATUS);
else
{
assertTrue(serverInfo.getDsId() == domain1ServerId);
--
Gitblit v1.10.0