From 0b264b02134cffc47160d18e41c3f28f04ad56c7 Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Fri, 06 Nov 2009 12:18:47 +0000
Subject: [PATCH] This fix tries to alleviate this problem somewhat by allocating more memory to the DB cache if more than 1 GB of heap space is defined and turning on the cleaner threads if the skipDNValidation flag is not specified. Issue 4337. 

---
 opendj-sdk/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
index a22e8ea..818e39c 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
@@ -64,6 +64,7 @@
   private final int TIMER_INTERVAL = 10000;
   private final int KB = 1024;
   private final int MB =  (KB * KB);
+  private final int GB = (1000 * MB);
   private final int LDIF_READER_BUFFER_SIZE = 2 * MB;
   private final int MIN_IMPORT_MEMORY_REQUIRED = 16 * MB;
   private final int MAX_BUFFER_SIZE = 48 * MB;
@@ -74,6 +75,7 @@
   private final int MAX_DB_LOG_BUFFER_BYTES = 100 * MB;
   private final int MEM_PCT_PHASE_1 = 45;
   private final int MEM_PCT_PHASE_2 = 55;
+  private final int EXTRA_DB_CACHE_PCT = 30;
   private final int DN_STATE_CACHE_SIZE = 32 * KB;
 
   private final String DIRECT_PROPERTY = "import.directphase2";
@@ -390,7 +392,12 @@
       long maxMemory = runTime.maxMemory();
       long totMemory = runTime.totalMemory();
       long totFreeMemory = (freeMemory + (maxMemory - totMemory));
+      long extraDBCache = 0;
       long availableMemoryImport = (totFreeMemory * MEM_PCT_PHASE_1) / 100;
+      if(!skipDNValidation && (totFreeMemory > GB)){
+        extraDBCache = (availableMemoryImport * EXTRA_DB_CACHE_PCT) / 100;
+        availableMemoryImport -= extraDBCache;
+       }
       int phaseOneBuffers = 2 * (indexCount * threadCount);
       message = NOTE_JEB_IMPORT_LDIF_TOT_MEM_BUF.get(availableMemoryImport,
               phaseOneBuffers);
@@ -404,6 +411,11 @@
           }
       }
       getBufferSizes(availableMemoryImport, phaseOneBuffers);
+      dbCacheSize += extraDBCache;
+      if(!skipDNValidation)
+      {
+        envConfig.setConfigParam(EnvironmentConfig.ENV_RUN_CLEANER, "true");
+      }
       envConfig.setConfigParam("je.maxMemory", Long.toString(dbCacheSize));
       message =
               NOTE_JEB_IMPORT_LDIF_DB_MEM_BUF_INFO.get(dbCacheSize, bufferSize);

--
Gitblit v1.10.0