From d2fe682c2696d6b42f28ae1527663e788dcb47bb Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 30 Mar 2015 11:57:18 +0000
Subject: [PATCH] OPENDJ-1793 (CR-6493) Convert PersistItBackendCfg references to PluggableBackendCfg

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java |   31 ++++---------------------------
 1 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java
index 3670bc3..c728529 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java
@@ -191,8 +191,6 @@
 
   /** Import configuration. */
   private final LDIFImportConfig importConfiguration;
-  /** Backend configuration. */
-  private final PersistitBackendCfg backendConfiguration;
   private final ServerContext serverContext;
 
   /** LDIF reader. */
@@ -288,11 +286,10 @@
    * @throws ConfigException
    *           If a problem occurs during initialization.
    */
-  Importer(RebuildConfig rebuildConfig, PersistitBackendCfg cfg, ServerContext serverContext)
+  Importer(RebuildConfig rebuildConfig, PluggableBackendCfg cfg, ServerContext serverContext)
       throws InitializationException, StorageRuntimeException, ConfigException
   {
     this.importConfiguration = null;
-    this.backendConfiguration = cfg;
     this.serverContext = serverContext;
     this.tmpEnv = null;
     this.threadCount = 1;
@@ -327,12 +324,11 @@
    * @throws StorageRuntimeException
    *           If an error occurred when opening the DB.
    */
-  Importer(LDIFImportConfig importConfiguration, PersistitBackendCfg backendCfg, ServerContext serverContext)
+  Importer(LDIFImportConfig importConfiguration, PluggableBackendCfg backendCfg, ServerContext serverContext)
       throws InitializationException, ConfigException, StorageRuntimeException
   {
     this.rebuildManager = null;
     this.importConfiguration = importConfiguration;
-    this.backendConfiguration = backendCfg;
     this.serverContext = serverContext;
 
     if (importConfiguration.getThreadCount() == 0)
@@ -605,27 +601,8 @@
     if (DirectoryServer.isRunning())
     {
       // Online import/rebuild.
-      Runtime runTime = Runtime.getRuntime();
-      // call twice gc to ensure finalizers are called
-      // and young to old gen references are properly gc'd
-      runTime.gc();
-      runTime.gc();
-      final long usedMemory = runTime.totalMemory() - runTime.freeMemory();
-      final long maxUsableMemory = Platform.getUsableMemoryForCaching();
-      final long usableMemory = maxUsableMemory - usedMemory;
-
-      final long configuredMemory;
-      if (backendConfiguration.getDBCacheSize() > 0)
-      {
-        configuredMemory = backendConfiguration.getDBCacheSize();
-      }
-      else
-      {
-        configuredMemory = backendConfiguration.getDBCachePercent() * Runtime.getRuntime().maxMemory() / 100;
-      }
-
-      // Round up to minimum of 16MB (e.g. unit tests only use 2% cache).
-      totalAvailableMemory = Math.max(Math.min(usableMemory, configuredMemory), 16 * MB);
+      final long availableMemory = serverContext.getMemoryQuota().getAvailableMemory();
+      totalAvailableMemory = Math.max(availableMemory, 16 * MB);
     }
     else
     {

--
Gitblit v1.10.0