From 3f27a7ede5ca9df06137254aa32d41d023ac105d Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Tue, 16 Sep 2014 15:05:25 +0000
Subject: [PATCH] OPENDJ-1444 CR-4537 Remove previous cookie from storage of ChangeNumberIndexDB
---
opends/src/server/org/opends/server/replication/server/changelog/je/CompositeDBCursor.java | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/CompositeDBCursor.java b/opends/src/server/org/opends/server/replication/server/changelog/je/CompositeDBCursor.java
index 748619c..bcc1338 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/CompositeDBCursor.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/je/CompositeDBCursor.java
@@ -34,6 +34,8 @@
import org.opends.server.replication.server.changelog.api.DBCursor;
import org.opends.server.util.StaticUtils;
+import com.forgerock.opendj.util.Pair;
+
/**
* {@link DBCursor} implementation that iterates across a Collection of
* {@link DBCursor}s, advancing from the oldest to the newest change cross all
@@ -214,6 +216,35 @@
return null;
}
+ /**
+ * Returns a snapshot of this cursor.
+ *
+ * @return a list of (Data, UpdateMsg) pairs representing the state of the
+ * cursor. In each pair, the data or the update message may be
+ * {@code null}, but at least one of them is non-null.
+ */
+ public List<Pair<Data, UpdateMsg>> getSnapshot()
+ {
+ final List<Pair<Data, UpdateMsg>> snapshot = new ArrayList<Pair<Data, UpdateMsg>>();
+ for (Entry<DBCursor<UpdateMsg>, Data> entry : cursors.entrySet())
+ {
+ final UpdateMsg updateMsg = entry.getKey().getRecord();
+ final Data data = entry.getValue();
+ if (updateMsg != null || data != null)
+ {
+ snapshot.add(Pair.of(data, updateMsg));
+ }
+ }
+ for (Data data : exhaustedCursors.values())
+ {
+ if (data != null)
+ {
+ snapshot.add(Pair.of(data, (UpdateMsg) null));
+ }
+ }
+ return snapshot;
+ }
+
/** {@inheritDoc} */
@Override
public void close()
--
Gitblit v1.10.0