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/util/Platform.java |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/Platform.java b/opendj-server-legacy/src/main/java/org/opends/server/util/Platform.java
index 3d07de1..0a3c247 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/Platform.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/Platform.java
@@ -48,6 +48,7 @@
 import java.lang.reflect.Method;
 
 import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.util.Reject;
 
 import static org.opends.messages.UtilityMessages.*;
 import static org.opends.server.util.ServerConstants.CERTANDKEYGEN_PROVIDER;
@@ -609,4 +610,20 @@
   {
     return IMPL.getUsableMemoryForCaching();
   }
+
+  /**
+   * Computes the number of replay/worker/cleaner threads based on the number of cpus in the system.
+   * Allows for a multiplier to be specified and a minimum value to be returned if not enough processors
+   * are present in the system.
+   *
+   * @param minimumValue at least this value should be returned.
+   * @param cpuMultiplier the scaling multiplier of the number of threads to return
+   * @return the number of threads based on the number of cpus in the system.
+   * @throws IllegalArgumentException if {@code cpuMultiplier} is a non positive number
+   */
+  public static int computeNumberOfThreads(int minimumValue, float cpuMultiplier)
+  {
+    Reject.ifTrue(cpuMultiplier < 0, "Multiplier must be a positive number");
+    return Math.max(minimumValue, (int)(Runtime.getRuntime().availableProcessors() * cpuMultiplier));
+  }
 }

--
Gitblit v1.10.0