From 134f26626acf0f76f0e999875f3c5a90c7b16034 Mon Sep 17 00:00:00 2001
From: Yannick Lecaillez <yannick.lecaillez@forgerock.com>
Date: Thu, 30 Jun 2016 08:47:04 +0000
Subject: [PATCH] OPENDJ-3171: rebuild-index/importer are killed on low-memory configuration.

---
 opendj-server-legacy/src/main/java/org/opends/server/util/Platform.java |   91 ---------------------------------------------
 1 files changed, 0 insertions(+), 91 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 8f6d878..ce0c8a2 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
@@ -25,14 +25,10 @@
 import java.security.cert.Certificate;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
-import java.util.List;
 
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryPoolMXBean;
-import java.lang.management.MemoryUsage;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 
@@ -411,65 +407,6 @@
     {
       return cert.getSubjectDN().equals(cert.getIssuerDN());
     }
-
-
-
-    private long getUsableMemoryForCaching()
-    {
-      long youngGenSize = 0;
-      long oldGenSize = 0;
-
-      List<MemoryPoolMXBean> mpools = ManagementFactory.getMemoryPoolMXBeans();
-      for (MemoryPoolMXBean mpool : mpools)
-      {
-        MemoryUsage usage = mpool.getUsage();
-        if (usage != null)
-        {
-          String name = mpool.getName();
-          if (name.equalsIgnoreCase("PS Eden Space"))
-          {
-            // Parallel.
-            youngGenSize = usage.getMax();
-          }
-          else if (name.equalsIgnoreCase("PS Old Gen"))
-          {
-            // Parallel.
-            oldGenSize = usage.getMax();
-          }
-          else if (name.equalsIgnoreCase("Par Eden Space"))
-          {
-            // CMS.
-            youngGenSize = usage.getMax();
-          }
-          else if (name.equalsIgnoreCase("CMS Old Gen"))
-          {
-            // CMS.
-            oldGenSize = usage.getMax();
-          }
-        }
-      }
-
-      if (youngGenSize > 0 && oldGenSize > youngGenSize)
-      {
-        // We can calculate available memory based on GC info.
-        return oldGenSize - youngGenSize;
-      }
-      else if (oldGenSize > 0)
-      {
-        // Small old gen. It is going to be difficult to avoid full GCs if the
-        // young gen is bigger.
-        return oldGenSize * 40 / 100;
-      }
-      else
-      {
-        // Unknown GC (G1, JRocket, etc).
-        Runtime runTime = Runtime.getRuntime();
-        runTime.gc();
-        runTime.gc();
-        return (runTime.freeMemory() + (runTime.maxMemory() - runTime
-            .totalMemory())) * 40 / 100;
-      }
-    }
   }
 
 
@@ -587,34 +524,6 @@
     return javaVendor.startsWith(vendor);
   }
 
-
-
-  /**
-   * Calculates the usable memory which could potentially be used by the
-   * application for caching objects. This method <b>does not</b> look at the
-   * amount of free memory, but instead tries to query the JVM's GC settings in
-   * order to determine the amount of usable memory in the old generation (or
-   * equivalent). More specifically, applications may also need to take into
-   * account the amount of memory already in use, for example by performing the
-   * following:
-   *
-   * <pre>
-   * Runtime runTime = Runtime.getRuntime();
-   * runTime.gc();
-   * runTime.gc();
-   * long freeCommittedMemory = runTime.freeMemory();
-   * long uncommittedMemory = runTime.maxMemory() - runTime.totalMemory();
-   * long freeMemory = freeCommittedMemory + uncommittedMemory;
-   * </pre>
-   *
-   * @return The usable memory which could potentially be used by the
-   *         application for caching objects.
-   */
-  public static long getUsableMemoryForCaching()
-  {
-    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

--
Gitblit v1.10.0