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

Matthew Swift
20.16.2013 d056ebdcc008cc3f0343390c682fddd6b9946384
Fix OPENDJ-992: JE environment failure (LOG_FILE_NOT_FOUND) after upgrading from OpenDJ 2.4.6 to OpenDJ 2.6.0

* add upgrade task which notifies the user that they must rebuild the ds-sync-hist ordering index when upgrading from 2.5.0-Xpress1.
3 files modified
220 ■■■■ changed files
opends/src/messages/messages/tools.properties 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/Upgrade.java 18 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java 198 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/tools.properties
@@ -2713,4 +2713,8 @@
INFO_UPGRADE_TASK_7466_SUMMARY_10016=Rename SNMP security config file
INFO_UPGRADE_TASK_8985_1_SUMMARY_10017=Adding 'emailAddress' attribute
INFO_UPGRADE_TASK_8985_2_SUMMARY_10018=Updating subject attribute to user attribute configuration
INFO_UPGRADE_TASK_9013_DESCRIPTION_10019=OpenDJ 2.5.0-Xpress1 introduced a \
 regression in the ds-sync-hist ordering index. This index must be rebuilt \
 after the upgrade has completed and before restarting OpenDJ. Do you wish to \
 continue?
opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
@@ -288,6 +288,12 @@
        "-",
        "add:ds-cfg-subject-attribute-mapping",
        "ds-cfg-subject-attribute-mapping: emailAddress:mail"));
    /* See OPENDJ-992 */
    register("2.5.0.9013",
        regressionInVersion("2.5.0.7640",
            rebuildSingleIndex(INFO_UPGRADE_TASK_9013_DESCRIPTION.get())));
    /*
     * All upgrades will refresh the server configuration schema and generate
     * a new upgrade folder.
@@ -469,12 +475,10 @@
    }
  }
  private static void register(final String versionString,
      final UpgradeTask... tasks)
  {
    final BuildVersion version = version(versionString);
    final BuildVersion version = BuildVersion.valueOf(versionString);
    List<UpgradeTask> taskList = TASKS.get(version);
    if (taskList == null)
    {
@@ -518,14 +522,6 @@
  private static BuildVersion version(final String version)
  {
    // TODO Need to change it when change to GIT.
    return BuildVersion.valueOf(version);
  }
  /**
   * The server must be offline during the upgrade.
   *
opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -47,6 +47,7 @@
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.tools.ClientException;
import org.opends.server.tools.upgrade.UpgradeTask.TaskType;
import org.opends.server.util.BuildVersion;
/**
 * Factory methods for create new upgrade tasks.
@@ -340,6 +341,99 @@
  }
  /**
   * Creates a group of tasks which will only be invoked if the current version
   * is more recent than the provided version. This may be useful in cases where
   * a regression was introduced in version X and resolved in a later version Y.
   * In this case, the provided upgrade tasks will only be invoked if the
   * current version is between X (inclusive) and Y (exclusive).
   *
   * @param versionString
   *          The lower bound version. The upgrade tasks will not be applied if
   *          the current version is older than this version.
   * @param tasks
   *          The group of tasks to invoke if the current version is equal to or
   *          more recent than {@code versionString}.
   * @return An upgrade task which will only be invoked if the current version
   *         is more recent than the provided version.
   */
  public static UpgradeTask regressionInVersion(final String versionString,
      final UpgradeTask... tasks)
  {
    final BuildVersion version = BuildVersion.valueOf(versionString);
    return new AbstractUpgradeTask()
    {
      @Override
      public void verify(UpgradeContext context) throws ClientException
      {
        if (currentVersionEqualToOrMoreRecentThan(context, version))
        {
          for (UpgradeTask task : tasks)
          {
            task.verify(context);
          }
        }
      }
      @Override
      public void interact(UpgradeContext context) throws ClientException
      {
        if (currentVersionEqualToOrMoreRecentThan(context, version))
        {
          for (UpgradeTask task : tasks)
          {
            task.interact(context);
          }
        }
      }
      @Override
      public void start(UpgradeContext context) throws ClientException
      {
        if (currentVersionEqualToOrMoreRecentThan(context, version))
        {
          for (UpgradeTask task : tasks)
          {
            task.start(context);
          }
        }
      }
      @Override
      public void perform(UpgradeContext context) throws ClientException
      {
        if (currentVersionEqualToOrMoreRecentThan(context, version))
        {
          for (UpgradeTask task : tasks)
          {
            task.perform(context);
          }
        }
      }
      @Override
      public void end(UpgradeContext context) throws ClientException
      {
        if (currentVersionEqualToOrMoreRecentThan(context, version))
        {
          for (UpgradeTask task : tasks)
          {
            task.end(context);
          }
        }
      }
      private boolean currentVersionEqualToOrMoreRecentThan(
          UpgradeContext context, final BuildVersion version)
      {
        return context.getFromVersion().compareTo(version) >= 0;
      }
    };
  }
  /**
   * Creates a rebuild all indexes task.
   *
   * @param summary
@@ -348,21 +442,8 @@
   */
  public static UpgradeTask rebuildAllIndexes(final Message summary)
  {
    return new UpgradeTask()
    return new AbstractUpgradeTask()
    {
      @Override
      public void end(final UpgradeContext context) throws ClientException
      {
        // Nothing to do.
      }
      @Override
      public void interact(final UpgradeContext context) throws ClientException
      {
        // Nothing to do.
      }
      @Override
      public void perform(final UpgradeContext context) throws ClientException
      {
@@ -383,6 +464,55 @@
    };
  }
  /**
   * Creates a rebuild index task for a single index. At the moment this is
   * implemented as a simple stub which displays a message which should prompt
   * the user to rebuild the index manually once the upgrade has completed.
   * <p>
   * In future this task should register the index to be rebuilt in a table. A
   * subsequent task executed at the end of the upgrade process will then obtain
   * the set of indexes to be rebuilt, optimize it (e.g. removing duplicates),
   * and perform the rebuild.
   *
   * @param summary
   *          A message describing why the index needs to be rebuilt and asking
   *          them whether or not they wish to continue.
   * @return The rebuild index task.
   */
  public static UpgradeTask rebuildSingleIndex(final Message summary)
  {
    return new AbstractUpgradeTask()
    {
      @Override
      public void verify(final UpgradeContext context) throws ClientException
      {
        verifyTaskType(TaskType.MANDATORY_USER_INTERACTION, context);
      }
      @Override
      public void interact(UpgradeContext context) throws ClientException
      {
        // Require acknowledgment from the user.
        final int answer = context.confirmYN(summary, ConfirmationCallback.NO);
        // The user refused to perform this task.
        if (answer == ConfirmationCallback.NO)
        {
          throw new ClientException(EXIT_CODE_MANUAL_INTERVENTION,
              INFO_UPGRADE_ABORTED_BY_USER.get());
        }
      }
      @Override
      public void perform(final UpgradeContext context) throws ClientException
      {
        // TODO: automatic rebuild is not supported yet.
      }
    };
  }
  /**
   * Creates a file object representing config/upgrade/schema.ldif.current which
   * the server creates the first time it starts if there are schema
@@ -481,17 +611,11 @@
      final Message description, final boolean needsUserConfirmation,
      final String... ldif)
  {
    return new UpgradeTask()
    return new AbstractUpgradeTask()
    {
      private boolean userConfirmation = true;
      @Override
      public void end(final UpgradeContext context)
      {
        // Nothing to do: no cleanup required.
      }
      @Override
      public void interact(final UpgradeContext context) throws ClientException
      {
        if (needsUserConfirmation)
@@ -544,18 +668,6 @@
          }
        }
      }
      @Override
      public void start(final UpgradeContext context) throws ClientException
      {
        // Nothing to do.
      }
      @Override
      public void verify(final UpgradeContext context) throws ClientException
      {
        // Nothing to do.
      }
    };
  }
@@ -605,17 +717,11 @@
      final Message description, final boolean needsUserConfirmation,
      final String filter, final String... ldif)
  {
    return new UpgradeTask()
    return new AbstractUpgradeTask()
    {
      private boolean userConfirmation = true;
      @Override
      public void end(final UpgradeContext context)
      {
        // Nothing to do: no cleanup required.
      }
      @Override
      public void interact(final UpgradeContext context) throws ClientException
      {
        if (needsUserConfirmation)
@@ -667,18 +773,6 @@
          }
        }
      }
      @Override
      public void start(final UpgradeContext context) throws ClientException
      {
        // Nothing to do.
      }
      @Override
      public void verify(final UpgradeContext context) throws ClientException
      {
        // Nothing to do.
      }
    };
  }