From 60f8d8d4575206697f47c040d4272dee27251bab Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 18 Apr 2014 13:56:22 +0000
Subject: [PATCH] OPENDJ-1430 Some changes are missing from the external changelog changeNumber
---
opends/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java | 40 ++++++++++++++++++++++++++++++----------
1 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java b/opends/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java
index 99870ed..3b44c84 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java
@@ -373,7 +373,10 @@
cursors.put(entry2.getValue(), entry.getKey());
}
}
- final CompositeDBCursor<DN> result = new CompositeDBCursor<DN>(cursors);
+
+ // CNIndexer manages the cursor itself,
+ // so do not try to recycle exhausted cursors
+ CompositeDBCursor<DN> result = new CompositeDBCursor<DN>(cursors, false);
result.next();
nextChangeForInsertDBCursor = result;
}
@@ -456,7 +459,12 @@
}
else
{
- createNewCursors();
+ final boolean createdCursors = createNewCursors();
+ final boolean recycledCursors = recycleExhaustedCursors();
+ if (createdCursors || recycledCursors)
+ {
+ resetNextChangeForInsertDBCursor();
+ }
}
final UpdateMsg msg = nextChangeForInsertDBCursor.getRecord();
@@ -470,9 +478,6 @@
}
wait();
}
- // try to recycle the exhausted cursors,
- // success/failure will be checked later
- nextChangeForInsertDBCursor.next();
// loop to check whether new changes have been added to the
// ReplicaDBs
continue;
@@ -603,7 +608,24 @@
}
}
- private void createNewCursors() throws ChangelogException
+ private boolean recycleExhaustedCursors() throws ChangelogException
+ {
+ boolean succesfullyRecycled = false;
+ for (Map<Integer, DBCursor<UpdateMsg>> map : allCursors.values())
+ {
+ for (DBCursor<UpdateMsg> cursor : map.values())
+ {
+ // try to recycle it by calling next()
+ if (cursor.getRecord() == null && cursor.next())
+ {
+ succesfullyRecycled = true;
+ }
+ }
+ }
+ return succesfullyRecycled;
+ }
+
+ private boolean createNewCursors() throws ChangelogException
{
if (!newCursors.isEmpty())
{
@@ -623,11 +645,9 @@
}
iter.remove();
}
- if (newCursorAdded)
- {
- resetNextChangeForInsertDBCursor();
- }
+ return newCursorAdded;
}
+ return false;
}
/**
--
Gitblit v1.10.0