From 6c2e6b3e93f6188aa46176268bf96c111549f120 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Mon, 13 Dec 2010 08:15:26 +0000
Subject: [PATCH] FIX OPENDJ-10 - Import phase2 warnings and failure with very large heap size. Some miscalculation of the available memory (computed twice) resulted in negative numbers.
---
opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java b/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
index ed59036..52dacaa 100644
--- a/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
+++ b/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
@@ -148,6 +148,9 @@
// Size in bytes of temporary env.
private long tmpEnvCacheSize;
+ // Available memory at the start of the import.
+ private long availableMemory;
+
// Size in bytes of DB cache.
private long dbCacheSize;
@@ -414,7 +417,8 @@
// Calculate amount of usable memory. This will need to take into account
// various fudge factors, including the number of IO buffers used by the
// scratch writers (1 per index).
- final long availableMemory = calculateAvailableMemory();
+ calculateAvailableMemory();
+
final long usableMemory = availableMemory
- (indexCount * READER_WRITER_BUFFER_SIZE);
@@ -532,7 +536,7 @@
}
Message message = NOTE_JEB_IMPORT_LDIF_TOT_MEM_BUF.get(
- phaseOneBufferMemory, phaseOneBufferCount);
+ availableMemory, phaseOneBufferCount);
logError(message);
if (tmpEnvCacheSize > 0)
{
@@ -548,13 +552,13 @@
/**
- * Returns the amount of available memory which can be used by this import,
+ * Calculates the amount of available memory which can be used by this import,
* taking into account whether or not the import is running offline or online
* as a task.
*/
- private long calculateAvailableMemory()
+ private void calculateAvailableMemory()
{
- final long availableMemory;
+ final long totalAvailableMemory;
if (DirectoryServer.isRunning())
{
// Online import/rebuild.
@@ -577,18 +581,18 @@
}
// Round up to minimum of 16MB (e.g. unit tests only use 2% cache).
- availableMemory = Math.max(Math.min(usableMemory, configuredMemory),
+ totalAvailableMemory = Math.max(Math.min(usableMemory, configuredMemory),
16 * MB);
}
else
{
// Offline import/rebuild.
- availableMemory = Platform.getUsableMemoryForCaching();
+ totalAvailableMemory = Platform.getUsableMemoryForCaching();
}
// Now take into account various fudge factors.
int importMemPct = 90;
- if (availableMemory <= SMALL_HEAP_SIZE)
+ if (totalAvailableMemory <= SMALL_HEAP_SIZE)
{
// Be pessimistic when memory is low.
importMemPct -= 25;
@@ -599,7 +603,7 @@
importMemPct -= 15;
}
- return (availableMemory * importMemPct / 100);
+ availableMemory = (totalAvailableMemory * importMemPct / 100);
}
@@ -1144,9 +1148,7 @@
}
// Calculate memory / buffer counts.
- final long availableMemory = calculateAvailableMemory();
final long usableMemory = availableMemory - dbCacheSize;
-
int readAheadSize;
int buffers;
while (true)
--
Gitblit v1.10.0