From 6a463421b18317cc8a4e4b4d32eb1ab4cb38cf79 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Thu, 05 Jul 2007 12:19:08 +0000
Subject: [PATCH] Fix for issue 1874, 1875

---
 opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationBroker.java |   12 ++++--
 opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java                |    7 ++-
 opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java |   62 ++++++++++++-------------------
 3 files changed, 37 insertions(+), 44 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java b/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java
index b07562b..5375b3c 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java
@@ -9263,8 +9263,11 @@
                     "None of the Directory Server backends are configured " +
                     "with the requested backend ID \"%s\"");
     registerMessage(MSGID_LDIFIMPORT_CANNOT_IMPORT,
-                    "The Directory Server backend with backend ID %s does " +
-                    "not provide a mechanism for performing LDIF imports");
+                    "The Directory Server backend for base DN %s does " +
+                    "not provide a mechanism for performing LDIF imports. " +
+                    "The replication will proceed but it will not be " +
+                    "possible to perform total update on this " +
+                    "ReplicationDomain");
     registerMessage(MSGID_LDIFIMPORT_CANNOT_DECODE_EXCLUDE_BASE,
                     "Unable to decode exclude branch string \"%s\" as a " +
                     "valid distinguished name:  %s");
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationBroker.java b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationBroker.java
index d87ef2e..c3a35a1 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationBroker.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationBroker.java
@@ -176,10 +176,8 @@
    * Start the ReplicationBroker.
    *
    * @param servers list of servers used
-   * @throws Exception : in case of errors
    */
   public void start(Collection<String> servers)
-                    throws Exception
   {
     /*
      * Open Socket to the ReplicationServer
@@ -207,7 +205,7 @@
    * @throws NumberFormatException address was invalid
    * @throws IOException error during connection phase
    */
-  private void connect() throws NumberFormatException, IOException
+  private void connect()
   {
     ReplServerStartMessage startMsg;
 
@@ -399,7 +397,13 @@
             {
               if (session != null)
               {
-                session.close();
+                try
+                {
+                  session.close();
+                } catch (IOException e)
+                {
+                  // The session was already closed, just ignore.
+                }
                 session = null;
               }
             }
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
index ac429e8..bf943ad 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
@@ -366,25 +366,22 @@
     /*
      * create the broker object used to publish and receive changes
      */
+    broker = new ReplicationBroker(state, baseDN, serverId, maxReceiveQueue,
+        maxReceiveDelay, maxSendQueue, maxSendDelay, window,
+        heartbeatInterval);
+
+    broker.start(replicationServers);
+
+    // Retrieves the related backend and its config entry
     try
     {
-      broker = new ReplicationBroker(state, baseDN, serverId, maxReceiveQueue,
-          maxReceiveDelay, maxSendQueue, maxSendDelay, window,
-          heartbeatInterval);
-      synchronized (broker)
-      {
-        broker.start(replicationServers);
-      }
-
-      // Retrieves the related backend and its config entry
       retrievesBackendInfos(baseDN);
-
-    } catch (Exception e)
+    } catch (DirectoryException e)
     {
-     /* TODO should mark that replicationServer service is
-      * not available, log an error and retry upon timeout
-      * should we stop the modifications ?
-      */
+      // The backend associated to this suffix is not able to
+      // perform export and import.
+      // The replication can continue but this replicationDomain
+      // won't be able to use total update.
     }
 
     /*
@@ -2076,18 +2073,8 @@
     state.loadState();
     disabled = false;
 
-    try
-    {
-      broker.start(replicationServers);
-    } catch (Exception e)
-    {
-      /* TODO should mark that replicationServer service is
-       * not available, log an error and retry upon timeout
-       * should we stop the modifications ?
-       */
-      e.printStackTrace();
-      return;
-    }
+    broker.start(replicationServers);
+
     createListeners();
   }
 
@@ -2394,23 +2381,22 @@
           ResultCode.OTHER, message, msgID, null);
     }
 
-    if (! domainBackend.supportsLDIFExport())
-    {
-      int    msgID   = MSGID_LDIFIMPORT_CANNOT_IMPORT;
-      String message = getMessage(msgID, domainBackend.getBackendID());
-      logError(ErrorLogCategory.BACKEND,
-          ErrorLogSeverity.SEVERE_ERROR, message, msgID);
-      throw new DirectoryException(
-          ResultCode.OTHER, message, msgID, null);
-    }
-
-
     this.backend = domainBackend;
     this.branches = new ArrayList<DN>(backendCfg.getBackendBaseDN().size());
     for (DN dn : backendCfg.getBackendBaseDN())
     {
       this.branches.add(dn);
     }
+
+    if (! domainBackend.supportsLDIFImport())
+    {
+      int    msgID   = MSGID_LDIFIMPORT_CANNOT_IMPORT;
+      String message = getMessage(msgID, baseDN);
+      logError(ErrorLogCategory.SYNCHRONIZATION,
+          ErrorLogSeverity.NOTICE, message, msgID);
+      throw new DirectoryException(
+          ResultCode.OTHER, message, msgID, null);
+    }
   }
 
 

--
Gitblit v1.10.0