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

Jean-Noel Rouvignac
17.46.2013 cec016958f29b8849a1768e588e1d728d621af49
OPENDJ-1116 Introduce abstraction for the changelog DB

Fixed nightly test org.opends.server.replication.server.ExternalChangeLogTest#ECLReplicationServerFullTest14 broken by r9505.

r9505 allowed code to throw ChangelogException and removed several useless catch(), in particular, a catch was removed from DraftCNDbHandler's methods getPreviousCookie(), getCSN(), getBaseDN() which were predecessors of getRecord().
Older code was throwing an exception, then catching it and returning null in some places while in other places, the exception was allowed to propagate.
The final change removed the unnecessary exception throwing and swallowing where it was useless. The exception is now thrown again where it is useful.


DraftCNDB.java:
In DraftCNDBCursor(long) ctor, removed throwing the exception and return an empty cursor instead.

DraftCNDbIterator.java:
In DraftCNDbIterator() ctor, throw an exception when the cursor is empty.
2 files modified
22 ■■■■■ changed files
opends/src/server/org/opends/server/replication/server/changelog/je/DraftCNDB.java 11 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/je/DraftCNDbIterator.java 11 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/je/DraftCNDB.java
@@ -31,7 +31,6 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.opends.messages.Message;
import org.opends.messages.MessageBuilder;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.replication.server.changelog.api.CNIndexRecord;
@@ -398,10 +397,12 @@
            // We could not move the cursor to the expected startChangeNumber
            if (localCursor.getSearchKeyRange(key, entry, DEFAULT) != SUCCESS)
            {
              // We could not even move the cursor close to it => failure
              throw new ChangelogException(
                  Message.raw("ChangeLog Change Number " + startChangeNumber
                      + " is not available"));
              // We could not even move the cursor close to it
              // => return an empty cursor
              isClosed = true;
              txn = null;
              cursor = null;
              return;
            }
            if (localCursor.getPrev(key, entry, LockMode.DEFAULT) != SUCCESS)
opends/src/server/org/opends/server/replication/server/changelog/je/DraftCNDbIterator.java
@@ -29,8 +29,10 @@
import org.opends.messages.Message;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.replication.server.changelog.api.*;
import org.opends.server.replication.server.changelog.je.DraftCNDB.*;
import org.opends.server.replication.server.changelog.api.CNIndexRecord;
import org.opends.server.replication.server.changelog.api.ChangeNumberIndexDBCursor;
import org.opends.server.replication.server.changelog.api.ChangelogException;
import org.opends.server.replication.server.changelog.je.DraftCNDB.DraftCNDBCursor;
import org.opends.server.types.DebugLogLevel;
import static org.opends.server.loggers.debug.DebugLogger.*;
@@ -59,9 +61,10 @@
      throws ChangelogException
  {
    draftCNDbCursor = db.openReadCursor(startChangeNumber);
    if (draftCNDbCursor == null)
    if (draftCNDbCursor.currentRecord() == null)
    {
      throw new ChangelogException(Message.raw("no new change"));
      throw new ChangelogException(Message.raw("Change Number "
          + startChangeNumber + " is not available in the Changelog"));
    }
  }