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

Jean-Noel Rouvignac
21.27.2015 8d540fde5ca1ce5a2ddc8d5faf2e0f5385e2f4c5
OPENDJ-1708 Persistit: no rebuild-index support

Preliminary work: adapt the higher level code so it accepts other backends than JE.
However, the rebuild-index functionality still needs to be implemented for the PersistIt backend.
5 files modified
75 ■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/api/Backend.java 22 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tasks/RebuildTask.java 7 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java 9 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestRebuildJob.java 24 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/api/Backend.java
@@ -41,6 +41,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.admin.Configuration;
import org.opends.server.backends.RebuildConfig;
import org.opends.server.backends.VerifyConfig;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
@@ -683,6 +684,27 @@
  }
  /**
   * Rebuild indexes in the backend instance. Note that the server will not explicitly initialize
   * this backend before calling this method.
   *
   * @param rebuildConfig
   *          The rebuild configuration.
   * @throws ConfigException
   *           If an unrecoverable problem arises during initialization.
   * @throws InitializationException
   *           If a problem occurs during initialization that is not related to the server
   *           configuration.
   * @throws DirectoryException
   *           If a Directory Server error occurs.
   */
  public void rebuildBackend(RebuildConfig rebuildConfig) throws InitializationException, ConfigException,
      DirectoryException
  {
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
        ERR_INDEXES_NOT_SUPPORTED.get(getBackendID()));
  }
  /**
   * Indicates whether this backend provides a backup mechanism of any
   * kind.  This method is used by the backup process when backing up
   * all backends to determine whether this backend is one that should
opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -863,17 +863,8 @@
  }
  /**
   * Rebuild index(es) in the backend instance. Note that the server will not
   * explicitly initialize this backend before calling this method.
   * @param rebuildConfig The rebuild configuration.
   * @throws  ConfigException  If an unrecoverable problem arises during
   *                           initialization.
   * @throws  InitializationException  If a problem occurs during initialization
   *                                   that is not related to the server
   *                                   configuration.
   * @throws DirectoryException If a Directory Server error occurs.
   */
  /** {@inheritDoc} */
  @Override
  public void rebuildBackend(RebuildConfig rebuildConfig)
          throws InitializationException, ConfigException, DirectoryException
  {
opendj3-server-dev/src/server/org/opends/server/tasks/RebuildTask.java
@@ -43,7 +43,6 @@
import org.opends.server.api.ClientConnection;
import org.opends.server.backends.RebuildConfig;
import org.opends.server.backends.RebuildConfig.RebuildMode;
import org.opends.server.backends.jeb.BackendImpl;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.DirectoryServer;
@@ -182,8 +181,7 @@
      logger.error(ERR_NO_BACKENDS_FOR_BASE, baseDN);
      return TaskState.STOPPED_BY_ERROR;
    }
    if (!(backend instanceof BackendImpl))
    if (!backend.supportsIndexing())
    {
      logger.error(ERR_REBUILDINDEX_WRONG_BACKEND_TYPE);
      return TaskState.STOPPED_BY_ERROR;
@@ -249,8 +247,7 @@
    // Launch the rebuild process.
    try
    {
      BackendImpl jebBackend = (BackendImpl) backend;
      jebBackend.rebuildBackend(rebuildConfig);
      backend.rebuildBackend(rebuildConfig);
    }
    catch (InitializationException e)
    {
opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2014 ForgeRock AS
 *      Portions Copyright 2011-2015 ForgeRock AS
 */
package org.opends.server.tools;
@@ -47,7 +47,6 @@
import org.opends.server.api.Backend;
import org.opends.server.backends.RebuildConfig;
import org.opends.server.backends.RebuildConfig.RebuildMode;
import org.opends.server.backends.jeb.BackendImpl;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
@@ -585,8 +584,7 @@
    int returnCode = 0;
    try
    {
      final BackendImpl jebBackend = (BackendImpl) backend;
      jebBackend.rebuildBackend(rebuildConfig);
      backend.rebuildBackend(rebuildConfig);
    }
    catch (InitializationException e)
    {
@@ -664,8 +662,7 @@
    {
      throw new ConfigException(ERR_NO_BACKENDS_FOR_BASE.get(baseDNString.getValue()));
    }
    if (!(backend instanceof BackendImpl))
    if (!backend.supportsIndexing())
    {
      throw new ConfigException(ERR_BACKEND_NO_INDEXING_SUPPORT.get());
    }
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestRebuildJob.java
@@ -29,9 +29,10 @@
import static org.testng.Assert.*;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.Backend;
import org.opends.server.backends.RebuildConfig;
import org.opends.server.backends.VerifyConfig;
import org.opends.server.backends.RebuildConfig.RebuildMode;
import org.opends.server.backends.VerifyConfig;
import org.opends.server.core.DirectoryServer;
import org.opends.server.tasks.TaskUtils;
import org.opends.server.types.DN;
@@ -51,7 +52,7 @@
  private  String numUsersLine="define numusers= #numEntries#";
  private  DN[] baseDNs;
  private BackendImpl backend;
  private Backend<?> backend;
  @DataProvider(name = "systemIndexes")
  public Object[][] systemIndexes() {
@@ -144,9 +145,7 @@
   */
  private void cleanAndLoad(int numEntries) throws Exception {
    TestCaseUtils.clearJEBackend(backendID);
    template[2]=numUsersLine;
    template[2]=
        template[2].replaceAll("#numEntries#", String.valueOf(numEntries));
    template[2] = numUsersLine.replaceAll("#numEntries#", String.valueOf(numEntries));
    createLoadEntries(template, numEntries);
  }
@@ -162,7 +161,7 @@
    RebuildConfig rebuildConfig = new RebuildConfig();
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex(index);
    backend = (BackendImpl) DirectoryServer.getBackend(backendID);
    backend = DirectoryServer.getBackend(backendID);
    backend.rebuildBackend(rebuildConfig);
    if(index.contains(".") && !index.startsWith("vlv."))
@@ -189,7 +188,7 @@
    RebuildConfig rebuildConfig = new RebuildConfig();
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex("id2entry");
    backend = (BackendImpl) DirectoryServer.getBackend(backendID);
    backend = DirectoryServer.getBackend(backendID);
    backend.rebuildBackend(rebuildConfig);
  }
@@ -208,7 +207,7 @@
    RebuildConfig rebuildConfig = new RebuildConfig();
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex("id2entry");
    backend = (BackendImpl) DirectoryServer.getBackend(backendID);
    backend = DirectoryServer.getBackend(backendID);
    TaskUtils.disableBackend(backendID);
    try {
@@ -225,7 +224,7 @@
    RebuildConfig rebuildConfig = new RebuildConfig();
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex(index);
    backend = (BackendImpl) DirectoryServer.getBackend(backendID);
    backend = DirectoryServer.getBackend(backendID);
    backend.rebuildBackend(rebuildConfig);
  }
@@ -237,7 +236,7 @@
    RebuildConfig rebuildConfig = new RebuildConfig();
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex(index);
    backend = (BackendImpl) DirectoryServer.getBackend(backendID);
    backend = DirectoryServer.getBackend(backendID);
    backend.rebuildBackend(rebuildConfig);
  }
@@ -248,10 +247,9 @@
    RebuildConfig rebuildConfig = new RebuildConfig();
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex(index);
    backend = (BackendImpl) DirectoryServer.getBackend(backendID);
    backend = DirectoryServer.getBackend(backendID);
    TaskUtils.disableBackend(backendID);
    backend.rebuildBackend(rebuildConfig);
    //TODO: Verify dn2uri database as well.
@@ -298,7 +296,7 @@
  private void rebuildIndexes(RebuildConfig rebuildConfig) throws Exception
  {
    backend = (BackendImpl) DirectoryServer.getBackend(backendID);
    backend = DirectoryServer.getBackend(backendID);
    TaskUtils.disableBackend(backendID);
    try
    {