From ab3cac04319c920ba14be59ea874e6e35f730655 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Mon, 21 Jul 2014 17:06:28 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1206 : Create a new ReplicationBackend/ChangelogBackend   to support cn=changelog CR-4053

---
 opends/src/server/org/opends/server/replication/server/changelog/file/LogFile.java |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/changelog/file/LogFile.java b/opends/src/server/org/opends/server/replication/server/changelog/file/LogFile.java
index ff041ea..5f66cc2 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/file/LogFile.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/file/LogFile.java
@@ -28,6 +28,7 @@
 import static org.opends.messages.ReplicationMessages.*;
 import static org.opends.server.loggers.ErrorLogger.*;
 import static org.opends.server.loggers.debug.DebugLogger.*;
+import static org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy.*;
 
 import java.io.BufferedWriter;
 import java.io.Closeable;
@@ -41,6 +42,8 @@
 import org.opends.server.loggers.debug.DebugTracer;
 import org.opends.server.replication.server.changelog.api.ChangelogException;
 import org.opends.server.replication.server.changelog.api.DBCursor;
+import org.opends.server.replication.server.changelog.api.DBCursor.KeyMatchingStrategy;
+import org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy;
 import org.opends.server.replication.server.changelog.file.Log.RepositionableCursor;
 import org.opends.server.types.DebugLogLevel;
 import org.opends.server.util.StaticUtils;
@@ -335,7 +338,7 @@
    */
   LogFileCursor<K, V> getCursor(final K key) throws ChangelogException
   {
-    return getCursor(key, false);
+    return getCursor(key, KeyMatchingStrategy.EQUAL_TO_KEY, PositionStrategy.ON_MATCHING_KEY);
   }
 
   /**
@@ -352,12 +355,15 @@
    */
   LogFileCursor<K, V> getNearestCursor(final K key) throws ChangelogException
   {
-    return getCursor(key, true);
+    return getCursor(key, KeyMatchingStrategy.GREATER_THAN_OR_EQUAL_TO_KEY, AFTER_MATCHING_KEY);
   }
 
   /** Returns a cursor starting from a key, using the strategy corresponding to provided indicator. */
-  private LogFileCursor<K, V> getCursor(final K key, boolean findNearest)
-      throws ChangelogException
+  private LogFileCursor<K, V> getCursor(
+      final K key,
+      final KeyMatchingStrategy matchingStrategy,
+      final PositionStrategy positionStrategy)
+          throws ChangelogException
   {
     if (key == null)
     {
@@ -367,7 +373,7 @@
     try
     {
       cursor = new LogFileCursor<K, V>(this);
-      cursor.positionTo(key, findNearest);
+      cursor.positionTo(key, matchingStrategy, positionStrategy);
       // if target is not found, cursor is positioned at end of stream
       return cursor;
     }
@@ -628,8 +634,9 @@
 
     /** {@inheritDoc} */
     @Override
-    public boolean positionTo(final K key, boolean findNearest) throws ChangelogException {
-      final Pair<Boolean, Record<K, V>> result = reader.seekToRecord(key, findNearest);
+    public boolean positionTo(final K key, final KeyMatchingStrategy match, final PositionStrategy pos)
+        throws ChangelogException {
+      final Pair<Boolean, Record<K, V>> result = reader.seekToRecord(key, match, pos);
       final boolean found = result.getFirst();
       initialRecord = found ? result.getSecond() : null;
       return found;

--
Gitblit v1.10.0