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

Jean-Noel Rouvignac
09.57.2013 abbdffd7e86953f89c3469bcfc659d842fb785f6
OPENDJ-1116 Introduce abstraction for the changelog DB


Change after review from Matthew Swift.


ReplicaDBCursor.java:
In next(), added thrown ChangelogException.

ReplicaDBCursor.java, JEChangelogDB.java:
In next(), let ChangelogException go up.

*.java:
Consequence of the change to ReplicaDBCursor.
5 files modified
34 ■■■■■ changed files
opends/src/server/org/opends/server/replication/server/MessageHandler.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationBackend.java 6 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/api/ReplicaDBCursor.java 4 ●●● 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/je/JEReplicaDBCursor.java 17 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/MessageHandler.java
@@ -40,6 +40,7 @@
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.common.ServerState;
import org.opends.server.replication.protocol.UpdateMsg;
import org.opends.server.replication.server.changelog.api.ChangelogException;
import org.opends.server.replication.server.changelog.api.ReplicaDBCursor;
import org.opends.server.types.*;
@@ -305,6 +306,10 @@
              lateQueue.add(cursor.getChange());
            }
          }
          catch (ChangelogException e)
          {
            TRACER.debugCaught(DebugLogLevel.ERROR, e);
          }
          finally
          {
            close(cursor);
opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
@@ -50,6 +50,7 @@
import org.opends.server.replication.plugin.MultimasterReplication;
import org.opends.server.replication.plugin.ReplicationServerListener;
import org.opends.server.replication.protocol.*;
import org.opends.server.replication.server.changelog.api.ChangelogException;
import org.opends.server.replication.server.changelog.api.ReplicaDBCursor;
import org.opends.server.types.*;
import org.opends.server.util.*;
@@ -622,6 +623,7 @@
  private void writeChangesAfterCSN(ReplicationServerDomain rsDomain,
      final LDIFExportConfig exportConfig, LDIFWriter ldifWriter,
      SearchOperation searchOperation, final CSN previousCSN)
      throws DirectoryException
  {
    if (exportConfig != null && exportConfig.isCancelled())
    { // Abort if cancelled
@@ -651,6 +653,10 @@
        cursor.next();
      }
    }
    catch (ChangelogException e)
    {
      throw new DirectoryException(ResultCode.OPERATIONS_ERROR, e);
    }
    finally
    {
      close(cursor);
opends/src/server/org/opends/server/replication/server/changelog/api/ReplicaDBCursor.java
@@ -51,8 +51,10 @@
   * Go to the next change in the ReplicaDB or in the server Queue.
   *
   * @return false if the cursor is already on the last change before this call.
   * @throws ChangelogException
   *           When database exception raised.
   */
  boolean next();
  boolean next() throws ChangelogException;
  /**
   * Release the resources and locks used by this cursor. This method must be
opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java
@@ -102,7 +102,7 @@
    }
    @Override
    public boolean next()
    public boolean next() throws ChangelogException
    {
      if (cursors.isEmpty())
      {
opends/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBCursor.java
@@ -94,7 +94,7 @@
  /** {@inheritDoc} */
  @Override
  public boolean next()
  public boolean next() throws ChangelogException
  {
    currentChange = cursor.next();
@@ -112,18 +112,11 @@
          cursor = null;
        }
        replicaDB.flush();
        try
        cursor = db.openReadCursor(lastNonNullCurrentCSN);
        currentChange = cursor.next();
        if (currentChange != null)
        {
          cursor = db.openReadCursor(lastNonNullCurrentCSN);
          currentChange = cursor.next();
          if (currentChange != null)
          {
            lastNonNullCurrentCSN = currentChange.getCSN();
          }
        }
        catch(Exception e)
        {
          currentChange = null;
          lastNonNullCurrentCSN = currentChange.getCSN();
        }
      }
    }