From 4a371f6717c50f5e327efeeaeeeccd3f82e1f5b0 Mon Sep 17 00:00:00 2001
From: Fabio Pistolesi <fabio.pistolesi@forgerock.com>
Date: Thu, 10 Dec 2015 10:38:32 +0000
Subject: [PATCH] Partial fix for OPENDJ-2190 Delete not replicated after 36h of add/delete operations on replicated topology

---
 opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/MultimasterReplication.java |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/MultimasterReplication.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/MultimasterReplication.java
index 3b9ecd6..3e66f86 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/MultimasterReplication.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/MultimasterReplication.java
@@ -81,6 +81,7 @@
 import org.opends.server.types.operation.PreOperationDeleteOperation;
 import org.opends.server.types.operation.PreOperationModifyDNOperation;
 import org.opends.server.types.operation.PreOperationModifyOperation;
+import org.opends.server.util.Platform;
 
 /**
  * This class is used to load the Replication code inside the JVM
@@ -277,7 +278,7 @@
     // number of replay threads is changed and apply changes.
     cfg.addReplicationChangeListener(this);
 
-    replayThreadNumber = cfg.getNumUpdateReplayThreads();
+    replayThreadNumber = getNumberOfReplayThreadsOrDefault(cfg);
     connectionTimeoutMS = (int) Math.min(cfg.getConnectionTimeout(), Integer.MAX_VALUE);
 
     //  Create the list of domains that are already defined.
@@ -303,6 +304,12 @@
         ReplicationRepairRequestControl.OID_REPLICATION_REPAIR_CONTROL);
   }
 
+  private int getNumberOfReplayThreadsOrDefault(ReplicationSynchronizationProviderCfg cfg)
+  {
+    Integer value = cfg.getNumUpdateReplayThreads();
+    return value == null ? Platform.computeNumberOfThreads(16, 1.5f) : value;
+  }
+
   /**
    * Create the threads that will wait for incoming update messages.
    */
@@ -780,16 +787,13 @@
     return true;
   }
 
-  /** {@inheritDoc} */
   @Override
-  public ConfigChangeResult applyConfigurationChange(
-      ReplicationSynchronizationProviderCfg configuration)
+  public ConfigChangeResult applyConfigurationChange(ReplicationSynchronizationProviderCfg configuration)
   {
-    int numUpdateRepayThread = configuration.getNumUpdateReplayThreads();
 
     // Stop threads then restart new number of threads
     stopReplayThreads();
-    replayThreadNumber = numUpdateRepayThread;
+    replayThreadNumber = getNumberOfReplayThreadsOrDefault(configuration);
     if (!domains.isEmpty())
     {
       createReplayThreads();

--
Gitblit v1.10.0