From 15fb59f9fe10a2fc54867be9fc61446e93bc5896 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Mon, 14 Sep 2009 08:39:11 +0000
Subject: [PATCH] Fix for 4223 : dsreplication enable --noSchemaReplication fails: routing table is empty

---
 opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServer.java                              |   23 +++++++++++++++++++++++
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java |    5 ++++-
 2 files changed, 27 insertions(+), 1 deletions(-)

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 132de94..9ccb5ca 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
@@ -185,6 +185,9 @@
   ECLWorkflowElement eclwe;
   private static HashSet<Integer> localPorts = new HashSet<Integer>();
 
+  // used to synchronize the domain creation with the connect thread.
+  final private Object domainMonitor = new Object();
+
   /**
    * Creates a new Replication server using the provided configuration entry.
    *
@@ -436,6 +439,10 @@
       }
       try
       {
+        synchronized(domainMonitor)
+        {
+          domainMonitor.notifyAll();
+        }
         synchronized (this)
         {
           /* check if we are connected every second */
@@ -689,6 +696,22 @@
       {
         replicationServerDomain = new ReplicationServerDomain(baseDn, this);
         baseDNs.put(baseDn, replicationServerDomain);
+        synchronized (domainMonitor)
+        {
+          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/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 35bffae..9016f5a 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
@@ -107,9 +107,12 @@
       domain1 = new FakeReplicationDomain(
           testService, domain1ServerId, servers, 100, 1000, rcvQueue1);
 
+      ArrayList<String> servers2 = new ArrayList<String>(1);
+      servers2.add("localhost:" + replServerPort2);
+
       BlockingQueue<UpdateMsg> rcvQueue2 = new LinkedBlockingQueue<UpdateMsg>();
       domain2 = new FakeReplicationDomain(
-          testService, domain2ServerId, servers, 100, 1000, rcvQueue2);
+          testService, domain2ServerId, servers2, 100, 1000, rcvQueue2);
 
       /*
        * Publish a message from domain1,

--
Gitblit v1.10.0