From 819f74758a1c464bbf578e70ca8592cc8d101d75 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 02 Apr 2014 09:51:11 +0000
Subject: [PATCH] OPENDJ-1177 (CR-3304) Re-implement changelog purging logic
---
opends/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBCursor.java | 45 ++++++++++++++-------------------------------
1 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBCursor.java b/opends/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBCursor.java
index 919ad34..577fc39 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBCursor.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBCursor.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
- * Portions Copyright 2011-2013 ForgeRock AS
+ * Portions Copyright 2011-2014 ForgeRock AS
*/
package org.opends.server.replication.server.changelog.je;
@@ -73,15 +73,6 @@
// we didn't find it in the db
cursor = null;
}
-
- if (cursor == null)
- {
- // flush the queue into the db
- replicaDB.flush();
-
- // look again in the db
- cursor = db.openReadCursor(startAfterCSN);
- }
}
/** {@inheritDoc} */
@@ -96,15 +87,7 @@
public boolean next() throws ChangelogException
{
final ReplServerDBCursor localCursor = cursor;
- if (localCursor != null)
- {
- currentChange = localCursor.next();
- }
- else
- {
- currentChange = null;
- }
-
+ currentChange = localCursor != null ? localCursor.next() : null;
if (currentChange != null)
{
@@ -114,12 +97,8 @@
{
synchronized (this)
{
- if (cursor != null)
- {
- cursor.close();
- cursor = null;
- }
- replicaDB.flush();
+ closeCursor();
+ // previously exhausted cursor must be able to reinitialize themselves
cursor = db.openReadCursor(lastNonNullCurrentCSN);
currentChange = cursor.next();
if (currentChange != null)
@@ -137,13 +116,17 @@
{
synchronized (this)
{
- if (cursor != null)
- {
- cursor.close();
- cursor = null;
- }
+ closeCursor();
this.replicaDB = null;
- this.db = null;
+ }
+ }
+
+ private void closeCursor()
+ {
+ if (cursor != null)
+ {
+ cursor.close();
+ cursor = null;
}
}
--
Gitblit v1.10.0