From 2030f68cb29c7aa4cddf811fee2550daf44b35db Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Fri, 13 Dec 2013 12:54:40 +0000
Subject: [PATCH] CR-2693 OPENDJ-1245 import-ldif changes ds-cfg-enabled attr (for user backend) to TRUE which causes an error in post ugrade task (rebuild-index)
---
opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java | 86 ++++++++++++++++++----------
opends/src/messages/messages/tools.properties | 2
opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java | 46 ++++++++++++--
3 files changed, 94 insertions(+), 40 deletions(-)
diff --git a/opends/src/messages/messages/tools.properties b/opends/src/messages/messages/tools.properties
index 6e1d833..a4616b4 100644
--- a/opends/src/messages/messages/tools.properties
+++ b/opends/src/messages/messages/tools.properties
@@ -2552,6 +2552,8 @@
INFO_UPGRADE_REBUILD_ALL_1848=Rebuilding all indexes
INFO_UPGRADE_PROCESS_END_1849=End of the upgrade process
SEVERE_ERR_UPGRADE_CORRUPTED_TEMPLATE_1850='%s' is missing or empty, it is probably corrupted
+INFO_UPGRADE_REBUILD_INDEX_NO_BACKEND_FOUND_1851=No backend found. The rebuild index task \
+stops.
# Upgrade tasks
INFO_UPGRADE_TASK_6869_SUMMARY_10000=Fixing de-DE collation matching rule OID
diff --git a/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java b/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
index f225cae..7683a5f 100644
--- a/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
+++ b/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -591,21 +591,9 @@
public void postUpgrade(final UpgradeContext context)
throws ClientException
{
- // Sets the arguments like the rebuild index command line.
- final List<String> args = new LinkedList<String>();
- args.addAll(Arrays.asList(
- "-f",
- new File(configDirectory, CURRENT_CONFIG_FILE_NAME)
- .getAbsolutePath()));
-
- // Index(es) could be contained in several backends.
- for (final String be : UpgradeUtils.getLocalBackendsFromConfig())
- {
- args.add("-b");
- args.add(be);
- }
-
Message message = null;
+ final List<String> args = new LinkedList<String>();
+
if (isRebuildAllIndexesIsPresent && isRebuildAllIndexesTaskAccepted)
{
args.add("--rebuildAll");
@@ -624,38 +612,72 @@
args.add("-i");
args.add(indexToRebuild);
}
- } else {
+ }
+ else
+ {
return;
}
-
+ // Startup message.
ProgressNotificationCallback pnc =
new ProgressNotificationCallback(0, message, 25);
LOG.log(Level.INFO, message.toString());
context.notifyProgress(pnc);
- final String[] commandLineArgs = args.toArray(new String[args.size()]);
- // Displays info about command line args for log only.
- LOG.log(Level.INFO, INFO_UPGRADE_REBUILD_INDEX_ARGUMENTS.get(
- Arrays.toString(commandLineArgs)).toString());
+ // Sets the arguments like the rebuild index command line.
+ args.addAll(Arrays.asList(
+ "-f",
+ new File(configDirectory, CURRENT_CONFIG_FILE_NAME)
+ .getAbsolutePath()));
/*
- * The rebuild-index process just display a status ok / fails. The
- * logger stream contains all the log linked to this process. The
- * complete process is not displayed in the upgrade console.
+ * Index(es) could be contained in several backends or none, If none,
+ * the post upgrade tasks succeed and a message is printed in the
+ * upgrade log file.
*/
- final int result =
- new RebuildIndex().rebuildIndexesWithinMultipleBackends(true,
- UpgradeLog.getPrintStream(), commandLineArgs);
- if (result == 0)
+ final List<String> backends = UpgradeUtils.getLocalBackendsFromConfig();
+ if (!backends.isEmpty())
{
- LOG.log(Level.INFO, INFO_UPGRADE_REBUILD_INDEX_ENDS.get().toString());
- context.notifyProgress(pnc.setProgress(100));
+ for (final String be : backends)
+ {
+ args.add("-b");
+ args.add(be);
+ }
+
+ final String[] commandLineArgs =
+ args.toArray(new String[args.size()]);
+ // Displays info about command line args for log only.
+ LOG.log(Level.INFO, INFO_UPGRADE_REBUILD_INDEX_ARGUMENTS.get(
+ Arrays.toString(commandLineArgs)).toString());
+
+ /*
+ * The rebuild-index process just display a status ok / fails. The
+ * logger stream contains all the log linked to this process. The
+ * complete process is not displayed in the upgrade console.
+ */
+ final int result =
+ new RebuildIndex().rebuildIndexesWithinMultipleBackends(true,
+ UpgradeLog.getPrintStream(), commandLineArgs);
+
+ if (result == 0)
+ {
+ LOG.log(Level.INFO, INFO_UPGRADE_REBUILD_INDEX_ENDS.get()
+ .toString());
+ context.notifyProgress(pnc.setProgress(100));
+ }
+ else
+ {
+ final Message msg = ERR_UPGRADE_PERFORMING_POST_TASKS_FAIL.get();
+ context.notifyProgress(pnc.setProgress(-100));
+ throw new ClientException(EXIT_CODE_ERROR, msg);
+ }
}
else
{
- final Message msg = ERR_UPGRADE_PERFORMING_POST_TASKS_FAIL.get();
- context.notifyProgress(pnc.setProgress(-100));
- throw new ClientException(EXIT_CODE_ERROR, msg);
+ final Message msg = INFO_UPGRADE_REBUILD_INDEX_NO_BACKEND_FOUND.get();
+ LOG.log(Level.INFO, msg.toString());
+ LOG.log(Level.INFO, INFO_UPGRADE_REBUILD_INDEX_DECLINED.get(
+ Arrays.toString(indexesListToRebuild.toArray())).toString());
+ context.notifyProgress(pnc.setProgress(100));
}
}
};
diff --git a/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java b/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
index fe32003..19685d5 100644
--- a/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
+++ b/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
@@ -398,20 +398,22 @@
*/
static List<String> getLocalBackendsFromConfig()
{
+ final Schema schema = getUpgradeSchema();
+
final List<String> listBackends = new LinkedList<String>();
LDIFEntryReader entryReader = null;
try
{
entryReader =
new LDIFEntryReader(new FileInputStream(new File(configDirectory,
- CURRENT_CONFIG_FILE_NAME)));
+ CURRENT_CONFIG_FILE_NAME))).setSchema(schema);
final SearchRequest sr =
Requests.newSearchRequest("", SearchScope.WHOLE_SUBTREE,
"(&(objectclass=ds-cfg-local-db-backend)(ds-cfg-enabled=true))",
"ds-cfg-base-dn");
- final EntryReader resultReader = LDIF.search(entryReader, sr);
+ final EntryReader resultReader = LDIF.search(entryReader, sr, schema);
while (resultReader.hasNext())
{
@@ -461,12 +463,7 @@
LDIFEntryWriter writer = null;
try
{
- Schema schema =
- new SchemaBuilder(Schema.getCoreSchema()).defaultMatchingRule(
- CoreSchema.getCaseExactMatchingRule()).defaultSyntax(
- CoreSchema.getDirectoryStringSyntax()).toSchema()
- .asNonStrictSchema();
-
+ final Schema schema = getUpgradeSchema();
entryReader =
new LDIFEntryReader(new FileInputStream(configPath))
.setSchema(schema);
@@ -784,6 +781,39 @@
}
}
+ /**
+ * Returns a schema used by upgrade(default octet string matching rule and
+ * directory string syntax). Added attribute types which we know we are
+ * sensitive to in the unit tests, e.g. ds-cfg-enabled (boolean syntax),
+ * ds-cfg-filter(case ingnore), ds-cfg-collation (case ignore)... related to
+ * upgrade tasks. See OPENDJ-1245.
+ *
+ * @return A schema which may used in the upgrade context.
+ */
+ final static Schema getUpgradeSchema() {
+ final SchemaBuilder sb =
+ new SchemaBuilder(Schema.getCoreSchema())
+ .defaultMatchingRule(CoreSchema.getCaseExactMatchingRule())
+ .defaultSyntax(CoreSchema.getDirectoryStringSyntax());
+
+ // Adds ds-cfg-enabled / boolean syntax
+ sb.addAttributeType("( 1.3.6.1.4.1.26027.1.1.2 NAME 'ds-cfg-enabled'"
+ + " EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7"
+ + " SINGLE-VALUE X-ORIGIN 'OpenDS Directory Server' )", false);
+
+ // Adds ds-cfg-filter / ignore match syntax
+ sb.addAttributeType("( 1.3.6.1.4.1.26027.1.1.279 NAME 'ds-cfg-filter'"
+ + " EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15"
+ + " X-ORIGIN 'OpenDS Directory Server' )", false);
+
+ // Adds ds-cfg-collation / ignore match syntax
+ sb.addAttributeType("( 1.3.6.1.4.1.26027.1.1.500 NAME 'ds-cfg-collation'"
+ + " EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15"
+ + " X-ORIGIN 'OpenDS Directory Server' )", false);
+
+ return sb.toSchema().asNonStrictSchema();
+ }
+
private static String[] readLDIFLines(final DN dn,
final ChangeOperationType changeType, final String... lines)
{
--
Gitblit v1.10.0