From 68fde1b50ba683919007b188eccc917708e8a7de Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 08 Oct 2013 06:55:05 +0000
Subject: [PATCH] OPENDJ-1116 Introduce abstraction for the changelog DB

---
 opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java         |    2 
 opends/src/server/org/opends/server/replication/server/changelog/api/ChangeNumberIndexDB.java  |   39 -------------------
 opends/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDB.java |   35 +++++++++++++----
 opends/src/server/org/opends/server/replication/server/changelog/api/CNIndexRecord.java        |    3 -
 4 files changed, 29 insertions(+), 50 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/changelog/api/CNIndexRecord.java b/opends/src/server/org/opends/server/replication/server/changelog/api/CNIndexRecord.java
index 0ce5e5e..7bd5bc0 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/api/CNIndexRecord.java
+++ b/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;
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/api/ChangeNumberIndexDB.java b/opends/src/server/org/opends/server/replication/server/changelog/api/ChangeNumberIndexDB.java
index 2670232..83d428b 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/api/ChangeNumberIndexDB.java
+++ b/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;
-
 }
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDB.java b/opends/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDB.java
index 9e94e24..daf3f0a 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDB.java
+++ b/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();
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java b/opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java
index 60a7186..21d4426 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java
+++ b/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();

--
Gitblit v1.10.0