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

Jean-Noel Rouvignac
08.55.2013 68fde1b50ba683919007b188eccc917708e8a7de
OPENDJ-1116 Introduce abstraction for the changelog DB


Tightening up the interfaces after review from Matthew Swift

CNIndexRecord.java:
Now final, removed a useless call to super().

ChangeNumberIndexDB.java, JEChangeNumberIndexDB.java:
Removed methods from the interface that ought not to be exposed to clients but remain internal to the implementation.
Moved javadocs to the implementation.

JEChangelogDB.java:
Reference JEChangeNumberIndexDB instead of ChangeNumberIndexDB due to the change above.
4 files modified
79 ■■■■■ changed files
opends/src/server/org/opends/server/replication/server/changelog/api/CNIndexRecord.java 3 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/api/ChangeNumberIndexDB.java 39 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDB.java 35 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/api/CNIndexRecord.java
@@ -33,7 +33,7 @@
 * The Change Number Index Data class represents records stored in the
 * {@link ChangeNumberIndexDB}.
 */
public class CNIndexRecord
public final class CNIndexRecord
{
  /** This is the key used to store the rest of the . */
@@ -57,7 +57,6 @@
  public CNIndexRecord(long changeNumber, String previousCookie, DN baseDN,
      CSN csn)
  {
    super();
    this.changeNumber = changeNumber;
    this.previousCookie = previousCookie;
    this.baseDN = baseDN;
opends/src/server/org/opends/server/replication/server/changelog/api/ChangeNumberIndexDB.java
@@ -26,7 +26,6 @@
 */
package org.opends.server.replication.server.changelog.api;
import org.opends.server.types.DN;
/**
 * This class stores an index of all the changes seen by this server in the form
@@ -118,42 +117,4 @@
  ChangeNumberIndexDBCursor getCursorFrom(long startChangeNumber)
      throws ChangelogException;
  /**
   * Returns whether this database is empty.
   *
   * @return <code>true</code> if this database is empty, <code>false</code>
   *         otherwise
   * @throws ChangelogException
   *           if a database problem occurs.
   */
  boolean isEmpty() throws ChangelogException;
  /**
   * Clear the changes from this DB (from both memory cache and DB storage).
   *
   * @throws ChangelogException
   *           if a database problem occurs.
   */
  void clear() throws ChangelogException;
  /**
   * Clear the changes from this DB (from both memory cache and DB storage) for
   * the provided baseDN.
   *
   * @param baseDNToClear
   *          The baseDN for which we want to remove all records from this DB,
   *          null means all.
   * @throws ChangelogException
   *           if a database problem occurs.
   */
  void clear(DN baseDNToClear) throws ChangelogException;
  /**
   * Shutdown this DB.
   *
   * @throws ChangelogException
   *           if a database problem occurs.
   */
  void shutdown() throws ChangelogException;
}
opends/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDB.java
@@ -198,8 +198,14 @@
    return db.count();
  }
  /** {@inheritDoc} */
  @Override
  /**
   * Returns whether this database is empty.
   *
   * @return <code>true</code> if this database is empty, <code>false</code>
   *         otherwise
   * @throws ChangelogException
   *           if a database problem occurs.
   */
  public boolean isEmpty() throws ChangelogException
  {
    return getLastRecord() == null;
@@ -231,8 +237,9 @@
    return new JEChangeNumberIndexDBCursor(db, startChangeNumber);
  }
  /** {@inheritDoc} */
  @Override
  /**
   * Shutdown this DB.
   */
  public void shutdown()
  {
    if (shutdown)
@@ -317,8 +324,16 @@
    clear(null);
  }
  /** {@inheritDoc} */
  @Override
  /**
   * Clear the changes from this DB (from both memory cache and DB storage) for
   * the provided baseDN.
   *
   * @param baseDNToClear
   *          The baseDN for which we want to remove all records from this DB,
   *          null means all.
   * @throws ChangelogException
   *           if a database problem occurs.
   */
  public void clear(DN baseDNToClear) throws ChangelogException
  {
    if (isEmpty())
@@ -510,8 +525,12 @@
    trimAge = delay;
  }
  /** {@inheritDoc} */
  @Override
  /**
   * Clear the changes from this DB (from both memory cache and DB storage).
   *
   * @throws ChangelogException
   *           if a database problem occurs.
   */
  public void clear() throws ChangelogException
  {
    db.clear();
opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java
@@ -71,7 +71,7 @@
   * <p>
   * Guarded by cnIndexDBLock
   */
  private ChangeNumberIndexDB cnIndexDB;
  private JEChangeNumberIndexDB cnIndexDB;
  /** Used for protecting {@link ChangeNumberIndexDB} related state. */
  private final Object cnIndexDBLock = new Object();