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

Jean-Noel Rouvignac
16.29.2015 2b32de2e46f63f9949886386cfe7edcb97c16d1b
Remove dead code

Index.java:
Removed curLocal field (not used anywhere) + removed closeCursor() as a consequence

Importer.java:
Some code cleanup.
3 files modified
179 ■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/backends/jeb/Index.java 82 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java 81 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/Index.java 16 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/Index.java
@@ -22,10 +22,14 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2014 ForgeRock AS
 *      Portions Copyright 2012-2015 ForgeRock AS
 */
package org.opends.server.backends.jeb;
import static com.sleepycat.je.OperationStatus.*;
import static org.opends.messages.JebMessages.*;
import java.util.*;
import org.forgerock.i18n.slf4j.LocalizedLogger;
@@ -42,10 +46,6 @@
import com.sleepycat.je.*;
import static com.sleepycat.je.OperationStatus.*;
import static org.opends.messages.JebMessages.*;
/**
 * Represents an index implemented by a JE database in which each key maps to
 * a set of entry IDs.  The key is a byte array, and is constructed from some
@@ -109,8 +109,6 @@
   */
  private boolean rebuildRunning;
  /** Thread local area to store per thread cursors. */
  private final ThreadLocal<Cursor> curLocal = new ThreadLocal<Cursor>();
  private final ImportIDSet newImportIDSet;
  /**
@@ -172,7 +170,15 @@
    getBufferedIndexValues(buffer, keyBytes).addEntryID(keyBytes, entryID);
  }
  private void deleteKey(DatabaseEntry key, ImportIDSet importIdSet, DatabaseEntry data) throws DatabaseException {
  /**
   * Delete the specified import ID set from the import ID set associated with the key.
   *
   * @param key The key to delete the set from.
   * @param importIdSet The import ID set to delete.
   * @param data A database entry to use for data.
   * @throws DatabaseException If a database error occurs.
   */
  public void delete(DatabaseEntry key, ImportIDSet importIdSet, DatabaseEntry data) throws DatabaseException {
    final OperationStatus status = read(null, key, data, LockMode.DEFAULT);
    if(status == SUCCESS) {
      newImportIDSet.clear(false);
@@ -192,7 +198,15 @@
    }
  }
  private void insertKey(DatabaseEntry key, ImportIDSet importIdSet, DatabaseEntry data) throws DatabaseException {
  /**
   * Insert the specified import ID set into this index. Creates a DB cursor if needed.
   *
   * @param key The key to add the set to.
   * @param importIdSet The set of import IDs.
   * @param data Database entry to reuse for read.
   * @throws DatabaseException If a database error occurs.
   */
  public void insert(DatabaseEntry key, ImportIDSet importIdSet, DatabaseEntry data) throws DatabaseException {
    final OperationStatus status = read(null, key, data, LockMode.DEFAULT);
    if(status == OperationStatus.SUCCESS) {
      newImportIDSet.clear(false);
@@ -215,43 +229,6 @@
  }
  /**
   * Insert the specified import ID set into this index. Creates a DB
   * cursor if needed.
   *
   * @param key The key to add the set to.
   * @param importIdSet The set of import IDs.
   * @param data Database entry to reuse for read.
   * @throws DatabaseException If a database error occurs.
   */
  public void insert(DatabaseEntry key, ImportIDSet importIdSet, DatabaseEntry data) throws DatabaseException {
    Cursor cursor = curLocal.get();
    if(cursor == null) {
      cursor = openCursor(null, null);
      curLocal.set(cursor);
    }
    insertKey(key, importIdSet, data);
  }
  /**
   * Delete the specified import ID set from the import ID set associated with
   * the key.
   *
   * @param key The key to delete the set from.
   * @param importIdSet The import ID set to delete.
   * @param data A database entry to use for data.
   *
   * @throws DatabaseException If a database error occurs.
   */
  public void delete(DatabaseEntry key, ImportIDSet importIdSet, DatabaseEntry data) throws DatabaseException {
    Cursor cursor = curLocal.get();
    if(cursor == null) {
      cursor = openCursor(null, null);
      curLocal.set(cursor);
    }
    deleteKey(key, importIdSet, data);
  }
  /**
   * Update the set of entry IDs for a given key.
   *
   * @param txn A database transaction, or null if none is required.
@@ -727,19 +704,6 @@
  }
  /**
   * Close any cursors open against this index.
   *
   * @throws DatabaseException  If a database error occurs.
   */
  public void closeCursor() throws DatabaseException {
    Cursor cursor = curLocal.get();
    if(cursor != null) {
      cursor.close();
      curLocal.remove();
    }
  }
  /**
   * Update the index buffer for a deleted entry.
   *
   * @param buffer The index buffer to use to store the deleted keys
opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
@@ -1873,10 +1873,6 @@
        }
        else
        {
          for (Index index : indexMap.values())
          {
            index.closeCursor();
          }
          if (!isCanceled)
          {
            logger.info(NOTE_JEB_IMPORT_LDIF_INDEX_CLOSE, indexMgr.getBufferFileName());
@@ -2361,7 +2357,6 @@
          dnKey.setData(key);
          index.insert(dnKey, idSet, dnValue);
        }
        index.closeCursor();
        if (clearMap)
        {
          map.clear();
@@ -3459,23 +3454,11 @@
                found = true;
                LocalDBIndexCfg indexCfg = cfg.getLocalDBIndex(idx);
                SortedSet<IndexType> indexType = indexCfg.getIndexType();
                if (indexType.contains(EQUALITY))
                {
                  indexCount++;
                }
                if (indexType.contains(ORDERING))
                {
                  indexCount++;
                }
                if (indexType.contains(PRESENCE))
                {
                  indexCount++;
                }
                if (indexType.contains(SUBSTRING))
                {
                  indexCount++;
                }
                if (indexType.contains(APPROXIMATE))
                if (indexType.contains(EQUALITY)
                    || indexType.contains(ORDERING)
                    || indexType.contains(PRESENCE)
                    || indexType.contains(SUBSTRING)
                    || indexType.contains(APPROXIMATE))
                {
                  indexCount++;
                }
@@ -3618,7 +3601,7 @@
     *
     * @return The total number for entries to process.
     */
    public long getTotEntries()
    public long getTotalEntries()
    {
      return this.totalEntries;
    }
@@ -3654,15 +3637,9 @@
     * progress report.
     */
    private long previousProcessed;
    /**
     * The time in milliseconds of the previous progress report.
     */
    /** The time in milliseconds of the previous progress report. */
    private long previousTime;
    /**
     * The environment statistics at the time of the previous report.
     */
    /** The environment statistics at the time of the previous report. */
    private EnvironmentStats prevEnvStats;
    /**
@@ -3694,12 +3671,12 @@
      long deltaCount = entriesProcessed - previousProcessed;
      float rate = 1000f * deltaCount / deltaTime;
      float completed = 0;
      if (rebuildManager.getTotEntries() > 0)
      if (rebuildManager.getTotalEntries() > 0)
      {
        completed = 100f * entriesProcessed / rebuildManager.getTotEntries();
        completed = 100f * entriesProcessed / rebuildManager.getTotalEntries();
      }
      logger.info(NOTE_JEB_REBUILD_PROGRESS_REPORT, completed, entriesProcessed,
              rebuildManager.getTotEntries(), rate);
          rebuildManager.getTotalEntries(), rate);
      try
      {
        Runtime runtime = Runtime.getRuntime();
@@ -3736,26 +3713,16 @@
     * progress report.
     */
    private long previousCount;
    /**
     * The time in milliseconds of the previous progress report.
     */
    /** The time in milliseconds of the previous progress report. */
    private long previousTime;
    /**
     * The environment statistics at the time of the previous report.
     */
    /** The environment statistics at the time of the previous report. */
    private EnvironmentStats previousStats;
    /** Determines if eviction has been detected. */
    private boolean evicting;
    /** Entry count when eviction was detected. */
    private long evictionEntryCount;
    /**
     * Create a new import progress task.
     */
    /** Create a new import progress task. */
    public FirstPhaseProgressTask()
    {
      previousTime = System.currentTimeMillis();
@@ -3769,9 +3736,7 @@
      }
    }
    /**
     * The action to be performed by this timer task.
     */
    /** The action to be performed by this timer task. */
    @Override
    public void run()
    {
@@ -3864,20 +3829,12 @@
     * progress report.
     */
    private long previousCount;
    /**
     * The time in milliseconds of the previous progress report.
     */
    /** The time in milliseconds of the previous progress report. */
    private long previousTime;
    /**
     * The environment statistics at the time of the previous report.
     */
    /** The environment statistics at the time of the previous report. */
    private EnvironmentStats previousStats;
    /** Determines if eviction has been detected. */
    private boolean evicting;
    private long latestCount;
    /**
@@ -3900,9 +3857,7 @@
      }
    }
    /**
     * The action to be performed by this timer task.
     */
    /** The action to be performed by this timer task. */
    @Override
    public void run()
    {
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/Index.java
@@ -106,9 +106,6 @@
   */
  private boolean rebuildRunning;
  /** Thread local area to store per thread cursors. */
  private final ThreadLocal<Cursor> curLocal = new ThreadLocal<Cursor>();
  /**
   * Create a new index object.
   * @param name The name of the index database within the entryContainer.
@@ -591,19 +588,6 @@
  }
  /**
   * Close any cursors open against this index.
   *
   * @throws StorageRuntimeException  If a database error occurs.
   */
  public void closeCursor() throws StorageRuntimeException {
    Cursor cursor = curLocal.get();
    if(cursor != null) {
      cursor.close();
      curLocal.remove();
    }
  }
  /**
   * Update the index buffer for a deleted entry.
   *
   * @param buffer The index buffer to use to store the deleted keys