From fb67046affe3a56fec8fb332de2c21f567917a0d Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Tue, 19 Jun 2012 08:51:36 +0000
Subject: [PATCH] Initial cleanup for OPENDJ-506: NoSuchElementException thrown during replication in java.util.TreeMap.key(TreeMap.java:1221)
---
opendj-sdk/opends/src/server/org/opends/server/replication/server/MessageHandler.java | 62 +-------------------
opendj-sdk/opends/src/server/org/opends/server/replication/server/MsgQueue.java | 14 ----
opendj-sdk/opends/src/server/org/opends/server/replication/server/ServerHandler.java | 39 ------------
opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java | 6 +-
4 files changed, 9 insertions(+), 112 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
index 84e041c..0578313 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2009-2010 Sun Microsystems, Inc.
- * Portions Copyright 2010-2011 ForgeRock AS
+ * Portions Copyright 2010-2012 ForgeRock AS
*/
package org.opends.server.replication.server;
@@ -232,7 +232,7 @@
// non blocking
UpdateMsg newMsg;
do {
- newMsg = mh.getnextMessage(false);
+ newMsg = mh.getNextMessage(false);
// when the replication changelog is trimmed, the last (latest) chg
// is left in the db (whatever its age), and we don't want this chg
// to be returned in the external changelog.
@@ -1232,7 +1232,7 @@
* @return the next message
*/
@Override
- protected UpdateMsg getnextMessage(boolean synchronous)
+ protected UpdateMsg getNextMessage(boolean synchronous)
{
UpdateMsg msg = null;
try
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/MessageHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/MessageHandler.java
index 1b933fc..0f4b2bd 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/MessageHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/MessageHandler.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2009-2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2012 ForgeRock AS
*/
package org.opends.server.replication.server;
@@ -49,7 +49,6 @@
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.ResultCode;
-import org.opends.server.util.TimeThread;
/**
* This class implements a buffering/producer/consumer mechanism of
@@ -75,7 +74,7 @@
/**
* Late queue.
*/
- protected MsgQueue lateQueue = new MsgQueue();
+ private final MsgQueue lateQueue = new MsgQueue();
/**
* Local hosting RS.
*/
@@ -195,49 +194,6 @@
}
/**
- * Get an approximation of the delay by looking at the age of the oldest
- * message that has not been sent to this server.
- * This is an approximation because the age is calculated using the
- * clock of the server where the replicationServer is currently running
- * while it should be calculated using the clock of the server
- * that originally processed the change.
- *
- * The approximation error is therefore the time difference between
- *
- * @return the approximate delay for the connected server.
- */
- public long getApproxDelay()
- {
- long olderUpdateTime = getOlderUpdateTime();
- if (olderUpdateTime == 0)
- return 0;
-
- long currentTime = TimeThread.getTime();
- return ((currentTime - olderUpdateTime) / 1000);
- }
-
- /**
- * Get the age of the older change that has not yet been replicated
- * to the server handled by this ServerHandler.
- * @return The age if the older change has not yet been replicated
- * to the server handled by this ServerHandler.
- */
- public Long getApproxFirstMissingDate()
- {
- Long result = (long) 0;
-
- // Get the older CN received
- ChangeNumber olderUpdateCN = getOlderUpdateCN();
- if (olderUpdateCN != null)
- {
- // If not present in the local RS db,
- // then approximate with the older update time
- result = olderUpdateCN.getTime();
- }
- return result;
- }
-
- /**
* Returns the Replication Server Domain to which belongs this handler.
*
* @param createIfNotExist Creates the domain if it does not exist.
@@ -311,7 +267,7 @@
* @return The next update that must be sent to the consumer.
* null when synchronous is false and queue is empty.
*/
- protected UpdateMsg getnextMessage(boolean synchronous)
+ protected UpdateMsg getNextMessage(boolean synchronous)
{
UpdateMsg msg;
while (activeConsumer == true)
@@ -577,18 +533,6 @@
}
/**
- * Get the older update time for that server.
- * @return The older update time.
- */
- public long getOlderUpdateTime()
- {
- ChangeNumber olderUpdateCN = getOlderUpdateCN();
- if (olderUpdateCN == null)
- return 0;
- return olderUpdateCN.getTime();
- }
-
- /**
* Get the count of updates sent to this server.
* @return The count of update sent to this server.
*/
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/MsgQueue.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/MsgQueue.java
index 270a184..2e42b49 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/MsgQueue.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/MsgQueue.java
@@ -23,6 +23,7 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
+ * Portions copyright 2012 ForgeRock AS.
*/
package org.opends.server.replication.server;
@@ -64,19 +65,6 @@
}
/**
- * Return the last UpdateMsg in the MsgQueue.
- *
- * @return The last UpdateMsg in the MsgQueue.
- */
- public UpdateMsg last()
- {
- synchronized (lock)
- {
- return map.get(map.lastKey());
- }
- }
-
- /**
* Returns the number of elements in this MsgQueue.
*
* @return The number of elements in this MsgQueue.
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ServerHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ServerHandler.java
index c3e2b86..0b58e05 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ServerHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ServerHandler.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2012 ForgeRock AS
*/
package org.opends.server.replication.server;
@@ -72,7 +72,6 @@
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.ResultCode;
-import org.opends.server.util.TimeThread;
/**
* This class defines a server handler :
@@ -410,28 +409,6 @@
}
/**
- * Get an approximation of the delay by looking at the age of the oldest
- * message that has not been sent to this server.
- * This is an approximation because the age is calculated using the
- * clock of the server where the replicationServer is currently running
- * while it should be calculated using the clock of the server
- * that originally processed the change.
- *
- * The approximation error is therefore the time difference between
- *
- * @return the approximate delay for the connected server.
- */
- public long getApproxDelay()
- {
- long olderUpdateTime = getOlderUpdateTime();
- if (olderUpdateTime == 0)
- return 0;
-
- long currentTime = TimeThread.getTime();
- return ((currentTime - olderUpdateTime) / 1000);
- }
-
- /**
* Get the age of the older change that has not yet been replicated
* to the server handled by this ServerHandler.
* @return The age if the older change has not yet been replicated
@@ -661,18 +638,6 @@
public abstract String getMonitorInstanceName();
/**
- * Get the older update time for that server.
- * @return The older update time.
- */
- public long getOlderUpdateTime()
- {
- ChangeNumber olderUpdateCN = getOlderUpdateCN();
- if (olderUpdateCN == null)
- return 0;
- return olderUpdateCN.getTime();
- }
-
- /**
* Get the count of updates sent to this server.
* @return The count of update sent to this server.
*/
@@ -1144,7 +1109,7 @@
public UpdateMsg take()
{
boolean interrupted = true;
- UpdateMsg msg = getnextMessage(true); // synchronous:block until msg
+ UpdateMsg msg = getNextMessage(true); // synchronous:block until msg
boolean acquired = false;
do
--
Gitblit v1.10.0