From 7eda83737e5c2a09bef758ac2bcd3b7ea8b32ce3 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Wed, 20 Jun 2007 18:27:41 +0000
Subject: [PATCH] This refactoring includes the following changes to the JE backend: - Extracted common interface DatabaseContainer from DN2ID, ID2Entry, etc... classes. - Moved database read and write methods from EntryContainer to DatabaseContainer. - Added index configuration to the XML based admin framework. - Removed redundant configuration objects (Config, IndexConfig). - Added exclusive/shared lock to EntryContainer. All access to an EntryContainer must acquire a lock before using the internal DatabaseContainers or making configuration changes. - Added the ability to add/remove/modify indexes with the backend online. Server will issue rebuild required warning when adding new indexes or sub-indexes (equality, substring, presence...). - Added the ability to change the index entry limit for both the backend and each index with the backend online. Server will issue rebuild required warning if the previous limit has been exceeded. - Added the ability to change entry compression and index substring length setting while the backend is online. - Added a persistent state database to each EntryContainer to persist backend configuration between server restarts. Server will issue rebuild required warning if a new index is added when the backend is offline. - Added a trusted flag to indexes so that non existent keys will not be interpreted as an empty entry ID set when an index is untrusted. An index is untrusted when it is added to an non-empty EntryContainer or an inconsistency is detected. Server will issue warning on startup to rebuild the index. - Fixed a issue where the LDIF import process stops responding if the temporary import dir is full or unwritable.
---
opends/src/server/org/opends/server/backends/jeb/ImportThread.java | 69 +++++++++++++---------------------
1 files changed, 27 insertions(+), 42 deletions(-)
diff --git a/opends/src/server/org/opends/server/backends/jeb/ImportThread.java b/opends/src/server/org/opends/server/backends/jeb/ImportThread.java
index edebcdb..fc9b757 100644
--- a/opends/src/server/org/opends/server/backends/jeb/ImportThread.java
+++ b/opends/src/server/org/opends/server/backends/jeb/ImportThread.java
@@ -30,18 +30,13 @@
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.api.DirectoryThread;
-import org.opends.server.types.AttributeType;
-import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import com.sleepycat.je.Transaction;
-import com.sleepycat.je.DatabaseException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
-import java.util.Map;
import java.util.ArrayList;
-import java.io.IOException;
/**
* A thread to process import entries from a queue. Multiple instances of
@@ -146,33 +141,30 @@
{
Entry entry;
- Map<AttributeType,IndexConfig>
- indexConfigs = importContext.getConfig().getIndexConfigMap();
-
// Figure out how many indexes there will be.
int nIndexes = 0;
nIndexes += 2; // For id2children and id2subtree.
- for (IndexConfig indexConfig : indexConfigs.values())
+ for (AttributeIndex attrIndex : entryContainer.getAttributeIndexes())
{
- if (indexConfig.isEqualityIndex())
+ if (attrIndex.equalityIndex != null)
{
nIndexes++;
}
- if (indexConfig.isPresenceIndex())
+ if (attrIndex.presenceIndex != null)
{
nIndexes++;
}
- if (indexConfig.isSubstringIndex())
+ if (attrIndex.substringIndex != null)
{
nIndexes++;
}
- if (indexConfig.isOrderingIndex())
+ if (attrIndex.orderingIndex != null)
{
nIndexes++;
}
- if (indexConfig.isApproximateIndex())
+ if (attrIndex.approximateIndex != null)
{
nIndexes++;
}
@@ -183,50 +175,55 @@
long indexBufferSize = importContext.getBufferSize() / nIndexes;
// Create an index builder for each attribute index database.
- for (IndexConfig indexConfig : indexConfigs.values())
+ for (AttributeIndex attrIndex : entryContainer.getAttributeIndexes())
{
- AttributeIndex attrIndex =
- entryContainer.getAttributeIndex(indexConfig.getAttributeType());
- if (indexConfig.isEqualityIndex())
+ int indexEntryLimit =
+ importContext.getConfig().getBackendIndexEntryLimit();
+ if(attrIndex.getConfiguration().getIndexEntryLimit() != null)
+ {
+ indexEntryLimit = attrIndex.getConfiguration().getIndexEntryLimit();
+ }
+
+ if (attrIndex.equalityIndex != null)
{
IndexBuilder indexBuilder =
new IndexBuilder(importContext,
attrIndex.equalityIndex,
- indexConfig.getEqualityEntryLimit(),
+ indexEntryLimit,
indexBufferSize);
builders.add(indexBuilder);
}
- if (indexConfig.isPresenceIndex())
+ if (attrIndex.presenceIndex != null)
{
IndexBuilder indexBuilder =
new IndexBuilder(importContext,
attrIndex.presenceIndex,
- indexConfig.getPresenceEntryLimit(),
+ indexEntryLimit,
indexBufferSize);
builders.add(indexBuilder);
}
- if (indexConfig.isSubstringIndex())
+ if (attrIndex.substringIndex != null)
{
IndexBuilder indexBuilder =
new IndexBuilder(importContext,
attrIndex.substringIndex,
- indexConfig.getSubstringEntryLimit(),
+ indexEntryLimit,
indexBufferSize);
builders.add(indexBuilder);
}
- if (indexConfig.isOrderingIndex())
+ if (attrIndex.orderingIndex != null)
{
IndexBuilder indexBuilder =
new IndexBuilder(importContext, attrIndex.orderingIndex,
- indexConfig.getEqualityEntryLimit(),
+ indexEntryLimit,
indexBufferSize);
builders.add(indexBuilder);
}
- if (indexConfig.isApproximateIndex())
+ if (attrIndex.approximateIndex != null)
{
IndexBuilder indexBuilder =
new IndexBuilder(importContext, attrIndex.approximateIndex,
- indexConfig.getEqualityEntryLimit(),
+ indexEntryLimit,
indexBufferSize);
builders.add(indexBuilder);
}
@@ -317,26 +314,14 @@
// Increment the entry count.
importContext.incrEntryInsertCount(entryInsertCount);
}
- catch (DatabaseException e)
+ catch (Exception e)
{
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
- }
- catch (DirectoryException e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- catch (IOException e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+
+ throw new RuntimeException(e);
}
}
}
--
Gitblit v1.10.0