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/RootContainer.java | 5 +----
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java | 5 +----
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java | 31 ++++---------------------------
3 files changed, 6 insertions(+), 35 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java
index bab0b0b..fa00f73 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java
@@ -46,7 +46,6 @@
import org.forgerock.util.Reject;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.BackendIndexCfgDefn;
-import org.opends.server.admin.std.server.PersistitBackendCfg;
import org.opends.server.admin.std.server.PluggableBackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.MonitorProvider;
@@ -788,9 +787,7 @@
{
rootContainer = initializeRootContainer();
}
- // FIXME JNR remove cast
- final Importer importer = new Importer(rebuildConfig, (PersistitBackendCfg) cfg, serverContext);
- importer.rebuildIndexes(rootContainer);
+ new Importer(rebuildConfig, cfg, serverContext).rebuildIndexes(rootContainer);
}
catch (ExecutionException execEx)
{
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
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/RootContainer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/RootContainer.java
index 7dc10c1..fa8429f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/RootContainer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/RootContainer.java
@@ -48,7 +48,6 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
-import org.opends.server.admin.std.server.PersistitBackendCfg;
import org.opends.server.admin.std.server.PluggableBackendCfg;
import org.opends.server.api.CompressedSchema;
import org.opends.server.backends.pluggable.spi.ReadOperation;
@@ -319,9 +318,7 @@
{
try
{
- // TODO JNR remove cast
- final Importer importer = new Importer(importConfig, (PersistitBackendCfg) config, serverContext);
- return importer.processImport(this);
+ return new Importer(importConfig, config, serverContext).processImport(this);
}
catch (DirectoryException e)
{
--
Gitblit v1.10.0