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

Jean-Noël Rouvignac
23.52.2015 0c7fb539fbcae9bd51fbff9f15fde8a30cc5ba4a
Run UCDetector on package org.opends.server.backends.pluggable
8 files modified
151 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendStat.java 26 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java 23 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java 32 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java 15 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java 9 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ShardedCounter.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/EntryIDSetTest.java 18 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/tasks/DummyTask.java 24 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendStat.java
@@ -102,7 +102,7 @@
   * Collects all necessary interaction interfaces with either a Backend using TreeNames
   * or a storage using Trees.
   */
  interface TreeKeyValue
  private interface TreeKeyValue
  {
    /**
     * Returns a key given a string representation of it.
@@ -139,11 +139,11 @@
  }
  /** Stays at the storage level when cursoring Trees. */
  static class StorageTreeKeyValue implements TreeKeyValue
  private static class StorageTreeKeyValue implements TreeKeyValue
  {
    private TreeName treeName;
    private final TreeName treeName;
    public StorageTreeKeyValue(TreeName treeName)
    private StorageTreeKeyValue(TreeName treeName)
    {
      this.treeName = treeName;
    }
@@ -174,12 +174,12 @@
  }
  /** Delegate key semantics to the backend. */
  static class BackendTreeKeyValue implements TreeKeyValue
  private static class BackendTreeKeyValue implements TreeKeyValue
  {
    private TreeName name;
    private Tree tree;
    private final TreeName name;
    private final Tree tree;
    public BackendTreeKeyValue(Tree tree)
    private BackendTreeKeyValue(Tree tree)
    {
      this.tree = tree;
      this.name = tree.getName();
@@ -215,13 +215,13 @@
  }
  /** Statistics collector. */
  class TreeStats
  private class TreeStats
  {
    final long count;
    final long totalKeySize;
    final long totalDataSize;
    private final long count;
    private final long totalKeySize;
    private final long totalDataSize;
    TreeStats(long count, long tks, long tds)
    private TreeStats(long count, long tks, long tds)
    {
      this.count = count;
      this.totalKeySize = tks;
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java
@@ -47,7 +47,6 @@
import org.opends.server.backends.pluggable.spi.SequentialCursor;
import org.opends.server.backends.pluggable.spi.StorageRuntimeException;
import org.opends.server.backends.pluggable.spi.TreeName;
import org.opends.server.backends.pluggable.spi.UpdateFunction;
import org.opends.server.backends.pluggable.spi.WriteableTransaction;
import org.opends.server.types.CanceledOperationException;
import org.opends.server.types.DN;
@@ -102,30 +101,12 @@
    txn.put(getName(), toKey(dn), toValue(entryID));
  }
  boolean insert(final WriteableTransaction txn, DN dn, final EntryID entryID) throws StorageRuntimeException
  {
    return txn.update(getName(), toKey(dn), new UpdateFunction()
    {
      @Override
      public ByteSequence computeNewValue(ByteSequence oldEntryID)
      {
        if (oldEntryID != null)
        {
          // no change
          return oldEntryID;
        }
        // it did not exist before, insert the new value
        return toValue(entryID);
      }
    });
  }
  ByteString toKey(DN dn)
  private ByteString toKey(DN dn)
  {
    return dnToDNKey(dn, baseDN.size());
  }
  ByteString toValue(final EntryID entryID)
  private ByteString toValue(final EntryID entryID)
  {
    // TODO JNR do we want to use compacted longs?
    return entryID.toByteString();
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java
@@ -80,8 +80,6 @@
    @Override
    Iterator<EntryID> iterator();
    Iterator<EntryID> iterator(EntryID begin);
  }
  /** Define serialization contract for EntryIDSet. */
@@ -265,12 +263,6 @@
    }
    @Override
    public Iterator<EntryID> iterator(EntryID begin)
    {
      return new IDSetIterator(entryIDs, begin == null ? 0 : begin.longValue());
    }
    @Override
    public long[] getRange()
    {
      if (entryIDs.length != 0)
@@ -363,12 +355,6 @@
    }
    @Override
    public Iterator<EntryID> iterator(EntryID begin)
    {
      return Iterators.emptyIterator();
    }
    @Override
    public long[] getRange()
    {
      return NO_ENTRY_IDS_RANGE;
@@ -392,12 +378,6 @@
      this.entryIDSet = entryIDSet;
    }
    IDSetIterator(long[] entryIDSet, long begin)
    {
      this(entryIDSet);
      currentIndex = Math.max(0, Arrays.binarySearch(entryIDSet, begin));
    }
    @Override
    public boolean hasNext()
    {
@@ -882,18 +862,6 @@
    return concreteImpl.iterator();
  }
  /**
   * Creates an iterator over the set or an empty iterator if the set is not defined.
   *
   * @param begin
   *          The entry ID of the first entry to return in the list.
   * @return An EntryID iterator.
   */
  public Iterator<EntryID> iterator(EntryID begin)
  {
    return concreteImpl.iterator(begin);
  }
  private long[] getIDs()
  {
    return concreteImpl.getIDs();
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java
@@ -29,8 +29,8 @@
import static org.forgerock.util.Reject.*;
import static org.forgerock.util.Utils.*;
import static org.opends.messages.BackendMessages.*;
import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.backends.pluggable.CursorTransformer.transformKeysAndValues;
import static org.opends.server.core.DirectoryServer.*;
import java.io.IOException;
import java.io.OutputStream;
@@ -359,19 +359,6 @@
  }
  /**
   * Remove a record from the entry tree.
   *
   * @param txn a non null transaction
   * @param entryID 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 storage.
   */
  boolean remove(WriteableTransaction txn, EntryID entryID) throws StorageRuntimeException
  {
    return txn.delete(getName(), entryID.toByteString());
  }
  /**
   * Fetch a record from the entry tree.
   *
   * @param txn a non null transaction
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java
@@ -25,6 +25,7 @@
package org.opends.server.backends.pluggable;
import static java.nio.channels.FileChannel.*;
import static org.forgerock.util.Utils.*;
import static org.opends.messages.BackendMessages.*;
import static org.opends.server.util.DynamicConstants.*;
@@ -965,14 +966,6 @@
      visitIndexes(entryContainer, setTrust(true, importer));
    }
    final void clearEntryContainerTrees(EntryContainer entryContainer)
    {
      for(Tree tree : entryContainer.listTrees())
      {
        importer.clearTree(tree.getName());
      }
    }
    final Chunk newExternalSortChunk(TreeName treeName) throws Exception
    {
      return new ExternalSortChunk(tempDir, treeName.toString(), bufferPool,
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ShardedCounter.java
@@ -217,13 +217,13 @@
   * Cursor that returns unique keys and null values. Ensure that {@link #getKey()} will return a different key after
   * each {@link #next()}.
   */
  static final class UniqueKeysCursor<K> implements SequentialCursor<K, Void>
  private static final class UniqueKeysCursor<K> implements SequentialCursor<K, Void>
  {
    private final Cursor<K, ?> delegate;
    private boolean isDefined;
    private K key;
    UniqueKeysCursor(Cursor<K, ?> cursor)
    private UniqueKeysCursor(Cursor<K, ?> cursor)
    {
      this.delegate = cursor;
      if (!delegate.isDefined())
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/EntryIDSetTest.java
@@ -36,6 +36,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
@Test(groups = { "precommit", "pluggablebackend", "unit" }, sequential=true)
public class EntryIDSetTest extends DirectoryServerTestCase
{
@@ -160,17 +161,6 @@
    assertIdsEquals(newDefinedSet(4, 6, 8, 10, 12).iterator(), 4, 6, 8, 10, 12);
  }
  @Test
  public void testDefinedIteratorWithBegin()
  {
    final EntryIDSet set = newDefinedSet(4, 6, 8, 10, 12);
    assertIdsEquals(set.iterator(id(4)), 4, 6, 8, 10, 12);
    assertIdsEquals(set.iterator(id(8)), 8, 10, 12);
    assertIdsEquals(set.iterator(id(12)), 12);
    assertIdsEquals(set.iterator(id(13)), 4, 6, 8, 10, 12);
  }
  @Test(dataProvider = "codecs")
  public void testCodecs(EntryIDSetCodec codec)
  {
@@ -253,12 +243,6 @@
  }
  @Test
  public void testUndefinedIteratorWithBegin()
  {
    assertThat(newUndefinedSet().iterator(id(8)).hasNext()).isFalse();
  }
  @Test
  public void testNewEmptySet()
  {
    assertThat(newDefinedSet().isDefined()).isTrue();
opendj-server-legacy/src/test/java/org/opends/server/tasks/DummyTask.java
@@ -26,13 +26,11 @@
 */
package org.opends.server.tasks;
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
import org.opends.server.types.Attribute;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -40,8 +38,7 @@
 * This class provides an implementation of a Directory Server task always
 * completes successfully.  It is intended only for testing purposes.
 */
public class DummyTask
       extends Task
public class DummyTask extends Task
{
  /** The length of time that the task should sleep before completing. */
  private long sleepTime;
@@ -52,15 +49,13 @@
   */
  private volatile TaskState interruptedState;
  /** {@inheritDoc} */
  @Override
  public LocalizableMessage getDisplayName() {
    return LocalizableMessage.raw("Dummy");
  }
  @Override
  public void initializeTask()
         throws DirectoryException
  public void initializeTask() throws DirectoryException
  {
    sleepTime = 0;
    interruptedState = null;
@@ -78,9 +73,7 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  protected TaskState runTask()
  {
    long stopTime = System.currentTimeMillis() + sleepTime;
@@ -89,7 +82,7 @@
      try
      {
        Thread.sleep(10);
      } catch (Exception e) {}
      } catch (InterruptedException e) {}
    }
    if (interruptedState != null)
@@ -99,18 +92,12 @@
    return TaskState.COMPLETED_SUCCESSFULLY;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isInterruptable()
  {
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public void interruptTask(TaskState taskState, LocalizableMessage interruptMessage)
  {
@@ -118,4 +105,3 @@
    setTaskInterruptState(taskState);
  }
}