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

Fabio Pistolesi
06.44.2015 b0f31909d49c1c97b5ced0d0fef0117a8073ab17
OPENDJ-1716 CR-5915 Changes in Pluggable backend configuration and preparatory work for OPENDJ-1750
Prepares for a fix in Backup restore for pluggable backends, keeping a single parameter (ds-cfg-java-class) in the configuration.
Pluggable backends will need to Extend BackendImpl to be able to be referenced in the configuration.
PitBackend is the backend using PersistIt as storage, until a better name comes up.
1 files added
4 files modified
74 ■■■■ changed files
opendj-config-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/PersistitBackendConfiguration.xml 6 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/PersistitBackendConfiguration.xml 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/persistit/PitBackend.java 44 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java 10 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/RootContainer.java 10 ●●●● patch | view | raw | blame | history
opendj-config-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/PersistitBackendConfiguration.xml
@@ -22,7 +22,7 @@
  ! CDDL HEADER END
  !
  !
  !      Copyright 2014 ForgeRock AS.
  !      Copyright 2014-2015 ForgeRock AS.
  ! -->
<adm:managed-object name="persistit-backend"
  plural-name="persistit-backends" package="org.forgerock.opendj.server.config"
@@ -43,7 +43,7 @@
    <adm:default-behavior>
      <adm:defined>
        <adm:value>
          org.opends.server.backends.pluggable.BackendImpl
          org.opends.server.backends.persistit.PitBackend
        </adm:value>
      </adm:defined>
    </adm:default-behavior>
@@ -185,7 +185,7 @@
    </adm:description>
    <adm:default-behavior>
      <adm:defined>
        <adm:value>false</adm:value>
        <adm:value>true</adm:value>
      </adm:defined>
    </adm:default-behavior>
    <adm:syntax>
opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/PersistitBackendConfiguration.xml
@@ -22,7 +22,7 @@
  ! CDDL HEADER END
  !
  !
  !      Copyright 2014 ForgeRock AS.
  !      Copyright 2014-2015 ForgeRock AS.
  ! -->
<adm:managed-object name="persistit-backend"
  plural-name="persistit-backends" package="org.opends.server.admin.std"
@@ -43,7 +43,7 @@
    <adm:default-behavior>
      <adm:defined>
        <adm:value>
          org.opends.server.backends.pluggable.BackendImpl
          org.opends.server.backends.persistit.PitBackend
        </adm:value>
      </adm:defined>
    </adm:default-behavior>
opendj3-server-dev/src/server/org/opends/server/backends/persistit/PitBackend.java
New file
@@ -0,0 +1,44 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2015 ForgeRock AS
 */
package org.opends.server.backends.persistit;
import org.opends.server.backends.pluggable.BackendImpl;
import org.opends.server.backends.pluggable.spi.Storage;
/**
 * Class defined in the configuration for this backend type.
 */
public class PitBackend extends BackendImpl
{
  /** {@inheritDoc} */
  @Override
  protected Storage newStorageInstance()
  {
    return new PersistItStorage();
  }
}
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java
@@ -53,6 +53,7 @@
import org.opends.server.api.DiskSpaceMonitorHandler;
import org.opends.server.api.MonitorProvider;
import org.opends.server.backends.VerifyConfig;
import org.opends.server.backends.pluggable.spi.Storage;
import org.opends.server.backends.pluggable.spi.StorageRuntimeException;
import org.opends.server.backends.pluggable.spi.WriteOperation;
import org.opends.server.backends.pluggable.spi.WriteableStorage;
@@ -64,7 +65,7 @@
 * This is an implementation of a Directory Server Backend which stores entries
 * locally in a Berkeley DB JE database.
 */
public class BackendImpl extends Backend<PersistitBackendCfg> implements
public abstract class BackendImpl extends Backend<PersistitBackendCfg> implements
    ConfigurationChangeListener<PersistitBackendCfg>, AlertGenerator,
    DiskSpaceMonitorHandler
{
@@ -758,9 +759,16 @@
    BackupManager backupManager = new BackupManager(getBackendID());
    File parentDir = getFileForPath(cfg.getDBDirectory());
    File backendDir = new File(parentDir, cfg.getBackendId());
    // Storage storage = newStorageInstance();
    // backupConfig.setFilesToBackupFilter(storage.getFilesToBackupFilter());
    backupManager.createBackup(backendDir, backupConfig);
  }
  /**
   * Returns the storage corresponding to the backend class defined in the configuration.
   * @return the storage corresponding to the backend class defined in the configuration
   */
  protected abstract Storage newStorageInstance();
  /** {@inheritDoc} */
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/RootContainer.java
@@ -46,11 +46,11 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.PersistitBackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.CompressedSchema;
import org.opends.server.backends.persistit.PersistItStorage;
import org.opends.server.backends.pluggable.spi.ReadOperation;
import org.opends.server.backends.pluggable.spi.ReadableStorage;
import org.opends.server.backends.pluggable.spi.Storage;
import org.opends.server.backends.pluggable.spi.StorageRuntimeException;
import org.opends.server.backends.pluggable.spi.WriteOperation;
import org.opends.server.backends.pluggable.spi.WriteableStorage;
@@ -119,7 +119,7 @@
  private final File backendDirectory;
  /** The backend to which this entry root container belongs. */
  private final Backend<?> backend;
  private final BackendImpl backend;
  /** The backend configuration. */
  private PersistitBackendCfg config;
  /** The database environment monitor for this JE environment. */
@@ -143,7 +143,7 @@
   * @param backend A reference to the JE back end that is creating this
   *                root container.
   */
  public RootContainer(Backend<?> backend, PersistitBackendCfg config)
  public RootContainer(BackendImpl backend, PersistitBackendCfg config)
  {
    this.backend = backend;
    this.config = config;
@@ -161,7 +161,7 @@
   *
   * @return the underlying storage engine
   */
  PersistItStorage getStorage()
  Storage getStorage()
  {
    return storage;
  }
@@ -401,7 +401,7 @@
    try
    {
      storage = new PersistItStorage();
      storage = (PersistItStorage) backend.newStorageInstance();
      storage.initialize(config);
      storage.open();
      storage.write(new WriteOperation()