mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
18.04.2014 be9f94f921957835e36578e31b5905a91de24cd3
OPENDJ-1602 New pluggable storage based backend

Reduced the number of compilation errors in package "org.opends.server.backends.pluggable".
Fixed NPEs where we passed null txn values as parameters.
8 files modified
71 ■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/backends/persistit/PersistItStorage.java 37 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java 1 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DbPreloadComparator.java 2 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java 10 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryIDSetSorter.java 8 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/IndexQueryFactoryImpl.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/Storage.java 7 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/WriteableStorage.java 2 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/persistit/PersistItStorage.java
@@ -235,6 +235,33 @@
                db.releaseExchange(ex);
            }
        }
        @Override
        public void truncateTree(TreeName treeName) {
            try {
                getVolume(treeName).truncate();
            } catch (PersistitException e) {
                throw new StorageRuntimeException(e);
            }
        }
        @Override
        public void renameTree(TreeName oldTreeName, TreeName newTreeName) {
            throw new UnsupportedOperationException();
        }
        @Override
        public void deleteTree(TreeName treeName) {
            Exchange ex = null;
            try {
                ex = getExchange(treeName);
                ex.removeTree();
            } catch (PersistitException e) {
                throw new StorageRuntimeException(e);
            } finally {
                db.releaseExchange(ex);
            }
        }
    }
    private final class CursorImpl implements Cursor {
@@ -472,4 +499,14 @@
    private Exchange getExchange0(TreeName treeName, boolean create) throws PersistitException {
        return db.getExchange(getVolume(treeName), treeName.toString(), create);
    }
    @Override
    public void closeTree(TreeName treeName) {
        // nothing to do, in persistit you close the volume itself
    }
    @Override
    public boolean isValid() {
        return !db.isFatal();
    }
}
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java
@@ -106,7 +106,6 @@
  public synchronized void close() throws StorageRuntimeException
  {
    storage.closeTree(treeName);
    treeName = null;
    if(logger.isTraceEnabled())
    {
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DbPreloadComparator.java
@@ -28,8 +28,6 @@
import java.util.Comparator;
import org.opends.server.backends.pluggable.spi.TreeName;
/**
 * This comparator is used to sort databases in order of priority
 * for preloading into the cache.
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java
@@ -988,7 +988,7 @@
                // default ordering. VLV search request goes through as if
                // this sort key was not found in the user entry.
                entryIDList =
                    EntryIDSetSorter.sort(EntryContainer.this, entryIDList, searchOperation,
                    EntryIDSetSorter.sort(EntryContainer.this, txn, entryIDList, searchOperation,
                        sortRequest.getSortOrder(), vlvRequest);
                if (sortRequest.containsSortKeys())
                {
@@ -1236,7 +1236,7 @@
          if (isInScope)
          {
            // Process the candidate entry.
            final Entry entry = getEntry(entryID);
            final Entry entry = getEntry(txn, entryID);
            if (entry != null)
            {
              lookthroughCount++;
@@ -1299,7 +1299,7 @@
   * @throws DirectoryException
   *           If an error occurs retrieving the entry
   */
  public Entry getEntry(EntryID entryID) throws DirectoryException
  public Entry getEntry(ReadableStorage txn, EntryID entryID) throws DirectoryException
  {
    // Try the entry cache first.
    final EntryCache entryCache = getEntryCache();
@@ -1309,7 +1309,7 @@
      return cacheEntry;
    }
    final Entry entry = id2entry.get(null, entryID, false);
    final Entry entry = id2entry.get(txn, entryID, false);
    if (entry != null)
    {
      // Put the entry in the cache making sure not to overwrite a newer copy
@@ -1391,7 +1391,7 @@
        Entry entry;
        try
        {
          entry = getEntry(id);
          entry = getEntry(txn, id);
        }
        catch (Exception e)
        {
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryIDSetSorter.java
@@ -35,6 +35,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.backends.pluggable.spi.ReadableStorage;
import org.opends.server.controls.VLVRequestControl;
import org.opends.server.controls.VLVResponseControl;
import org.opends.server.core.DirectoryServer;
@@ -55,7 +56,7 @@
   * Creates a new entry ID set which is a sorted representation of the provided
   * set using the given sort order.
   *
   * @param  suffixContainer  The suffix container with which the ID list is associated.
   * @param  entryContainer   The entry container with which the ID list is associated.
   * @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.
@@ -67,7 +68,8 @@
   *
   * @throws  DirectoryException  If an error occurs while performing the sort.
   */
  public static EntryIDSet sort(EntryContainer suffixContainer,
  public static EntryIDSet sort(EntryContainer entryContainer,
                                ReadableStorage txn,
                                EntryIDSet entryIDSet,
                                SearchOperation searchOperation,
                                SortOrder sortOrder,
@@ -88,7 +90,7 @@
    {
      try
      {
        Entry e = suffixContainer.getEntry(id);
        Entry e = entryContainer.getEntry(txn, id);
        if (e.matchesBaseAndScope(baseDN, scope) && filter.matchesEntry(e))
        {
          sortMap.put(new SortValues(id, e, sortOrder), id);
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/IndexQueryFactoryImpl.java
@@ -84,7 +84,7 @@
            return createMatchAllQuery().evaluate(debugMessage);
          }
          final EntryIDSet entrySet = index.readKey(key, null);
          final EntryIDSet entrySet = index.readKey(key, txn);
          if(debugMessage != null && !entrySet.isDefined())
          {
            updateStatsUndefinedResults(debugMessage, index);
@@ -166,7 +166,7 @@
            return new EntryIDSet();
          }
          final EntryIDSet entrySet = index.readKey(PresenceIndexer.presenceKey, null);
          final EntryIDSet entrySet = index.readKey(PresenceIndexer.presenceKey, txn);
          if (debugMessage != null && !entrySet.isDefined())
          {
            updateStatsUndefinedResults(debugMessage, index);
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/Storage.java
@@ -23,15 +23,12 @@
 *
 *      Copyright 2014 ForgeRock AS
 */
package org.opends.server.backends.pluggable.spi;
import java.io.Closeable;
import org.opends.server.admin.std.server.PersistitBackendCfg;
public interface Storage extends Closeable
{
  void initialize(PersistitBackendCfg cfg) throws Exception;
@@ -44,6 +41,10 @@
  void write(WriteOperation updateTransaction) throws Exception;
  void closeTree(TreeName treeName);
  boolean isValid();
  @Override
  void close();
}
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/spi/WriteableStorage.java
@@ -33,6 +33,8 @@
  void truncateTree(TreeName name);
  void renameTree(TreeName oldName, TreeName newName);
  void deleteTree(TreeName name);
  void create(TreeName name, ByteSequence key, ByteSequence value);