From 73bcbc6c61efa450b12b40598c55f420904b6cea Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 20 Jun 2013 20:16:32 +0000
Subject: [PATCH] Fix OPENDJ-992: JE environment failure (LOG_FILE_NOT_FOUND) after upgrading from OpenDJ 2.4.6 to OpenDJ 2.6.0
---
opendj-sdk/opends/src/messages/messages/tools.properties | 4 +
opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java | 18 +--
opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java | 198 ++++++++++++++++++++++++++++++++++++-------------
3 files changed, 157 insertions(+), 63 deletions(-)
diff --git a/opendj-sdk/opends/src/messages/messages/tools.properties b/opendj-sdk/opends/src/messages/messages/tools.properties
index 3100921..62b6fa2 100644
--- a/opendj-sdk/opends/src/messages/messages/tools.properties
+++ b/opendj-sdk/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?
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java b/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
index 3e5d3b3..02ef657 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
+++ b/opendj-sdk/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.
*
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java b/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
index 51b6701..334f8e1 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
+++ b/opendj-sdk/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.
- }
};
}
--
Gitblit v1.10.0