opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AbstractTree.java
File was renamed from opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AbstractDatabaseContainer.java @@ -35,12 +35,12 @@ * This class is a wrapper around the tree object and provides basic * read and write methods for entries. */ abstract class AbstractDatabaseContainer implements DatabaseContainer abstract class AbstractTree implements Tree { /** The name of the database within the entryContainer. */ /** The name of the tree within the entryContainer. */ private TreeName name; AbstractDatabaseContainer(final TreeName name) AbstractTree(final TreeName name) { this.name = name; } opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java
@@ -61,7 +61,7 @@ /** * Class representing an attribute index. * We have a separate database for each type of indexing, which makes it easy * We have a separate tree for each type of indexing, which makes it easy * to tell which attribute indexes are configured. The different types of * indexing are equality, presence, substrings and ordering. The keys in the * ordering index are ordered by setting the btree comparator to the ordering @@ -346,14 +346,14 @@ private TreeName getIndexName(AttributeType attrType, String indexID) { final String attrIndexId = attrType.getNameOrOID() + "." + indexID; return new TreeName(entryContainer.getDatabasePrefix(), attrIndexId); return new TreeName(entryContainer.getTreePrefix(), attrIndexId); } /** * Open the attribute index. * * @param txn a non null database transaction * @throws StorageRuntimeException if a database error occurs while opening the index * @param txn a non null transaction * @throws StorageRuntimeException if an error occurs while opening the index */ void open(WriteableTransaction txn) throws StorageRuntimeException { @@ -431,7 +431,7 @@ * @param buffer The index buffer to use to store the added keys * @param entryID The entry ID. * @param entry The contents of the new entry. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws DirectoryException If a Directory Server error occurs. */ void addEntry(IndexBuffer buffer, EntryID entryID, Entry entry) throws StorageRuntimeException, DirectoryException @@ -453,7 +453,7 @@ * @param buffer The index buffer to use to store the deleted keys * @param entryID The entry ID * @param entry The contents of the deleted entry. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws DirectoryException If a Directory Server error occurs. */ void removeEntry(IndexBuffer buffer, EntryID entryID, Entry entry) throws StorageRuntimeException, DirectoryException @@ -478,7 +478,7 @@ * @param oldEntry The entry before the modifications were applied. * @param newEntry The entry after the modifications were applied. * @throws StorageRuntimeException If an error occurs during an operation on a * database. * storage. */ void modifyEntry(IndexBuffer buffer, EntryID entryID, Entry oldEntry, Entry newEntry) throws StorageRuntimeException { @@ -513,13 +513,13 @@ * If not null, a diagnostic string will be written which will help * determine how the indexes contributed to this search. * @param monitor * The database environment monitor provider that will keep index * The backend monitor provider that will keep index * filter usage statistics. * @return The candidate entry IDs that might contain the filter assertion * value. */ private EntryIDSet evaluateIndexQuery(IndexQuery indexQuery, String indexName, SearchFilter filter, StringBuilder debugBuffer, DatabaseEnvironmentMonitor monitor) StringBuilder debugBuffer, BackendMonitor monitor) { LocalizableMessageBuilder debugMessage = monitor.isFilterUseEnabled() ? new LocalizableMessageBuilder() : null; EntryIDSet results = indexQuery.evaluate(debugMessage); @@ -561,12 +561,12 @@ * If not null, a diagnostic string will be written which will help * determine how the indexes contributed to this search. * @param monitor * The database environment monitor provider that will keep index * The backend monitor provider that will keep index * filter usage statistics. * @return The candidate entry IDs that might contain match both filters. */ EntryIDSet evaluateBoundedRange(IndexQueryFactory<IndexQuery> indexQueryFactory, SearchFilter filter1, SearchFilter filter2, StringBuilder debugBuffer, DatabaseEnvironmentMonitor monitor) SearchFilter filter1, SearchFilter filter2, StringBuilder debugBuffer, BackendMonitor monitor) { // TODO : this implementation is not optimal // as it implies two separate evaluations instead of a single one, @@ -581,7 +581,7 @@ } private EntryIDSet evaluate(IndexQueryFactory<IndexQuery> indexQueryFactory, SearchFilter filter, StringBuilder debugBuffer, DatabaseEnvironmentMonitor monitor) StringBuilder debugBuffer, BackendMonitor monitor) { boolean isLessOrEqual = filter.getFilterType() == FilterType.LESS_OR_EQUAL; IndexFilterType indexFilterType = isLessOrEqual ? IndexFilterType.LESS_OR_EQUAL : IndexFilterType.GREATER_OR_EQUAL; @@ -597,13 +597,13 @@ * @param debugBuffer If not null, a diagnostic string will be written * which will help determine how the indexes contributed * to this search. * @param monitor The database environment monitor provider that will keep * @param monitor The backend monitor provider that will keep * index filter usage statistics. * @return The candidate entry IDs that might contain a value * that matches the filter type. */ EntryIDSet evaluateFilter(IndexQueryFactory<IndexQuery> indexQueryFactory, IndexFilterType indexFilterType, SearchFilter filter, StringBuilder debugBuffer, DatabaseEnvironmentMonitor monitor) SearchFilter filter, StringBuilder debugBuffer, BackendMonitor monitor) { try { @@ -815,7 +815,7 @@ Index index = nameToIndexes.get(indexId); if (index != null) { entryContainer.deleteDatabase(txn, index); entryContainer.deleteTree(txn, index); nameToIndexes.remove(index); } } @@ -893,7 +893,7 @@ try { nameToIndexes.remove(indexType.toString()); entryContainer.deleteDatabase(txn, index); entryContainer.deleteTree(txn, index); } finally { @@ -933,13 +933,13 @@ } /** * Get the database name prefix for indexes in this attribute index. * Get the tree name prefix for indexes in this attribute index. * * @return database name for this database container. * @return tree name for this container. */ String getName() { return entryContainer.getDatabasePrefix() return entryContainer.getTreePrefix() + "_" + config.getAttribute().getNameOrOID(); } @@ -957,14 +957,13 @@ * @param debugBuffer If not null, a diagnostic string will be written * which will help determine how the indexes contributed * to this search. * @param monitor The database environment monitor provider that will keep * @param monitor The backend monitor provider that will keep * index filter usage statistics. * @return The candidate entry IDs that might contain the filter * assertion value. */ EntryIDSet evaluateExtensibleFilter(IndexQueryFactory<IndexQuery> indexQueryFactory, SearchFilter filter, StringBuilder debugBuffer, DatabaseEnvironmentMonitor monitor) SearchFilter filter, StringBuilder debugBuffer, BackendMonitor monitor) { //Get the Matching Rule OID of the filter. String matchRuleOID = filter.getMatchingRuleID(); opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java
@@ -95,8 +95,8 @@ OID_VLV_REQUEST_CONTROL)); /** * Begin a Backend API method that accesses the database and returns the <code>EntryContainer</code> for * <code>entryDN</code>. * Begin a Backend API method that accesses the {@link EntryContainer} for <code>entryDN</code> * and returns it. * @param operation requesting the storage * @param entryDN the target DN for the operation * @return <code>EntryContainer</code> where <code>entryDN</code> resides @@ -114,22 +114,22 @@ return ec; } /** End a Backend API method that accesses the database. */ /** End a Backend API method that accesses the EntryContainer. */ private void accessEnd() { threadTotalCount.getAndDecrement(); } /** * Wait until there are no more threads accessing the database. It is assumed * that new threads have been prevented from entering the database at the time * Wait until there are no more threads accessing the storage. It is assumed * that new threads have been prevented from entering the storage at the time * this method is called. */ private void waitUntilQuiescent() { while (threadTotalCount.get() > 0) { // Still have threads in the database so sleep a little // Still have threads accessing the storage so sleep a little try { Thread.sleep(500); @@ -161,7 +161,7 @@ rootContainer = initializeRootContainer(); } // Preload the database cache. // Preload the tree cache. rootContainer.preload(cfg.getPreloadTimeLimit()); try @@ -187,7 +187,6 @@ } } // Register a monitor provider for the environment. rootContainerMonitor = rootContainer.getMonitorProvider(); DirectoryServer.registerMonitorProvider(rootContainerMonitor); @@ -221,7 +220,7 @@ // backend. We need to wait for them to finish. waitUntilQuiescent(); // Close the database. // Close RootContainer and Storage. try { rootContainer.close(); @@ -998,7 +997,7 @@ private RootContainer initializeRootContainer() throws ConfigException, InitializationException { // Open the database environment // Open the storage try { RootContainer rc = new RootContainer(this, cfg); rc.open(); opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendMonitor.java
File was renamed from opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DatabaseEnvironmentMonitor.java @@ -26,29 +26,28 @@ */ package org.opends.server.backends.pluggable; import java.lang.reflect.Method; import java.util.*; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.config.server.ConfigException; import org.opends.server.admin.std.server.MonitorProviderCfg; import org.opends.server.api.AttributeSyntax; import org.opends.server.api.MonitorProvider; import org.opends.server.core.DirectoryServer; import org.opends.server.types.*; import org.opends.server.types.Attribute; import org.opends.server.types.AttributeBuilder; import org.opends.server.types.Attributes; import org.opends.server.types.InitializationException; import org.opends.server.types.SearchFilter; import org.opends.server.util.TimeThread; /** * A monitor provider for a Berkeley DB JE environment. * It uses reflection on the environment statistics object * so that we don't need to keep a list of all the stats. * A monitor provider for high level backend statistics, such as filter stats and search counters. */ class DatabaseEnvironmentMonitor extends MonitorProvider<MonitorProviderCfg> class BackendMonitor extends MonitorProvider<MonitorProviderCfg> { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); /** Represents the statistical information kept for each search filter. */ private static class FilterStats implements Comparable<FilterStats> @@ -91,18 +90,17 @@ private int maxEntries = 1024; private boolean filterUseEnabled; private String startTimeStamp; private final HashMap<SearchFilter, FilterStats> filterToStats = new HashMap<SearchFilter, FilterStats>(); private final HashMap<SearchFilter, FilterStats> filterToStats = new HashMap<>(); private final AtomicInteger indexedSearchCount = new AtomicInteger(); private final AtomicInteger unindexedSearchCount = new AtomicInteger(); /** * Creates a new database environment monitor. * Creates a new backend monitor. * @param name The monitor instance name. * @param rootContainer A root container handle for the database to be * @param rootContainer A root container handle for the backend to be * monitored. */ DatabaseEnvironmentMonitor(String name, RootContainer rootContainer) BackendMonitor(String name, RootContainer rootContainer) { this.name = name; this.rootContainer = rootContainer; @@ -128,59 +126,6 @@ } /** * Creates monitor attribute values for a given JE statistics object, * using reflection to call all the getter methods of the statistics object. * The attribute type names of the created attribute values are derived from * the names of the getter methods. * @param monitorAttrs The monitor attribute values are inserted into this * attribute list. * @param stats The JE statistics object. * @param attrPrefix A common prefix for the attribute type names of the * monitor attribute values, to distinguish the attributes of one * type of statistical object from another, and to avoid attribute name * collisions. */ private void addAttributesForStatsObject(ArrayList<Attribute> monitorAttrs, Object stats, String attrPrefix) { Class<?> c = stats.getClass(); Method[] methods = c.getMethods(); // Iterate through all the statistic class methods. for (Method method : methods) { // Invoke all the getters returning integer values. if (method.getName().startsWith("get")) { Class<?> returnType = method.getReturnType(); if (returnType.equals(int.class) || returnType.equals(long.class)) { AttributeSyntax<?> integerSyntax = DirectoryServer.getDefaultIntegerSyntax(); // Remove the 'get' from the method name and add the prefix. String attrName = attrPrefix + method.getName().substring(3); try { // Read the statistic. Object statValue = method.invoke(stats); // Create an attribute from the statistic. AttributeType attrType = DirectoryServer.getDefaultAttributeType(attrName, integerSyntax); monitorAttrs.add(Attributes.create(attrType, String.valueOf(statValue))); } catch (Exception e) { logger.traceException(e); } } } } } /** * Retrieves a set of attributes containing monitor data that should be * returned to the client if the corresponding monitor entry is requested. * @@ -196,11 +141,11 @@ AttributeBuilder needReindex = new AttributeBuilder("need-reindex"); for(EntryContainer ec : rootContainer.getEntryContainers()) { for(DatabaseContainer dc : ec.listDatabases()) for(Tree tree : ec.listTrees()) { if(dc instanceof Index && !((Index)dc).isTrusted()) if(tree instanceof Index && !((Index)tree).isTrusted()) { needReindex.add(dc.getName().toString()); needReindex.add(tree.getName().toString()); } } } opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java
@@ -43,11 +43,11 @@ import org.opends.server.types.DirectoryException; /** * This class represents the DN database, or dn2id, which has one record * This class represents the dn2id index, which has one record * for each entry. The key is the normalized entry DN and the value * is the entry ID. */ class DN2ID extends AbstractDatabaseContainer class DN2ID extends AbstractTree { private static final Function<ByteString, Void, DirectoryException> TO_VOID_KEY = new Function<ByteString, Void, DirectoryException>() @@ -73,11 +73,11 @@ /** * Create a DN2ID instance for the DN database in a given entryContainer. * Create a DN2ID instance for in a given entryContainer. * * @param treeName The name of the DN database. * @param baseDN The base DN of the database. * @throws StorageRuntimeException If an error occurs in the database. * @param treeName The name of the DN tree. * @param baseDN The base DN of the tree. * @throws StorageRuntimeException If an error occurs in the storage. */ DN2ID(TreeName treeName, DN baseDN) throws StorageRuntimeException { @@ -86,8 +86,8 @@ } /** * Adds a new record into the DN database replacing any existing record having the same DN. * @param txn a non null database transaction * Adds a new record into the DN tree replacing any existing record having the same DN. * @param txn a non null transaction * @param dn The entry DN, which is the key to the record. * @param id The entry ID, which is the value of the record. * @throws StorageRuntimeException If an error occurred while attempting to insert @@ -103,8 +103,8 @@ } /** * Remove a record from the DN database. * @param txn a non null database transaction * Remove a record from the DN tree. * @param txn a non null transaction * @param dn The entry DN, which is the key to the record. * @return true if the record was removed, false if it was not removed. * @throws StorageRuntimeException If an error occurred while attempting to remove @@ -117,10 +117,10 @@ /** * Fetch the entry ID for a given DN. * @param txn a non null database transaction * @param txn a non null transaction * @param dn The DN for which the entry ID is desired. * @return The entry ID, or null if the given DN is not in the DN database. * @throws StorageRuntimeException If an error occurs in the database. * @return The entry ID, or null if the given DN is not in the DN tree. * @throws StorageRuntimeException If an error occurs in the storage. */ EntryID get(ReadableTransaction txn, DN dn) throws StorageRuntimeException { opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java
@@ -62,7 +62,7 @@ import org.opends.server.util.StaticUtils; /** * This class represents the referral database which contains URIs from referral * This class represents the referral tree which contains URIs from referral * entries. * <p> * The key is the DN of the referral entry and the value is that of a pair @@ -70,10 +70,10 @@ * duplicated in the value because the key is suitable for comparisons but is * not reversible to a valid DN. Duplicate keys are permitted since a referral * entry can contain multiple values of the ref attribute. Key order is the same * as in the DN database so that all referrals in a subtree can be retrieved by * cursoring through a range of the records. * as in dn2id so that all referrals in a subtree can be retrieved by cursoring * through a range of the records. */ class DN2URI extends AbstractDatabaseContainer class DN2URI extends AbstractTree { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); @@ -88,7 +88,7 @@ /** * A flag that indicates whether there are any referrals contained in this * database. It should only be set to {@code false} when it is known that * tree. It should only be set to {@code false} when it is known that * there are no referrals. */ private volatile ConditionResult containsReferrals = @@ -96,15 +96,15 @@ /** * Create a new object representing a referral database in a given * Create a new object representing a referral tree in a given * entryContainer. * * @param treeName * The name of the referral database. * The name of the referral tree. * @param entryContainer * The entryContainer of the DN database. * The entryContainer of the DN tree. * @throws StorageRuntimeException * If an error occurs in the database. * If an error occurs in the storage. */ DN2URI(TreeName treeName, EntryContainer entryContainer) throws StorageRuntimeException { @@ -160,12 +160,12 @@ } /** * Puts a URI value in the referral database. * Puts a URI value in the referral tree. * * @param txn a non null database transaction * @param txn a non null transaction * @param dn The DN of the referral entry. * @param labeledURIs The labeled URI value of the ref attribute. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ private void put(final WriteableTransaction txn, final DN dn, final Collection<String> labeledURIs) throws StorageRuntimeException @@ -196,13 +196,13 @@ } /** * Delete URI values for a given referral entry from the referral database. * Delete URI values for a given referral entry from the referral tree. * * @param txn a non null database transaction * @param txn a non null transaction * @param dn The DN of the referral entry for which URI values are to be * deleted. * @return true if the values were deleted, false if not. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ private boolean delete(WriteableTransaction txn, DN dn) throws StorageRuntimeException { @@ -217,11 +217,11 @@ } /** * Delete a single URI value from the referral database. * @param txn a non null database transaction * Delete a single URI value from the referral tree. * @param txn a non null transaction * @param dn The DN of the referral entry. * @param labeledURIs The URI value to be deleted. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ private void delete(final WriteableTransaction txn, final DN dn, final Collection<String> labeledURIs) throws StorageRuntimeException @@ -248,10 +248,10 @@ } /** * Indicates whether the underlying database contains any referrals. * Indicates whether the underlying tree contains any referrals. * * @param txn The transaction to use when making the determination. * @return {@code true} if it is believed that the underlying database may * @return {@code true} if it is believed that the underlying tree may * contain at least one referral, or {@code false} if it is certain * that it doesn't. */ @@ -275,15 +275,15 @@ } /** * Update the referral database for an entry that has been modified. Does * Update the referral tree for an entry that has been modified. Does * not do anything unless the entry before the modification or the entry after * the modification is a referral entry. * * @param txn a non null database transaction * @param txn a non null transaction * @param before The entry before the modifications have been applied. * @param after The entry after the modifications have been applied. * @param mods The sequence of modifications made to the entry. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ void modifyEntry(WriteableTransaction txn, Entry before, Entry after, List<Modification> mods) throws StorageRuntimeException @@ -343,19 +343,19 @@ } /** * Update the referral database for an entry that has been replaced. Does not * Update the referral tree for an entry that has been replaced. Does not * do anything unless the entry before it was replaced or the entry after it * was replaced is a referral entry. * * @param txn * A database transaction used for the update, or null if none is * A transaction used for the update, or null if none is * required. * @param before * The entry before it was replaced. * @param after * The entry after it was replaced. * @throws StorageRuntimeException * If an error occurs in the database. * If an error occurs in the storage. */ void replaceEntry(WriteableTransaction txn, Entry before, Entry after) throws StorageRuntimeException @@ -365,11 +365,11 @@ } /** * Update the referral database for a new entry. Does nothing if the entry * Update the referral tree for a new entry. Does nothing if the entry * is not a referral entry. * @param txn a non null database transaction * @param txn a non null transaction * @param entry The entry to be added. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ void addEntry(WriteableTransaction txn, Entry entry) throws StorageRuntimeException @@ -382,11 +382,11 @@ } /** * Update the referral database for a deleted entry. Does nothing if the entry * Update the referral tree for a deleted entry. Does nothing if the entry * was not a referral entry. * @param txn a non null database transaction * @param txn a non null transaction * @param entry The entry to be deleted. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ void deleteEntry(WriteableTransaction txn, Entry entry) throws StorageRuntimeException { @@ -501,7 +501,7 @@ /** * Process referral entries that are above the target DN of an operation. * @param txn a non null database transaction * @param txn a non null transaction * @param targetDN The target DN of the operation, or the base object of a * search operation. * @param searchScope The scope of the search operation, or null if the @@ -558,8 +558,8 @@ /** * Return search result references for a search operation using the referral * database to find all referral entries within scope of the search. * @param txn a non null database transaction * tree to find all referral entries within scope of the search. * @param txn a non null transaction * @param searchOp The search operation for which search result references * should be returned. * @return <CODE>true</CODE> if the caller should continue processing the opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DataConfig.java
@@ -32,14 +32,14 @@ /** * Configuration class to indicate desired compression and cryptographic options * for the data stored in the database. * for the data stored in the tree. */ final class DataConfig { /** Indicates whether data should be compressed before writing to the database. */ /** Indicates whether data should be compressed before writing to the storage. */ private boolean compressed; /** The configuration to use when encoding entries in the database. */ /** The configuration to use when encoding entries in the tree. */ private EntryEncodeConfig encodeConfig; /** @@ -68,7 +68,7 @@ } /** * Determine whether data should be compressed before writing to the database. * Determine whether data should be compressed before writing to the tree. * @return true if data should be compressed, false if not. */ boolean isCompressed() opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java
@@ -55,7 +55,7 @@ * of a value) appearing in the entry. */ @SuppressWarnings("javadoc") class DefaultIndex extends AbstractDatabaseContainer implements Index class DefaultIndex extends AbstractTree implements Index { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); @@ -67,7 +67,7 @@ private final EntryIDSetCodec codec; /** * A flag to indicate if this index should be trusted to be consistent with the entries database. * A flag to indicate if this index should be trusted to be consistent with the entries tree. * If not trusted, we assume that existing entryIDSets for a key is still accurate. However, keys * that do not exist are undefined instead of an empty entryIDSet. The following rules will be * observed when the index is not trusted: - no entryIDs will be added to a non-existing key. - @@ -79,17 +79,17 @@ * Create a new index object. * * @param name * The name of the index database within the entryContainer. * The name of the index tree within the entryContainer. * @param state * The state database to persist index state info. * The state tree to persist index state info. * @param indexEntryLimit * The configured limit on the number of entry IDs that may be indexed by one key. * @param txn * a non null database transaction * a non null transaction * @param entryContainer * The database entryContainer holding this index. * The entryContainer holding this index. * @throws StorageRuntimeException * If an error occurs in the database. * If an error occurs in the storage. */ DefaultIndex(TreeName name, State state, int indexEntryLimit, WriteableTransaction txn, EntryContainer entryContainer) throws StorageRuntimeException opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DnKeyFormat.java
@@ -45,7 +45,7 @@ * key. The superior DN is represented by the initial bytes of the DN key. * * @param dnKey * The database key value of the DN. * The key value of the DN. * @return The length of the superior DN or -1 if the given dn is the root DN * or 0 if the superior DN is removed. */ @@ -70,7 +70,7 @@ } /** * Create a DN database key from an entry DN. * Create a DN key from an entry DN. * * @param dn The entry DN. * @param prefixRDNs The number of prefix RDNs to remove from the encoded opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -116,7 +116,7 @@ import org.opends.server.util.StaticUtils; /** * Storage container for LDAP entries. Each base DN of a JE backend is given * Storage container for LDAP entries. Each base DN of a backend is given * its own entry container. The entry container is the object that implements * the guts of the backend API methods for LDAP operations. */ @@ -127,21 +127,21 @@ /** Number of EntryID to considers when building EntryIDSet from DN2ID. */ private static final int SCOPE_IDSET_LIMIT = 4096; /** The name of the entry database. */ private static final String ID2ENTRY_DATABASE_NAME = ID2ENTRY_INDEX_NAME; /** The name of the DN database. */ private static final String DN2ID_DATABASE_NAME = DN2ID_INDEX_NAME; /** The name of the children index database. */ private static final String ID2CHILDREN_COUNT_DATABASE_NAME = ID2CHILDREN_COUNT_NAME; /** The name of the referral database. */ private static final String REFERRAL_DATABASE_NAME = REFERRAL_INDEX_NAME; /** The name of the state database. */ private static final String STATE_DATABASE_NAME = STATE_INDEX_NAME; /** The name of the entry tree. */ private static final String ID2ENTRY_TREE_NAME = ID2ENTRY_INDEX_NAME; /** The name of the DN tree. */ private static final String DN2ID_TREE_NAME = DN2ID_INDEX_NAME; /** The name of the children index tree. */ private static final String ID2CHILDREN_COUNT_TREE_NAME = ID2CHILDREN_COUNT_NAME; /** The name of the referral tree. */ private static final String REFERRAL_TREE_NAME = REFERRAL_INDEX_NAME; /** The name of the state tree. */ private static final String STATE_TREE_NAME = STATE_INDEX_NAME; /** The attribute index configuration manager. */ private final AttributeJEIndexCfgManager attributeJEIndexCfgManager; private final AttributeIndexCfgManager attributeIndexCfgManager; /** The vlv index configuration manager. */ private final VLVJEIndexCfgManager vlvJEIndexCfgManager; private final VLVIndexCfgManager vlvIndexCfgManager; /** The backend to which this entry container belongs. */ private final Backend<?> backend; @@ -155,18 +155,18 @@ /** The backend configuration. */ private PluggableBackendCfg config; /** The database storage. */ /** The tree storage. */ private final Storage storage; /** The DN database maps a normalized DN string to an entry ID (8 bytes). */ /** The DN tree maps a normalized DN string to an entry ID (8 bytes). */ private final DN2ID dn2id; /** The entry database maps an entry ID (8 bytes) to a complete encoded entry. */ /** The entry tree maps an entry ID (8 bytes) to a complete encoded entry. */ private ID2Entry id2entry; /** Store the number of children for each entry. */ private final ID2Count id2childrenCount; /** The referral database maps a normalized DN string to labeled URIs. */ /** The referral tree maps a normalized DN string to labeled URIs. */ private final DN2URI dn2uri; /** The state database maps a config DN to config entries. */ /** The state tree maps a config DN to config entries. */ private final State state; /** The set of attribute indexes. */ @@ -179,13 +179,13 @@ * Prevents name clashes for common indexes (like id2entry) across multiple suffixes. * For example when a root container contains multiple suffixes. */ private final String databasePrefix; private final String treePrefix; /** * This class is responsible for managing the configuration for attribute * indexes used within this entry container. */ private class AttributeJEIndexCfgManager implements private class AttributeIndexCfgManager implements ConfigurationAddListener<BackendIndexCfg>, ConfigurationDeleteListener<BackendIndexCfg> { @@ -291,7 +291,7 @@ * This class is responsible for managing the configuration for VLV indexes * used within this entry container. */ private class VLVJEIndexCfgManager implements private class VLVIndexCfgManager implements ConfigurationAddListener<BackendVLVIndexCfg>, ConfigurationDeleteListener<BackendVLVIndexCfg> { @@ -431,49 +431,49 @@ * * @param baseDN The baseDN this entry container will be responsible for * storing on disk. * @param backend A reference to the JE backend that is creating this entry * @param backend A reference to the backend that is creating this entry * container. It is needed by the Directory Server entry cache * methods. * @param config The configuration of the JE backend. * @param env The JE environment to create this entryContainer in. * @param config The configuration of the backend. * @param storage The storage for this entryContainer. * @param rootContainer The root container this entry container is in. * @throws ConfigException if a configuration related error occurs. */ EntryContainer(DN baseDN, Backend<?> backend, PluggableBackendCfg config, Storage env, RootContainer rootContainer) throws ConfigException EntryContainer(DN baseDN, Backend<?> backend, PluggableBackendCfg config, Storage storage, RootContainer rootContainer) throws ConfigException { this.backend = backend; this.baseDN = baseDN; this.config = config; this.storage = env; this.storage = storage; this.rootContainer = rootContainer; this.databasePrefix = baseDN.toNormalizedUrlSafeString(); this.id2childrenCount = new ID2Count(getIndexName(ID2CHILDREN_COUNT_DATABASE_NAME)); this.dn2id = new DN2ID(getIndexName(DN2ID_DATABASE_NAME), baseDN); this.dn2uri = new DN2URI(getIndexName(REFERRAL_DATABASE_NAME), this); this.state = new State(getIndexName(STATE_DATABASE_NAME)); this.treePrefix = baseDN.toNormalizedUrlSafeString(); this.id2childrenCount = new ID2Count(getIndexName(ID2CHILDREN_COUNT_TREE_NAME)); this.dn2id = new DN2ID(getIndexName(DN2ID_TREE_NAME), baseDN); this.dn2uri = new DN2URI(getIndexName(REFERRAL_TREE_NAME), this); this.state = new State(getIndexName(STATE_TREE_NAME)); config.addPluggableChangeListener(this); attributeJEIndexCfgManager = new AttributeJEIndexCfgManager(); config.addBackendIndexAddListener(attributeJEIndexCfgManager); config.addBackendIndexDeleteListener(attributeJEIndexCfgManager); attributeIndexCfgManager = new AttributeIndexCfgManager(); config.addBackendIndexAddListener(attributeIndexCfgManager); config.addBackendIndexDeleteListener(attributeIndexCfgManager); vlvJEIndexCfgManager = new VLVJEIndexCfgManager(); config.addBackendVLVIndexAddListener(vlvJEIndexCfgManager); config.addBackendVLVIndexDeleteListener(vlvJEIndexCfgManager); vlvIndexCfgManager = new VLVIndexCfgManager(); config.addBackendVLVIndexAddListener(vlvIndexCfgManager); config.addBackendVLVIndexDeleteListener(vlvIndexCfgManager); } private TreeName getIndexName(String indexId) { return new TreeName(databasePrefix, indexId); return new TreeName(treePrefix, indexId); } /** * Opens the entryContainer for reading and writing. * * @param txn a non null database transaction * @throws StorageRuntimeException If an error occurs in the database. * @param txn a non null transaction * @throws StorageRuntimeException If an error occurs in the storage. * @throws ConfigException if a configuration related error occurs. */ void open(WriteableTransaction txn) throws StorageRuntimeException, ConfigException @@ -485,7 +485,7 @@ config.isCompactEncoding(), rootContainer.getCompressedSchema()); id2entry = new ID2Entry(getIndexName(ID2ENTRY_DATABASE_NAME), entryDataConfig); id2entry = new ID2Entry(getIndexName(ID2ENTRY_TREE_NAME), entryDataConfig); id2entry.open(txn); id2childrenCount.open(txn); dn2id.open(txn); @@ -531,7 +531,7 @@ /** * Closes the entry container. * * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ @Override public void close() throws StorageRuntimeException @@ -541,10 +541,10 @@ // Deregister any listeners. config.removePluggableChangeListener(this); config.removeBackendIndexAddListener(attributeJEIndexCfgManager); config.removeBackendIndexDeleteListener(attributeJEIndexCfgManager); config.removeBackendVLVIndexAddListener(vlvJEIndexCfgManager); config.removeBackendVLVIndexDeleteListener(vlvJEIndexCfgManager); config.removeBackendIndexAddListener(attributeIndexCfgManager); config.removeBackendIndexDeleteListener(attributeIndexCfgManager); config.removeBackendVLVIndexAddListener(vlvIndexCfgManager); config.removeBackendVLVIndexDeleteListener(vlvIndexCfgManager); } /** @@ -560,10 +560,10 @@ } /** * Get the DN database used by this entry container. * Get the DN tree used by this entry container. * The entryContainer must have been opened. * * @return The DN database. * @return The DN tree. */ DN2ID getDN2ID() { @@ -571,10 +571,10 @@ } /** * Get the entry database used by this entry container. * Get the entry tree used by this entry container. * The entryContainer must have been opened. * * @return The entry database. * @return The entry tree. */ ID2Entry getID2Entry() { @@ -582,10 +582,10 @@ } /** * Get the referral database used by this entry container. * Get the referral tree used by this entry container. * The entryContainer must have been opened. * * @return The referral database. * @return The referral tree. */ DN2URI getDN2URI() { @@ -593,10 +593,10 @@ } /** * Get the children database used by this entry container. * Get the children tree used by this entry container. * The entryContainer must have been opened. * * @return The children database. * @return The children tree. */ ID2Count getID2ChildrenCount() { @@ -659,9 +659,9 @@ * Determine the highest entryID in the entryContainer. * The entryContainer must already be open. * * @param txn a non null database transaction * @param txn a non null transaction * @return The highest entry ID. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ EntryID getHighestEntryID(ReadableTransaction txn) throws StorageRuntimeException { @@ -709,7 +709,7 @@ * @param entryDN The distinguished name of the entry. * @return The number of children entries for the given entry or -1 if * the entry does not exist. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ long getNumberOfChildren(final DN entryDN) throws StorageRuntimeException { @@ -740,7 +740,7 @@ * @throws DirectoryException * If a problem occurs while processing the * search. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws CanceledOperationException if this operation should be cancelled. */ void search(final SearchOperation searchOperation) @@ -1099,9 +1099,9 @@ * Here we are relying on the DN key order to ensure children are * returned after their parents. * <ul> * <li>iterate through a subtree range of the DN database * <li>iterate through a subtree range of the DN tree * <li>discard non-children DNs if the search scope is single level * <li>fetch the entry by ID from the entry cache or the entry database * <li>fetch the entry by ID from the entry cache or the entry tree * <li>return the entry if it matches the filter * </ul> * @@ -1278,7 +1278,7 @@ /** * Returns the entry corresponding to the provided entryID. * * @param txn a non null database transaction * @param txn a non null transaction * @param entryID * the id of the entry to retrieve * @return the entry corresponding to the provided entryID @@ -1471,18 +1471,18 @@ } /** * Adds the provided entry to this database. This method must ensure that the * entry is appropriate for the database and that no entry already exists with * Adds the provided entry to this tree. This method must ensure that the * entry is appropriate for the tree and that no entry already exists with * the same DN. The caller must hold a write lock on the DN of the provided * entry. * * @param entry The entry to add to this database. * @param entry The entry to add to this tree. * @param addOperation The add operation with which the new entry is * associated. This may be <CODE>null</CODE> for adds * performed internally. * @throws DirectoryException If a problem occurs while trying to add the * entry. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws CanceledOperationException if this operation should be cancelled. */ void addEntry(final Entry entry, final AddOperation addOperation) @@ -1579,19 +1579,19 @@ } /** * Removes the specified entry from this database. This method must ensure * Removes the specified entry from this tree. This method must ensure * that the entry exists and that it does not have any subordinate entries * (unless the database supports a subtree delete operation and the client * (unless the storage supports a subtree delete operation and the client * included the appropriate information in the request). The caller must hold * a write lock on the provided entry DN. * * @param entryDN The DN of the entry to remove from this database. * @param entryDN The DN of the entry to remove from this tree. * @param deleteOperation The delete operation with which this action is * associated. This may be <CODE>null</CODE> for * deletes performed internally. * @throws DirectoryException If a problem occurs while trying to remove the * entry. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws CanceledOperationException if this operation should be cancelled. */ void deleteEntry(final DN entryDN, final DeleteOperation deleteOperation) @@ -1793,7 +1793,7 @@ dn2uri.checkTargetForReferral(entry, null); } // Update the referral database. // Update the referral tree. dn2uri.deleteEntry(txn, entry); // Remove from id2entry. @@ -1878,16 +1878,16 @@ } /** * Fetch an entry by DN, trying the entry cache first, then the database. * Fetch an entry by DN, trying the entry cache first, then the tree. * Retrieves the requested entry, trying the entry cache first, * then the database. * then the tree. * * @param entryDN The distinguished name of the entry to retrieve. * @return The requested entry, or <CODE>null</CODE> if the entry does not * exist. * @throws DirectoryException If a problem occurs while trying to retrieve * the entry. * @throws StorageRuntimeException An error occurred during a database operation. * @throws StorageRuntimeException An error occurred during a storage operation. */ Entry getEntry(final DN entryDN) throws StorageRuntimeException, DirectoryException { @@ -1960,7 +1960,7 @@ * @param modifyOperation The modify operation with which this action is * associated. This may be <CODE>null</CODE> for * modifications performed internally. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws DirectoryException If a Directory Server error occurs. * @throws CanceledOperationException if this operation should be cancelled. */ @@ -1989,7 +1989,7 @@ dn2uri.checkTargetForReferral(oldEntry, null); } // Update the referral database. // Update the referral tree. if (modifyOperation != null) { // In this case we know from the operation what the modifications were. @@ -2083,7 +2083,7 @@ * If this backend noticed and reacted * to a request to cancel or abandon the * modify DN operation. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ void renameEntry(final DN currentDN, final Entry entry, final ModifyDNOperation modifyDNOperation) throws StorageRuntimeException, DirectoryException, CanceledOperationException @@ -2299,7 +2299,7 @@ } } /** Represents an renamed entry that was deleted from JE but yet to be added back. */ /** Represents an renamed entry that was deleted from but yet to be added back. */ private static final class MovedEntry { private EntryID entryID; @@ -2518,7 +2518,7 @@ * @param buffer The index buffer used to buffer up the index changes. * @param entry The entry to be inserted into the indexes. * @param entryID The ID of the entry to be inserted into the indexes. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws DirectoryException If a Directory Server error occurs. */ private void indexInsertEntry(IndexBuffer buffer, Entry entry, EntryID entryID) @@ -2541,7 +2541,7 @@ * @param buffer The index buffer used to buffer up the index changes. * @param entry The entry to be removed from the indexes. * @param entryID The ID of the entry to be removed from the indexes. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws DirectoryException If a Directory Server error occurs. */ private void indexRemoveEntry(IndexBuffer buffer, Entry entry, EntryID entryID) @@ -2567,7 +2567,7 @@ * @param newEntry The contents of the entry after the change. * @param entryID The ID of the entry that was changed. * @param mods The sequence of modifications made to the entry. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws DirectoryException If a Directory Server error occurs. */ private void indexModifications(IndexBuffer buffer, Entry oldEntry, Entry newEntry, @@ -2594,10 +2594,10 @@ * Get a count of the number of entries stored in this entry container including the baseDN * * @param txn * a non null database transaction * a non null transaction * @return The number of entries stored in this entry container including the baseDN. * @throws StorageRuntimeException * If an error occurs in the database. * If an error occurs in the storage. */ long getNumberOfEntriesInBaseDN() throws StorageRuntimeException { @@ -2649,37 +2649,36 @@ * Delete this entry container from disk. The entry container should be * closed before calling this method. * * @param txn a non null database transaction * @param txn a non null transaction * @throws StorageRuntimeException If an error occurs while removing the entry * container. */ void delete(WriteableTransaction txn) throws StorageRuntimeException { for (DatabaseContainer db : listDatabases()) for (Tree tree : listTrees()) { db.delete(txn); tree.delete(txn); } } /** * Remove a database from disk. * Remove a tree from disk. * * @param txn a non null database transaction * @param database The database container to remove. * @throws StorageRuntimeException If an error occurs while attempting to delete the * database. * @param txn a non null transaction * @param tree The tree container to remove. * @throws StorageRuntimeException If an error occurs while attempting to delete the tree. */ void deleteDatabase(WriteableTransaction txn, DatabaseContainer database) throws StorageRuntimeException void deleteTree(WriteableTransaction txn, Tree tree) throws StorageRuntimeException { if(database == state) if(tree == state) { // The state database can not be removed individually. // The state tree can not be removed individually. return; } database.delete(txn); if(database instanceof Index) tree.delete(txn); if(tree instanceof Index) { state.deleteRecord(txn, database.getName()); state.deleteRecord(txn, tree.getName()); } } @@ -2690,21 +2689,21 @@ * * @return The container name for the base DN. */ String getDatabasePrefix() String getTreePrefix() { return databasePrefix; return treePrefix; } /** * Sets a new database prefix for this entry container and rename all * existing databases in use by this entry container. * Sets a new tree prefix for this entry container and rename all * existing trees in use by this entry container. * * @param newBaseDN The new database prefix to use. * @throws StorageRuntimeException If an error occurs in the database. * @param newBaseDN The new tree prefix to use. * @throws StorageRuntimeException If an error occurs in the storage. */ void setDatabasePrefix(final String newBaseDN) throws StorageRuntimeException void setTreePrefix(final String newBaseDN) throws StorageRuntimeException { final List<DatabaseContainer> databases = listDatabases(); final List<Tree> allTrees = listTrees(); try { // Rename in transaction. @@ -2713,20 +2712,20 @@ @Override public void run(WriteableTransaction txn) throws Exception { for(DatabaseContainer db : databases) for(Tree tree : allTrees) { TreeName oldName = db.getName(); TreeName oldName = tree.getName(); TreeName newName = oldName.replaceBaseDN(newBaseDN); txn.renameTree(oldName, newName); } } }); // Only rename the containers if the txn succeeded. for (DatabaseContainer db : databases) for (Tree tree : allTrees) { TreeName oldName = db.getName(); TreeName oldName = tree.getName(); TreeName newName = oldName.replaceBaseDN(newBaseDN); db.setName(newName); tree.setName(newName); } } catch (Exception e) @@ -2748,9 +2747,9 @@ public void run(WriteableTransaction txn) throws Exception { // Open the containers backup. for(DatabaseContainer db : databases) for(Tree tree : allTrees) { db.open(txn); tree.open(txn); } } }); @@ -2861,70 +2860,69 @@ private void clear0(WriteableTransaction txn) throws StorageRuntimeException { final List<DatabaseContainer> databases = listDatabases(); final List<Tree> allTrees = listTrees(); try { for (DatabaseContainer db : databases) for (Tree tree : allTrees) { db.delete(txn); tree.delete(txn); } } finally { for(DatabaseContainer db : databases) for(Tree tree : allTrees) { db.open(txn); tree.open(txn); } for (DatabaseContainer db : databases) for (Tree tree : allTrees) { if (db instanceof Index) if (tree instanceof Index) { ((Index) db).setTrusted(txn, true); ((Index) tree).setTrusted(txn, true); } } } } List<DatabaseContainer> listDatabases() List<Tree> listTrees() { final List<DatabaseContainer> databases = new ArrayList<DatabaseContainer>(); databases.add(dn2id); databases.add(id2entry); databases.add(dn2uri); databases.add(id2childrenCount); databases.add(state); final List<Tree> allTrees = new ArrayList<Tree>(); allTrees.add(dn2id); allTrees.add(id2entry); allTrees.add(dn2uri); allTrees.add(id2childrenCount); allTrees.add(state); for (AttributeIndex index : attrIndexMap.values()) { databases.addAll(index.getNameToIndexes().values()); allTrees.addAll(index.getNameToIndexes().values()); } databases.addAll(vlvIndexMap.values()); return databases; allTrees.addAll(vlvIndexMap.values()); return allTrees; } /** * Clear the contents for a database from disk. * Clear the contents for a tree from disk. * * @param txn a non null database transaction * @param database The database to clear. * @throws StorageRuntimeException if a database error occurs. * @param txn a non null transaction * @param tree The tree to clear. * @throws StorageRuntimeException if a storage error occurs. */ void clearDatabase(WriteableTransaction txn, DatabaseContainer database) throws StorageRuntimeException void clearTree(WriteableTransaction txn, Tree tree) throws StorageRuntimeException { try { database.delete(txn); tree.delete(txn); } finally { database.open(txn); tree.open(txn); } if(logger.isTraceEnabled()) { logger.trace("Cleared the database %s", database.getName()); logger.trace("Cleared the tree %s", tree.getName()); } } @@ -3219,7 +3217,7 @@ /** {@inheritDoc} */ @Override public String toString() { return databasePrefix; return treePrefix; } } opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryID.java
@@ -29,7 +29,7 @@ import org.forgerock.opendj.ldap.ByteString; /** * An integer identifier assigned to each entry in the JE backend. * An integer identifier assigned to each entry in the backend. * An entry ID is implemented by this class as a long. * There are static methods to assign monotonically increasing entry IDs, * starting from 1. @@ -38,7 +38,7 @@ { /** The identifier integer value. */ private final long id; /** The value in database format, created when necessary. */ /** The value in tree format, created when necessary. */ private ByteString value; /** @@ -51,8 +51,8 @@ } /** * Create a new entry ID object from a value in database format. * @param value The database value of the ID. * Create a new entry ID object from a value in tree format. * @param value The tree value of the ID. */ EntryID(ByteString value) { @@ -70,8 +70,8 @@ } /** * Get the value of the ID in database format. * @return The value of the ID in database format. * Get the value of the ID in tree format. * @return The value of the ID in tree format. */ ByteString toByteString() { opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java
@@ -291,14 +291,12 @@ */ private static final class UndefinedImpl implements EntryIDSetImplementor { /** * The database key containing this set, if the set was constructed directly from the database. */ private final ByteSequence databaseKey; /** The key containing this set, if the set was constructed directly from the tree. */ private final ByteSequence treeKey; UndefinedImpl(ByteSequence key) { databaseKey = checkNotNull(key, "key must not be null"); treeKey = checkNotNull(key, "key must not be null"); } @Override @@ -310,7 +308,7 @@ @Override public void toString(StringBuilder buffer) { if (databaseKey == NO_KEY) if (treeKey == NO_KEY) { buffer.append("[NOT-INDEXED]"); } opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ExportJob.java
@@ -47,7 +47,7 @@ import static org.opends.messages.BackendMessages.*; /** * Export a JE backend to LDIF. * Export a backend to LDIF. */ class ExportJob { @@ -87,7 +87,7 @@ /** * Export entries from the backend to an LDIF file. * @param rootContainer The root container to export. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws IOException If an I/O error occurs while writing an entry. * @throws LDIFException If an error occurs while trying to determine whether * to write an entry. @@ -185,7 +185,7 @@ * one of the base DNs. * @param entryContainer The entry container that holds the entries to be * exported. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws IOException If an error occurs while writing an entry. * @throws LDIFException If an error occurs while trying to determine * whether to write an entry. opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Count.java
@@ -38,10 +38,10 @@ import org.opends.server.backends.pluggable.spi.WriteableTransaction; /** * Store a counter associated to a key. Counter value is sharded amongst multiple database key to allow concurrent * Store a counter associated to a key. Counter value is sharded amongst multiple keys to allow concurrent * update without contention (at the price of a slower read). */ final class ID2Count extends AbstractDatabaseContainer final class ID2Count extends AbstractTree { /** * Must be a power of 2 @see <a href="http://en.wikipedia.org/wiki/Modulo_operation#Performance_issues">Performance @@ -129,7 +129,7 @@ /** * Get the counter value for the specified key * @param txn The database transaction * @param txn The transaction * @param entryID The entryID identifying to the counter * @return Value of the counter. 0 if no counter is associated yet. */ @@ -160,7 +160,7 @@ /** * Get the total counter value. The total counter maintain the sum of all * the counter contained in this tree. * @param txn The database transaction * @param txn The transaction * @return Sum of all the counter contained in this tree */ long getTotalCount(ReadableTransaction txn) @@ -170,7 +170,7 @@ /** * Delete the counter associated to the given key * @param txn The database transaction * @param txn The transaction * @param entryID The entryID identifying the counter * @return Value of the counter before it's deletion. */ opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java
@@ -56,10 +56,10 @@ import org.opends.server.types.LDAPException; /** * Represents the database containing the LDAP entries. The database key is * the entry ID and the value is the entry contents. * Represents the tree containing the LDAP entries. * The key is the entry ID and the value is the entry contents. */ class ID2Entry extends AbstractDatabaseContainer class ID2Entry extends AbstractTree { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); @@ -95,7 +95,7 @@ private static final class EntryCodec { /** The ASN1 tag for the ByteString type. */ private static final byte TAG_DATABASE_ENTRY = 0x60; private static final byte TAG_TREE_ENTRY = 0x60; private static final int BUFFER_INIT_SIZE = 512; private final ByteStringBuilder encodedBuffer = new ByteStringBuilder(); @@ -189,7 +189,7 @@ try { // Then start the ASN1 sequence. writer.writeStartSequence(TAG_DATABASE_ENTRY); writer.writeStartSequence(TAG_TREE_ENTRY); if (dataConfig.isCompressed()) { @@ -225,11 +225,11 @@ /** * Create a new ID2Entry object. * * @param name The name of the entry database. * @param name The name of the entry tree. * @param dataConfig The desired compression and encryption options for data * stored in the entry database. * @param entryContainer The entryContainer of the entry database. * @throws StorageRuntimeException If an error occurs in the database. * stored in the entry tree. * @param entryContainer The entryContainer of the entry tree. * @throws StorageRuntimeException If an error occurs in the storage. */ ID2Entry(TreeName name, DataConfig dataConfig) throws StorageRuntimeException { @@ -238,7 +238,7 @@ } /** * Decodes an entry from its database representation. * Decodes an entry from its tree representation. * <p> * An entry on disk is ASN1 encoded in this format: * @@ -260,7 +260,7 @@ * } * </pre> * * @param bytes A byte array containing the encoded database value. * @param bytes A byte array containing the encoded tree value. * @param compressedSchema The compressed schema manager to use when decoding. * @return The decoded entry. * @throws DecodeException If the data is not in the expected ASN.1 encoding @@ -288,11 +288,11 @@ } /** * Encodes an entry to the raw database format, with optional compression. * Encodes an entry to the raw tree format, with optional compression. * * @param entry The entry to encode. * @param dataConfig Compression and cryptographic options. * @return A ByteSTring containing the encoded database value. * @return A ByteSTring containing the encoded tree value. * * @throws DirectoryException If a problem occurs while attempting to encode * the entry. @@ -311,12 +311,12 @@ } /** * Write a record in the entry database. * Write a record in the entry tree. * * @param txn a non null database transaction * @param txn a non null transaction * @param id The entry ID which forms the key. * @param entry The LDAP entry. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws DirectoryException If a problem occurs while attempting to encode * the entry. */ @@ -337,12 +337,12 @@ } /** * Remove a record from the entry database. * Remove a record from the entry tree. * * @param txn a non null database transaction * @param txn a non null transaction * @param id The entry ID which forms the key. * @return true if the entry was removed, false if it was not. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ boolean remove(WriteableTransaction txn, EntryID id) throws StorageRuntimeException { @@ -350,13 +350,13 @@ } /** * Fetch a record from the entry database. * Fetch a record from the entry tree. * * @param txn a non null database transaction * @param txn a non null transaction * @param id The desired entry ID which forms the key. * @return The requested entry, or null if there is no such record. * @throws DirectoryException If a problem occurs while getting the entry. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ public Entry get(ReadableTransaction txn, EntryID id) throws DirectoryException, StorageRuntimeException @@ -365,13 +365,13 @@ } /** * Check that a record entry exists in the entry database. * Check that a record entry exists in the entry tree. * * @param txn a non null database transaction * @param txn a non null transaction * @param id The entry ID which forms the key. * @return True if an entry with entryID exists * @throws DirectoryException If a problem occurs while getting the entry. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ public boolean containsEntryID(ReadableTransaction txn, EntryID id) { @@ -403,10 +403,10 @@ /** * Set the desired compression and encryption options for data * stored in the entry database. * stored in the entry tree. * * @param dataConfig The desired compression and encryption options for data * stored in the entry database. * stored in the entry tree. */ void setDataConfig(DataConfig dataConfig) { opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportIDSet.java
@@ -38,7 +38,7 @@ /** * This class manages the set of ID that are to be eventually added to an index * database. It is responsible for determining if the number of IDs is above * tree. It is responsible for determining if the number of IDs is above * the configured ID limit. If the limit it reached, the class stops tracking * individual IDs and marks the set as undefined. This class is not thread safe. */ opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java
@@ -224,7 +224,7 @@ /** Map of DNs to Suffix objects. */ private final Map<DN, Suffix> dnSuffixMap = new LinkedHashMap<>(); /** Map of indexIDs to database containers. */ /** Map of indexIDs to indexes. */ private final ConcurrentHashMap<Integer, Index> indexIDToIndexMap = new ConcurrentHashMap<>(); /** Map of indexIDs to entry containers. */ private final ConcurrentHashMap<Integer, EntryContainer> indexIDToECMap = new ConcurrentHashMap<>(); @@ -634,7 +634,7 @@ } } private static int getIndexID(DatabaseContainer index) private static int getIndexID(Tree index) { return System.identityHashCode(index); } @@ -778,7 +778,7 @@ * @throws InitializationException * If an initialization error occurred. * @throws StorageRuntimeException * If the database had an error. * If the storage had an error. * @throws InterruptedException * If an interrupted error occurred. * @throws ExecutionException @@ -958,7 +958,7 @@ final EntryContainer replacement = suffix.getEntryContainer(); replacement.lock(); replacement.setDatabasePrefix(baseDN.toNormalizedUrlSafeString()); replacement.setTreePrefix(baseDN.toNormalizedUrlSafeString()); replacement.unlock(); rootContainer.registerEntryContainer(baseDN, replacement); } @@ -1635,7 +1635,7 @@ getAll(futures); } int processKey(DatabaseContainer container, ByteString key, EntryID entryID, int processKey(Tree container, ByteString key, EntryID entryID, IndexKey indexKey, boolean insert) throws InterruptedException { int sizeNeeded = IndexOutputBuffer.getRequiredSize(key.length(), entryID.longValue()); @@ -1708,7 +1708,7 @@ /** * This task reads sorted records from the temporary index scratch files, * processes the records and writes the results to the index database. The DN * processes the records and writes the results to the index tree. The DN * index is treated differently then non-DN indexes. */ private final class IndexDBWriteTask implements Callable<Void> @@ -2889,13 +2889,13 @@ { if (dn2uri != null) { entryContainer.clearDatabase(txn, entryContainer.getDN2URI()); entryContainer.clearTree(txn, entryContainer.getDN2URI()); } if (dn2id != null) { entryContainer.clearDatabase(txn, entryContainer.getDN2ID()); entryContainer.clearDatabase(txn, entryContainer.getID2ChildrenCount()); entryContainer.clearTree(txn, entryContainer.getDN2ID()); entryContainer.clearTree(txn, entryContainer.getID2ChildrenCount()); } for (Map.Entry<IndexKey, MatchingRuleIndex> mapEntry : indexMap.entrySet()) @@ -2903,7 +2903,7 @@ final Index index = mapEntry.getValue(); if (!index.isTrusted()) { entryContainer.clearDatabase(txn, index); entryContainer.clearTree(txn, index); } } @@ -2911,7 +2911,7 @@ { if (!vlvIndex.isTrusted()) { entryContainer.clearDatabase(txn, vlvIndex); entryContainer.clearTree(txn, vlvIndex); } } } @@ -2998,7 +2998,7 @@ case ALL: return getTotalIndexCount(cfg); case DEGRADED: // FIXME: since the environment is not started we cannot determine which // FIXME: since the storgae is not opened we cannot determine which // indexes are degraded. As a workaround, be conservative and assume all // indexes need rebuilding. return getTotalIndexCount(cfg); @@ -3244,7 +3244,7 @@ * Create a new rebuild index progress task. * * @throws StorageRuntimeException * If an error occurred while accessing the database. * If an error occurred while accessing the storage. */ public RebuildFirstPhaseProgressTask() throws StorageRuntimeException { @@ -3550,7 +3550,7 @@ * @return {@code true} if the DN was inserted in the cache, or {@code false} if the DN exists * in the cache already and could not be inserted. * @throws StorageRuntimeException * If an error occurs accessing the database. * If an error occurs accessing the storage. */ boolean insert(DN dn); @@ -3562,7 +3562,7 @@ * @return {@code true} if the cache contains the DN, or {@code false} if it * is not. * @throws StorageRuntimeException * If an error occurs reading the database. * If an error occurs reading the storage. */ boolean contains(DN dn) throws StorageRuntimeException; opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java
@@ -38,7 +38,7 @@ * is a byte array, and is constructed from some normalized form of an attribute value (or fragment * of a value) appearing in the entry. */ interface Index extends DatabaseContainer interface Index extends Tree { EntryIDSet get(ReadableTransaction txn, ByteSequence key); opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexBuffer.java
@@ -139,8 +139,7 @@ /** * Construct a new empty index buffer object. * * @param entryContainer The database entryContainer using this * index buffer. * @param entryContainer The entryContainer using this index buffer. */ IndexBuffer(EntryContainer entryContainer) { @@ -182,11 +181,10 @@ } /** * Flush the buffered index changes until the given transaction to * the database. * Flush the buffered index changes to storage. * * @param txn a non null database transaction * @throws StorageRuntimeException If an error occurs in the database. * @param txn a non null transaction * @throws StorageRuntimeException If an error occurs in the storage. * @throws DirectoryException If a Directory Server error occurs. */ void flush(WriteableTransaction txn) throws StorageRuntimeException, DirectoryException opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexFilter.java
@@ -72,13 +72,13 @@ * how the indexed contributed to the search operation. */ private final StringBuilder buffer; private final DatabaseEnvironmentMonitor monitor; private final BackendMonitor monitor; /** * Construct an index filter for a search operation. * * @param entryContainer The entry entryContainer. * @param txn a non null database transaction * @param txn a non null transaction * @param searchOp The search operation to be evaluated. * @param monitor The monitor to gather filter usage stats. * @param debugBuilder If not null, a diagnostic string will be written @@ -86,7 +86,7 @@ * to this search. */ IndexFilter(EntryContainer entryContainer, ReadableTransaction txn, SearchOperation searchOp, StringBuilder debugBuilder, DatabaseEnvironmentMonitor monitor) StringBuilder debugBuilder, BackendMonitor monitor) { this.entryContainer = entryContainer; this.txn = txn; opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexQueryFactoryImpl.java
@@ -79,7 +79,7 @@ @Override public EntryIDSet evaluate(LocalizableMessageBuilder debugMessage) { // Read the database and get Record for the key. // Read the tree and get Record for the key. // Select the right index to be used. final Index index = attributeIndex.getNameToIndexes().get(indexID); if (index == null) opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/PersistentCompressedSchema.java
@@ -52,15 +52,15 @@ /** * This class provides a compressed schema implementation whose definitions are * persisted in a database. * persisted in a tree. */ final class PersistentCompressedSchema extends CompressedSchema { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); /** The name of the database used to store compressed attribute description definitions. */ /** The name of the tree used to store compressed attribute description definitions. */ private static final String DB_NAME_AD = "compressed_attributes"; /** The name of the database used to store compressed object class set definitions. */ /** The name of the tree used to store compressed object class set definitions. */ private static final String DB_NAME_OC = "compressed_object_classes"; /** The compressed attribute description schema tree. */ @@ -68,7 +68,7 @@ /** The compressed object class set schema tree. */ private static final TreeName ocTreeName = new TreeName("compressed_schema", DB_NAME_OC); /** The storage in which the databases are held. */ /** The storage in which the trees are held. */ private Storage storage; private final ByteStringBuilder storeAttributeWriterBuffer = new ByteStringBuilder(); @@ -79,15 +79,14 @@ /** * Creates a new instance of this JE compressed schema manager. * Creates a new instance of this compressed schema manager. * * @param storage * A reference to the database environment in which the databases * will be held. * @param txn a non null database transaction * A reference to the storage in which the trees will be held. * @param txn a non null transaction * @throws StorageRuntimeException * If a database problem occurs while loading the compressed schema * definitions from the database. * If a problem occurs while loading the compressed schema * definitions from the tree. * @throws InitializationException * If an error occurs while loading and processing the compressed * schema definitions. @@ -150,11 +149,10 @@ /** * Loads the compressed schema information from the database. * Loads the compressed schema information from the tree. * * @throws StorageRuntimeException * If a database error occurs while loading the definitions from the * database. * If an error occurs while loading the definitions from the tree. * @throws InitializationException * If an error occurs while loading and processing the definitions. */ opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/RootContainer.java
@@ -72,7 +72,7 @@ import org.opends.server.util.LDIFReader; /** * Wrapper class for the JE environment. Root container holds all the entry * Wrapper class for a backend "container". Root container holds all the entry * containers for each base DN. It also maintains all the openings and closings * of the entry containers. */ @@ -116,15 +116,15 @@ private static final int IMPORT_PROGRESS_INTERVAL = 10000; /** The database storage. */ /** The tree storage. */ private Storage storage; /** The backend to which this entry root container belongs. */ private final BackendImpl<?> backend; /** The backend configuration. */ private final PluggableBackendCfg config; /** The database environment monitor for this JE environment. */ private DatabaseEnvironmentMonitor monitor; /** The monitor for this backend. */ private BackendMonitor monitor; /** The base DNs contained in this root container. */ private final ConcurrentHashMap<DN, EntryContainer> entryContainers = new ConcurrentHashMap<DN, EntryContainer>(); @@ -136,13 +136,12 @@ private PersistentCompressedSchema compressedSchema; /** * Creates a new RootContainer object. Each root container represents a JE * environment. * Creates a new RootContainer object representing a storage. * * @param config * The configuration of the JE backend. * The configuration of the backend. * @param backend * A reference to the JE back end that is creating this root * A reference to the backend that is creating this root * container. */ RootContainer(BackendImpl<?> backend, PluggableBackendCfg config) @@ -341,9 +340,9 @@ * Opens the root container. * * @throws StorageRuntimeException * If a database error occurs when creating the environment. * If an error occurs when opening the storage. * @throws ConfigException * If an configuration error occurs while creating the environment. * If an configuration error occurs while opening the storage. */ void open() throws StorageRuntimeException, ConfigException { @@ -378,7 +377,7 @@ * @param baseDN * The base DN of the entry container to open. * @param txn * The database transaction * The transaction * @return The opened entry container. * @throws StorageRuntimeException * If an error occurs while opening the entry container. @@ -411,7 +410,7 @@ // another to be opened. if (ec1 != null) { throw new InitializationException(ERR_ENTRY_CONTAINER_ALREADY_REGISTERED.get(ec1.getDatabasePrefix(), baseDN)); throw new InitializationException(ERR_ENTRY_CONTAINER_ALREADY_REGISTERED.get(ec1.getTreePrefix(), baseDN)); } this.entryContainers.put(baseDN, entryContainer); @@ -423,7 +422,7 @@ * @param baseDNs * The base DNs of the entry containers to open. * @throws StorageRuntimeException * If a database error occurs while opening the entry container. * If an error occurs while opening the entry container. * @throws InitializationException * If an initialization error occurs while opening the entry * container. @@ -473,24 +472,23 @@ } /** * Get the DatabaseEnvironmentMonitor object for JE environment used by this * root container. * Get the BackendMonitor object used by this root container. * * @return The DatabaseEnvironmentMonitor object. * @return The BackendMonitor object. */ DatabaseEnvironmentMonitor getMonitorProvider() BackendMonitor getMonitorProvider() { if (monitor == null) { String monitorName = backend.getBackendID() + " Database Storage"; monitor = new DatabaseEnvironmentMonitor(monitorName, this); String monitorName = backend.getBackendID() + " Storage"; monitor = new BackendMonitor(monitorName, this); } return monitor; } /** * Preload the database cache. There is no preload if the configured preload * Preload the tree cache. There is no preload if the configured preload * time limit is zero. * * @param timeLimit @@ -500,14 +498,14 @@ { if (timeLimit > 0) { // Get a list of all the databases used by the backend. final List<DatabaseContainer> databases = new ArrayList<DatabaseContainer>(); // Get a list of all the tree used by the backend. final List<Tree> trees = new ArrayList<>(); for (EntryContainer ec : entryContainers.values()) { ec.sharedLock.lock(); try { databases.addAll(ec.listDatabases()); trees.addAll(ec.listTrees()); } finally { @@ -516,9 +514,9 @@ } // Sort the list in order of priority. Collections.sort(databases, new DbPreloadComparator()); Collections.sort(trees, new TreePreloadComparator()); // Preload each database until we reach the time limit or the cache // Preload each tree until we reach the time limit or the cache // is filled. try { @@ -668,7 +666,7 @@ /** * Resets the next entry ID counter to zero. This should only be used after * clearing all databases. * clearing all trees. */ public void resetNextEntryID() { opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/State.java
@@ -44,9 +44,9 @@ /** * This class is responsible for storing the configuration state of * the JE backend for a particular suffix. * the backend for a particular suffix. */ class State extends AbstractDatabaseContainer class State extends AbstractTree { /** @@ -81,7 +81,7 @@ /** * Create a new State object. * * @param name The name of the entry database. * @param name The name of the entry tree. */ State(TreeName name) { @@ -94,12 +94,12 @@ } /** * Fetch index flags from the database. * @param txn The database transaction or null if none. * Fetch index flags from the tree. * @param txn The transaction or null if none. * @param indexTreeName The tree's name of the index * @return The flags of the index in the database or an empty set if no index has no flags. * @return The flags of the index in the tree or an empty set if no index has no flags. * @throws NullPointerException if tnx or index is null * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ EnumSet<IndexFlag> getIndexFlags(ReadableTransaction txn, TreeName indexTreeName) throws StorageRuntimeException { checkNotNull(txn, "txn must not be null"); @@ -111,11 +111,11 @@ /** * Ensure that the specified flags are set for the given index * @param txn a non null database transaction * @param txn a non null transaction * @param index The index storing the trusted state info. * @return true if the flags have been updated * @throws NullPointerException if txn, index or flags is null * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ boolean addFlagsToIndex(WriteableTransaction txn, TreeName indexTreeName, final IndexFlag... flags) { @@ -162,10 +162,10 @@ /** * Ensure that the specified flags are not set for the given index * @param txn a non null database transaction * @param txn a non null transaction * @param index The index storing the trusted state info. * @throws NullPointerException if txn, index or flags is null * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ void removeFlagsFromIndex(WriteableTransaction txn, TreeName indexTreeName, final IndexFlag... flags) { checkNotNull(txn, "txn must not be null"); @@ -185,13 +185,13 @@ } /** * Remove a record from the entry database. * Remove a record from the entry tree. * * @param txn a non null database transaction * @param txn a non null transaction * @param index The index storing the trusted state info. * @return true if the entry was removed, false if it was not. * @throws NullPointerException if txn, index is null * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ boolean deleteRecord(WriteableTransaction txn, TreeName indexTreeName) throws StorageRuntimeException { opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Suffix.java
@@ -97,7 +97,7 @@ /** * Returns the DN2ID instance pertaining to a suffix instance. * * @return A DN2ID instance that can be used to manipulate the DN2ID database. * @return A DN2ID instance that can be used to manipulate the DN2ID tree. */ public DN2ID getDN2ID() { @@ -108,8 +108,7 @@ /** * Returns the ID2Entry instance pertaining to a suffix instance. * * @return A ID2Entry instance that can be used to manipulate the ID2Entry * database. * @return A ID2Entry instance that can be used to manipulate the ID2Entry tree. */ public ID2Entry getID2Entry() { @@ -120,8 +119,7 @@ /** * Returns the DN2URI instance pertaining to a suffix instance. * * @return A DN2URI instance that can be used to manipulate the DN2URI * database. * @return A DN2URI instance that can be used to manipulate the DN2URI tree. */ public DN2URI getDN2URI() { @@ -199,18 +197,15 @@ * in the specified DN cache. This would indicate that the parent has already * been processed. It returns {@code false} otherwise. * * It will optionally check the dn2id database for the dn if the specified * It will optionally check the dn2id tree for the dn if the specified * cleared backend boolean is {@code true}. * * @param txn a non null database transaction * @param txn a non null transaction * @param dn The DN to check for. * @param dnCache The importer DN cache. * @param clearedBackend Set to {@code true} if the import process cleared the * backend before processing. * @return {@code true} if the dn is contained in the parent ID, or * {@code false} otherwise. * @throws StorageRuntimeException If an error occurred searching the DN cache, or * dn2id database. * @param clearedBackend Set to {@code true} if the import process cleared the backend before processing. * @return {@code true} if the dn is contained in the parent ID, or {@code false} otherwise. * @throws StorageRuntimeException If an error occurred searching the DN cache, or dn2id tree. * @throws InterruptedException If an error occurred processing the pending map */ public boolean isParentProcessed(ReadableTransaction txn, DN dn, DNCache dnCache, boolean clearedBackend) @@ -229,7 +224,7 @@ throw e; } // Either parent is in the DN cache, // or else check the dn2id database for the DN (only if backend wasn't cleared) // or else check the dn2id tree for the DN (only if backend wasn't cleared) final boolean parentThere = dnCache.contains(dn) || (!clearedBackend && getDN2ID().get(txn, dn) != null); @@ -251,7 +246,7 @@ /** * Sets the trusted status of all of the indexes and vlvIndexes. * * @param txn a non null database transaction * @param txn a non null transaction * @param trusted True if the indexes should be trusted or false otherwise. * @throws StorageRuntimeException If an error occurred setting the indexes to trusted. */ opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Tree.java
File was renamed from opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DatabaseContainer.java @@ -35,51 +35,51 @@ * This class is a wrapper around the tree object and provides basic * read and write methods for entries. */ interface DatabaseContainer interface Tree { /** * Opens a database in this database container. If the provided database configuration is * transactional, a transaction will be created and used to perform the open. * Opens a tree. If the provided configuration is transactional, * a transaction will be created and used to perform the open. * * @param txn * a non null database transaction * a non null transaction * @throws StorageRuntimeException * if a database error occurs while opening the index. * if an error occurs while opening the index. */ void open(WriteableTransaction txn) throws StorageRuntimeException; /** * Deletes this database and all of its contents. * Deletes this tree and all of its contents. * * @param txn * a non null database transaction * a non null transaction * @throws StorageRuntimeException * if a database error occurs while deleting the index. * if an error occurs while deleting the index. */ void delete(WriteableTransaction txn) throws StorageRuntimeException; /** * Returns the number of key/value pairs in this database container. * Returns the number of key/value pairs in this tree. * * @param txn * a non null database transaction * a non null transaction * @return the number of key/value pairs in the provided tree. * @throws StorageRuntimeException * If an error occurs in the DB operation. * If an error occurs in the storage operation. */ long getRecordCount(ReadableTransaction txn) throws StorageRuntimeException; /** * Get the database name for this database container. * Get the name for this tree. * * @return database name for this database container. * @return name for this tree. */ TreeName getName(); /** * Set the database name to use for this container. * Set the name to use for this tree. * * @param name The database name to use for this container. * @param name The name to use for this tree. */ void setName(TreeName name); } opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/TreePreloadComparator.java
File was renamed from opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DbPreloadComparator.java @@ -29,22 +29,21 @@ import java.util.Comparator; /** * This comparator is used to sort databases in order of priority * This comparator is used to sort trees in order of priority * for preloading into the cache. */ class DbPreloadComparator implements Comparator<DatabaseContainer> class TreePreloadComparator implements Comparator<Tree> { /** * Calculate the relative priority of a database for preloading. * Calculate the relative priority of a tree for preloading. * * @param database A handle to the database. * @return 1 for id2entry database, 2 for dn2id database, 3 for all others. * @param tree A handle to the tree. * @return 1 for id2entry tree, 2 for dn2id tree, 3 for all others. */ private static int priority(DatabaseContainer database) private static int priority(Tree tree) { String indexName = database.getName().getIndexId(); String indexName = tree.getName().getIndexId(); if (indexName.endsWith(SuffixContainer.ID2ENTRY_INDEX_NAME)) { return 1; @@ -64,15 +63,15 @@ * zero, or a positive integer as the first argument is less than, equal * to, or greater than the second. * * @param database1 the first object to be compared. * @param database2 the second object to be compared. * @param tree1 the first object to be compared. * @param tree2 the second object to be compared. * @return a negative integer, zero, or a positive integer as the * first argument is less than, equal to, or greater than the * second. **/ @Override public int compare(DatabaseContainer database1, DatabaseContainer database2) public int compare(Tree tree1, Tree tree2) { return priority(database1) - priority(database2); return priority(tree1) - priority(tree2); } } opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
@@ -79,15 +79,15 @@ import org.opends.server.util.StaticUtils; /** * This class represents a VLV index. Each database record corresponds to a single entry matching * This class represents a VLV index. Each record corresponds to a single entry matching * the VLV criteria. Keys are a sequence of the entry's normalized attribute values corresponding to * the VLV sort order, followed by the entry's entry ID. Records do not have a "value" since all * required information is held within the key. The entry ID is included in the key as a * "tie-breaker" and ensures that keys correspond to one and only one entry. This ensures that all * database updates can be performed using lock-free operations. * tree updates can be performed using lock-free operations. */ @SuppressWarnings("javadoc") class VLVIndex extends AbstractDatabaseContainer implements ConfigurationChangeListener<BackendVLVIndexCfg>, Closeable class VLVIndex extends AbstractTree implements ConfigurationChangeListener<BackendVLVIndexCfg>, Closeable { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); @@ -108,8 +108,7 @@ private final State state; /** * A flag to indicate if this vlvIndex should be trusted to be consistent with the entries * database. * A flag to indicate if this vlvIndex should be trusted to be consistent with the entries tree. */ private boolean trusted; @@ -117,7 +116,7 @@ final EntryContainer entryContainer, final WriteableTransaction txn) throws StorageRuntimeException, ConfigException { super(new TreeName(entryContainer.getDatabasePrefix(), "vlv." + config.getName())); super(new TreeName(entryContainer.getTreePrefix(), "vlv." + config.getName())); this.config = config; this.baseDN = config.getBaseDN(); opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VerifyJob.java
@@ -98,16 +98,16 @@ private IdentityHashMap<Index, HashMap<ByteString, Long>> entryLimitMap = new IdentityHashMap<Index, HashMap<ByteString, Long>>(); /** Indicates whether the DN database is to be verified. */ /** Indicates whether dn2id is to be verified. */ private boolean verifyDN2ID; /** Indicates whether the children count database is to be verified. */ /** Indicates whether the children count tree is to be verified. */ private boolean verifyID2ChildrenCount; /** The entry database. */ /** The entry tree. */ private ID2Entry id2entry; /** The DN database. */ /** The DN tree. */ private DN2ID dn2id; /** The children database. */ /** The children tree. */ private ID2Count id2childrenCount; /** A list of the attribute indexes to be verified. */ @@ -131,7 +131,7 @@ * * @param rootContainer The root container that holds the entries to verify. * @return The error count. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws DirectoryException If an error occurs while verifying the backend. */ long verifyBackend() throws StorageRuntimeException, @@ -347,7 +347,7 @@ * index completeness. We check that the ID for the entry is indeed * present in the indexes for the appropriate values. * * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ private void iterateID2Entry(ReadableTransaction txn) throws StorageRuntimeException { @@ -415,7 +415,7 @@ * index cleanliness. For each ID in the index we check that the * entry it refers to does indeed contain the expected value. * * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws DirectoryException If an error occurs reading values in the index. */ private void iterateIndex(ReadableTransaction txn) throws StorageRuntimeException, DirectoryException @@ -447,7 +447,7 @@ * Iterate through the entries in DN2ID to perform a check for * index cleanliness. * * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. */ private void iterateDN2ID(ReadableTransaction txn) throws StorageRuntimeException { @@ -612,7 +612,7 @@ * * @param vlvIndex The VLV index to perform the check against. * @param verifyID True to verify the IDs against id2entry. * @throws StorageRuntimeException If an error occurs in the database. * @throws StorageRuntimeException If an error occurs in the storage. * @throws DirectoryException If an error occurs reading values in the index. */ private void iterateVLVIndex(ReadableTransaction txn, VLVIndex vlvIndex, boolean verifyID) @@ -669,8 +669,8 @@ /** * Iterate through the entries in an attribute index to perform a check for * index cleanliness. * @param index The index database to be checked. * @throws StorageRuntimeException If an error occurs in the database. * @param index The index tree to be checked. * @throws StorageRuntimeException If an error occurs in the storage. */ private void iterateAttrIndex(ReadableTransaction txn, MatchingRuleIndex index, IndexingOptions options) throws StorageRuntimeException @@ -885,7 +885,7 @@ * Construct a printable string from a raw key value. * * @param indexName * The name of the index database containing the key value. * The name of the index tree containing the key value. * @param key * The bytes of the key. * @return A string that may be logged or printed. @@ -995,7 +995,7 @@ { logger.traceException(e); logger.trace("Error reading database: %s%n%s", e.getMessage(), keyDump(index.toString(), key)); logger.trace("Error reading tree: %s%n%s", e.getMessage(), keyDump(index.toString(), key)); } errorCount++; } @@ -1065,8 +1065,7 @@ * Create a new verify progress task. * @param indexIterator boolean, indicates if the task is iterating * through indexes or the entries. * @throws StorageRuntimeException An error occurred while accessing the JE * database. * @throws StorageRuntimeException An error occurred while accessing the storage. */ private ProgressTask(boolean indexIterator, ReadableTransaction txn) throws StorageRuntimeException {