From 5c58d43b2dc3023cce62a6eac98ab742c94ba13b Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 27 Jan 2015 17:00:39 +0000
Subject: [PATCH] OPENDJ-1716 Various PluggableBackend/Storage refactorings Code review: Nicolas Capponi
---
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java | 5
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryIDSetSorter.java | 5
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/StorageRuntimeException.java | 26 ++++++
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/WriteableStorage.java | 6
opendj-sdk/opendj3-server-dev/build.xml | 2
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JECompressedSchema.java | 4
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/RootContainer.java | 29 ++++++
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/AttributeIndex.java | 18 ++-
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java | 19 ++--
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/Cursor.java | 54 +++++++++++++
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/SortValuesSet.java | 8 -
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/IndexFilter.java | 4
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/TreeName.java | 47 ++++++++++-
13 files changed, 179 insertions(+), 48 deletions(-)
diff --git a/opendj-sdk/opendj3-server-dev/build.xml b/opendj-sdk/opendj3-server-dev/build.xml
index c8e48bf..f639dad 100644
--- a/opendj-sdk/opendj3-server-dev/build.xml
+++ b/opendj-sdk/opendj3-server-dev/build.xml
@@ -42,7 +42,6 @@
<!-- General server-wide properties -->
<property name="src.dir" location="src/server" />
- <property name="pluggablebackend.pkg" value="org/opends/server/backends/pluggable" />
<property name="build.dir" location="build" />
<property name="classes.dir" location="${build.dir}/classes" />
<property name="build.lib.dir" location="${build.dir}/lib" />
@@ -679,7 +678,6 @@
<fileset dir="${src.dir}">
<include name="**/*.java"/>
<exclude name="**/PublicAPI.java" />
- <exclude name="${pluggablebackend.pkg}/**/*.java" />
</fileset>
<formatter type="plain" />
</checkstyle>
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/AttributeIndex.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/AttributeIndex.java
index 0ce0c19..d3bb424 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/AttributeIndex.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/AttributeIndex.java
@@ -27,6 +27,10 @@
*/
package org.opends.server.backends.pluggable;
+import static org.opends.messages.JebMessages.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.io.Closeable;
import java.util.*;
@@ -53,10 +57,6 @@
import org.opends.server.types.*;
import org.opends.server.util.StaticUtils;
-import static org.opends.messages.JebMessages.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
* Class representing an attribute index.
* We have a separate database for each type of indexing, which makes it easy
@@ -131,9 +131,11 @@
*
* @param indexConfig The attribute index configuration.
* @param entryContainer The entryContainer of this attribute index.
+ * @param txn The database transaction
* @throws ConfigException if a configuration related error occurs.
*/
- public AttributeIndex(BackendIndexCfg indexConfig, EntryContainer entryContainer, WriteableStorage txn) throws ConfigException
+ public AttributeIndex(BackendIndexCfg indexConfig, EntryContainer entryContainer, WriteableStorage txn)
+ throws ConfigException
{
this.entryContainer = entryContainer;
this.indexConfig = indexConfig;
@@ -258,6 +260,7 @@
/**
* Open the attribute index.
*
+ * @param txn The database transaction
* @throws StorageRuntimeException if a JE database error occurs while
* opening the index.
*/
@@ -643,7 +646,7 @@
final ConfigChangeResult ccr = new ConfigChangeResult();
try
{
- entryContainer.getStorage().write(new WriteOperation()
+ entryContainer.getRootContainer().getStorage().write(new WriteOperation()
{
@Override
public void run(WriteableStorage txn) throws Exception
@@ -776,7 +779,8 @@
return rules;
}
- private void applyChangeToIndex(WriteableStorage txn, IndexType indexType, BackendIndexCfg cfg, ConfigChangeResult ccr)
+ private void applyChangeToIndex(final WriteableStorage txn, final IndexType indexType, final BackendIndexCfg cfg,
+ final ConfigChangeResult ccr)
{
String indexId = indexType.toString();
Index index = nameToIndexes.get(indexId);
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java
index 985a58b..1838e8b 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java
@@ -156,7 +156,8 @@
* @param txn The JE transaction handle, or null if none.
* @param key The record key.
* @param value The record value.
- * @return <code>true</code> if the key-value mapping could be inserted, <code>false</code> if the key was already mapped to another value
+ * @return {@code true} if the key-value mapping could be inserted,
+ * {@code false} if the key was already mapped to another value
* @throws StorageRuntimeException If an error occurs in the JE operation.
*/
boolean insert(WriteableStorage txn, ByteString key, ByteString value) throws StorageRuntimeException
@@ -174,7 +175,7 @@
* simple wrapper around the JE Database.delete method.
* @param txn The JE transaction handle, or null if none.
* @param key The key of the record to be read.
- * @return <code>true</code> if the key mapping was removed, <code>false</code> otherwise
+ * @return {@code true} if the key mapping was removed, {@code false} otherwise
* @throws StorageRuntimeException If an error occurs in the JE operation.
*/
boolean delete(WriteableStorage txn, ByteSequence key) throws StorageRuntimeException
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java
index 15af457..b83a2ea 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java
@@ -47,6 +47,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
@@ -88,7 +89,6 @@
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.CanceledOperationException;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
@@ -260,7 +260,7 @@
public void run(WriteableStorage txn) throws Exception
{
AttributeIndex index = attrIndexMap.get(cfg.getAttribute());
- deleteAttributeIndex(txn, index, ccr);
+ deleteAttributeIndex(txn, index);
attrIndexMap.remove(cfg.getAttribute());
}
});
@@ -471,6 +471,7 @@
/**
* Opens the entryContainer for reading and writing.
*
+ * @param txn The database transaction
* @throws StorageRuntimeException If an error occurs in the JE database.
* @throws ConfigException if a configuration related error occurs.
*/
@@ -595,11 +596,6 @@
return rootContainer;
}
- public Storage getStorage()
- {
- return storage;
- }
-
/**
* Get the DN database used by this entry container.
* The entryContainer must have been opened.
@@ -721,6 +717,7 @@
* Determine the highest entryID in the entryContainer.
* The entryContainer must already be open.
*
+ * @param txn The database transaction
* @return The highest entry ID.
* @throws StorageRuntimeException If an error occurs in the JE database.
*/
@@ -1312,6 +1309,7 @@
/**
* Returns the entry corresponding to the provided entryID.
*
+ * @param txn The database transaction
* @param entryID
* the id of the entry to retrieve
* @return the entry corresponding to the provided entryID
@@ -2743,6 +2741,7 @@
/**
* Get a count of the number of entries stored in this entry container.
*
+ * @param txn The database transaction
* @return The number of entries stored in this entry container.
* @throws StorageRuntimeException If an error occurs in the JE database.
*/
@@ -2844,6 +2843,7 @@
* Delete this entry container from disk. The entry container should be
* closed before calling this method.
*
+ * @param txn The database transaction
* @throws StorageRuntimeException If an error occurs while removing the entry
* container.
*/
@@ -2861,6 +2861,7 @@
/**
* Remove a database from disk.
*
+ * @param txn The database transaction
* @param database The database container to remove.
* @throws StorageRuntimeException If an error occurs while attempting to delete the
* database.
@@ -2888,8 +2889,7 @@
* @throws StorageRuntimeException If an JE database error occurs while attempting
* to delete the index.
*/
- private void deleteAttributeIndex(WriteableStorage txn, AttributeIndex attributeIndex, ConfigChangeResult ccr)
- throws StorageRuntimeException
+ private void deleteAttributeIndex(WriteableStorage txn, AttributeIndex attributeIndex) throws StorageRuntimeException
{
attributeIndex.close();
for (Index index : attributeIndex.getAllIndexes())
@@ -3247,6 +3247,7 @@
/**
* Creates a new index for an attribute.
*
+ * @param txn The database transaction
* @param indexName the name to give to the new index
* @param indexer the indexer to use when inserting data into the index
* @param indexEntryLimit the index entry limit
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryIDSetSorter.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryIDSetSorter.java
index 92372fd..2defe93 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryIDSetSorter.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryIDSetSorter.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
- * Portions Copyright 2011-2014 ForgeRock AS
+ * Portions Copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.backends.pluggable;
@@ -57,15 +57,14 @@
* set using the given sort order.
*
* @param entryContainer The entry container with which the ID list is associated.
+ * @param txn The database transaction
* @param entryIDSet The entry ID set to be sorted.
* @param searchOperation The search operation being processed.
* @param sortOrder The sort order to use for the entry ID set.
* @param vlvRequest The VLV request control included in the search
* request, or {@code null} if there was none.
- *
* @return A new entry ID set which is a sorted representation of the
* provided set using the given sort order.
- *
* @throws DirectoryException If an error occurs while performing the sort.
*/
public static EntryIDSet sort(EntryContainer entryContainer,
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/IndexFilter.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/IndexFilter.java
index 697bf5d..95e7b29 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/IndexFilter.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/IndexFilter.java
@@ -22,8 +22,7 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions copyright 2011-2014 ForgeRock AS
- *
+ * Portions copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.backends.pluggable;
@@ -73,6 +72,7 @@
* Construct an index filter for a search operation.
*
* @param entryContainer The entry entryContainer.
+ * @param txn The database 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
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JECompressedSchema.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JECompressedSchema.java
index bd25bae..f236ac7 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JECompressedSchema.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JECompressedSchema.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
- * Portions Copyright 2013-2014 ForgeRock AS.
+ * Portions Copyright 2013-2015 ForgeRock AS.
*/
package org.opends.server.backends.pluggable;
@@ -85,7 +85,7 @@
* @param storage
* A reference to the database environment in which the databases
* will be held.
- * @param txn
+ * @param txn The database transaction
* @throws StorageRuntimeException
* If a database problem occurs while loading the compressed schema
* definitions from the database.
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/RootContainer.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/RootContainer.java
index f7cc86f..1f1fc2b 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/RootContainer.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/RootContainer.java
@@ -42,6 +42,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.PersistitBackendCfg;
@@ -54,7 +55,6 @@
import org.opends.server.backends.pluggable.spi.WriteOperation;
import org.opends.server.backends.pluggable.spi.WriteableStorage;
import org.opends.server.core.DirectoryServer;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -75,6 +75,7 @@
public class RootContainer
implements ConfigurationChangeListener<PersistitBackendCfg>
{
+ /** Logs the progress of the import. */
private static final class ImportProgress implements Runnable
{
private final LDIFReader reader;
@@ -155,11 +156,25 @@
config.addPersistitChangeListener(this);
}
+ /**
+ * Returns the underlying storage engine.
+ *
+ * @return the underlying storage engine
+ */
PersistItStorage getStorage()
{
return storage;
}
+ /**
+ * Imports information from an LDIF file into this backend.
+ * This method should only be called if {@code supportsLDIFImport} returns {@code true}.
+ * Note that the server will not explicitly initialize this backend before calling this method.
+ *
+ * @param importConfig The configuration to use when performing the import.
+ * @return information about the result of the import processing.
+ * @throws DirectoryException If a problem occurs while performing the LDIF import.
+ */
LDIFImportResult importLDIF(LDIFImportConfig importConfig) throws DirectoryException
{
RuntimeInformation.logInfo();
@@ -187,7 +202,8 @@
long importCount = 0;
final long startTime = System.currentTimeMillis();
- timerService.scheduleAtFixedRate(new ImportProgress(reader), IMPORT_PROGRESS_INTERVAL, IMPORT_PROGRESS_INTERVAL, TimeUnit.MILLISECONDS);
+ timerService.scheduleAtFixedRate(new ImportProgress(reader),
+ IMPORT_PROGRESS_INTERVAL, IMPORT_PROGRESS_INTERVAL, TimeUnit.MILLISECONDS);
while (true)
{
final Entry entry;
@@ -318,6 +334,14 @@
}
}
+ /**
+ * Opens the root container.
+ *
+ * @throws StorageRuntimeException
+ * If a database error occurs when creating the environment.
+ * @throws ConfigException
+ * If an configuration error occurs while creating the environment.
+ */
void open() throws StorageRuntimeException, ConfigException
{
// Create the directory if it doesn't exist.
@@ -407,6 +431,7 @@
* @param baseDN The base DN of the entry container to open.
* @param name The name of the entry container or <CODE>NULL</CODE> to open
* the default entry container for the given base DN.
+ * @param txn The database transaction
* @return The opened entry container.
* @throws StorageRuntimeException If an error occurs while opening the entry
* container.
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/SortValuesSet.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/SortValuesSet.java
index 66db1f7..27e65b4 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/SortValuesSet.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/SortValuesSet.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.backends.pluggable;
@@ -98,7 +98,6 @@
* Add the given entryID and values from these sort values.
*
* @param sv The sort values to add.
- * @param types The types of the values to add.
* @throws DirectoryException If a Directory Server error occurs.
* @throws StorageRuntimeException If an error occurs in the JE database.
*/
@@ -232,7 +231,6 @@
*
* @param sv The sort values to remove.
* @throws DirectoryException If a Directory Server error occurs.
- * @throws StorageRuntimeException If an error occurs in the JE database.
*/
void remove(SortValues sv) throws DirectoryException
{
@@ -354,9 +352,9 @@
final ByteStringBuilder builder = new ByteStringBuilder(4 + entryIDs.length
* 8 + valuesBytes.length);
builder.append(entryIDs.length);
- for (int i = 0; i < entryIDs.length; i++)
+ for (long entryID : entryIDs)
{
- builder.append(entryIDs[i]);
+ builder.append(entryID);
}
builder.append(valuesBytes);
return builder.toByteString();
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/Cursor.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/Cursor.java
index 6e67586..7bd700d 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/Cursor.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/Cursor.java
@@ -21,9 +21,8 @@
* CDDL HEADER END
*
*
- * Copyright 2014 ForgeRock AS
+ * Copyright 2014-2015 ForgeRock AS
*/
-
package org.opends.server.backends.pluggable.spi;
import java.io.Closeable;
@@ -31,22 +30,73 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+/**
+ * Cursor that iterates through records in a tree.
+ */
public interface Cursor extends Closeable
{
+ /**
+ * Positions the cursor to the provided key if it exists in the tree.
+ *
+ * @param key
+ * the key where to position the cursor
+ * @return {@code true} if the cursor could be positioned to the key,
+ * {@code false} otherwise
+ */
boolean positionToKey(ByteSequence key);
+ /**
+ * Positions the cursor to the provided key if it exists in the tree,
+ * or else the lesser key greater than the provided key in the tree.
+ *
+ * @param key
+ * the key where to position the cursor
+ * @return {@code true} if the cursor could be positioned to the key,
+ * {@code false} otherwise
+ */
boolean positionToKeyOrNext(ByteSequence key);
+ /**
+ * Positions the cursor to the last key in the tree.
+ *
+ * @return {@code true} if the cursor could be positioned to the last key,
+ * {@code false} otherwise
+ */
boolean positionToLastKey();
+ /**
+ * Moves this cursor to the next record in the tree.
+ *
+ * @return {@code true} if the cursor could move to the next record,
+ * {@code false} if no next record exists
+ */
boolean next();
+ /**
+ * Moves this cursor to the previous record in the tree.
+ *
+ * @return {@code true} if the cursor could move to the previous record,
+ * {@code false} if no previous record exists
+ */
boolean previous();
+ /**
+ * Returns the key of the record on which this cursor is currently positioned.
+ *
+ * @return the current record's key,
+ * or {@code null} if this cursor is not positioned on any record.
+ */
ByteString getKey();
+ /**
+ * Returns the value of the record on which this cursor is currently positioned.
+ *
+ * @return the current record's value,
+ * or {@code null} if this cursor is not positioned on any record.
+ */
ByteString getValue();
+ /** {@inheritDoc} */
@Override
public void close();
}
\ No newline at end of file
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/StorageRuntimeException.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/StorageRuntimeException.java
index 963b2d0..c907b50 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/StorageRuntimeException.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/StorageRuntimeException.java
@@ -21,25 +21,47 @@
* CDDL HEADER END
*
*
- * Copyright 2014 ForgeRock AS
+ * Copyright 2014-2015 ForgeRock AS
*/
-
package org.opends.server.backends.pluggable.spi;
+/**
+ * Runtime exception for problems happening in the storage engine.
+ */
@SuppressWarnings("serial")
public final class StorageRuntimeException extends RuntimeException
{
+ /**
+ * Constructor with a message.
+ *
+ * @param message
+ * the exception message
+ */
public StorageRuntimeException(final String message)
{
super(message);
}
+ /**
+ * Constructor with a message and a cause.
+ *
+ * @param message
+ * the exception message
+ * @param cause
+ * the cause of the exception
+ */
public StorageRuntimeException(final String message, final Throwable cause)
{
super(message, cause);
}
+ /**
+ * Constructor with a cause.
+ *
+ * @param cause
+ * the cause of the exception
+ */
public StorageRuntimeException(final Throwable cause)
{
super(cause);
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/TreeName.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/TreeName.java
index fa100c3..d52866c 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/TreeName.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/TreeName.java
@@ -21,17 +21,30 @@
* CDDL HEADER END
*
*
- * Copyright 2014 ForgeRock AS
+ * Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.backends.pluggable.spi;
-/** Assumes name components don't contain a '/'. */
+/**
+ * Represents the name of a tree (key-value store) in a database.
+ * A tree name is made of the baseDN it is part of, and the identifier of the index it represents.
+ * <p>
+ * Note: This class assumes name components don't contain a '/'.
+ */
public final class TreeName
{
private final String baseDN;
private final String indexId;
private final String s;
+ /**
+ * Builds a tree name.
+ *
+ * @param baseDN
+ * the base DN
+ * @param indexId
+ * the index identifier
+ */
public TreeName(String baseDN, String indexId)
{
this.baseDN = baseDN;
@@ -39,21 +52,39 @@
this.s = '/' + baseDN + '/' + indexId;
}
+ /**
+ * Returns the base DN.
+ *
+ * @return a {@code String} representing the base DN
+ */
public String getBaseDN()
{
return baseDN;
}
- public TreeName replaceBaseDN(String newBaseDN)
- {
- return new TreeName(newBaseDN, indexId);
- }
-
+ /**
+ * Returns the index identifier.
+ *
+ * @return a {@code String} representing the base DN
+ */
public String getIndexId()
{
return indexId;
}
+ /**
+ * Returns a new tree name object created by replacing the baseDN of the current object.
+ *
+ * @param newBaseDN
+ * the new base DN that replaces the existing base DN
+ * @return a new tree name object with the provided the base DN
+ */
+ public TreeName replaceBaseDN(String newBaseDN)
+ {
+ return new TreeName(newBaseDN, indexId);
+ }
+
+ /** {@inheritDoc} */
@Override
public boolean equals(final Object obj)
{
@@ -71,12 +102,14 @@
}
}
+ /** {@inheritDoc} */
@Override
public int hashCode()
{
return s.hashCode();
}
+ /** {@inheritDoc} */
@Override
public String toString()
{
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/WriteableStorage.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/WriteableStorage.java
index 7d0f13f..a501872 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/WriteableStorage.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/WriteableStorage.java
@@ -33,7 +33,7 @@
public interface WriteableStorage extends ReadableStorage
{
/**
- * Opens the tree having the provided name. The tree is created if does not already exist.
+ * Opens the tree identified by the provided name. The tree is created if it does not already exist.
*
* @param name
* the tree name
@@ -41,7 +41,7 @@
void openTree(TreeName name);
/**
- * Truncates the tree having the provided name. It removes all the records in the tree.
+ * Truncates the tree identified by the provided name. It removes all the records in the tree.
*
* @param name
* the tree name
@@ -59,7 +59,7 @@
void renameTree(TreeName oldName, TreeName newName);
/**
- * Deletes the tree having the provided name.
+ * Deletes the tree identified by the provided name.
*
* @param name
* the tree name
--
Gitblit v1.10.0