mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
30.57.2015 d2fe682c2696d6b42f28ae1527663e788dcb47bb
OPENDJ-1793 (CR-6493) Convert PersistItBackendCfg references to PluggableBackendCfg

Fabio suggested using MemoryQuota instead of implementing our own custom available memory calculation.


Importer.java:
Removed references to PersistitBackendCfg.
In calculateAvailableMemory(), used MemoryQuota to compute the available memory.

BackendImpl.java, RootContainer.java:
Removed references to PersistitBackendCfg.
3 files modified
41 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java 5 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java 31 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/RootContainer.java 5 ●●●● patch | view | raw | blame | history
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)
    {
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
    {
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)
    {