From 991178c44056e8dd7ed0df74cb0a54b9b84ac785 Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Thu, 27 May 2010 14:47:42 +0000
Subject: [PATCH] Fix issue #4384, a performance problem in replication monitoring

---
 opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java |   35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
index 46a9031..e92d185 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -1615,8 +1615,8 @@
         {
           // Monitoring information requested by a DS
           MonitorMsg monitorMsg =
-            createGlobalTopologyMonitorMsg(msg.getDestination(),
-            msg.getsenderID());
+            createGlobalTopologyMonitorMsg(
+                msg.getDestination(), msg.getsenderID(), false);
 
            if (monitorMsg != null)
           {
@@ -1763,10 +1763,18 @@
    * whole topology.
    * @param sender The sender of this message.
    * @param destination The destination of this message.
+   * @param  updateMonitorData A boolean indicating if the monitor data should
+   *                           be updated. If false the last monitoring data
+   *                           that was computed will be returned. This is
+   *                           acceptable for most cases because the monitoring
+   *                           thread computes the monitoring data frequently.
+   *                           If true is used the calling thread may be
+   *                           blocked for a while.
    * @return The newly created and filled MonitorMsg. Null if a problem occurred
    * during message creation.
    */
-  public MonitorMsg createGlobalTopologyMonitorMsg(int sender, int destination)
+  public MonitorMsg createGlobalTopologyMonitorMsg(
+      int sender, int destination, boolean updateMonitorData)
   {
     MonitorMsg returnMsg =
       new MonitorMsg(sender, destination);
@@ -1776,7 +1784,7 @@
       returnMsg.setReplServerDbState(getDbServerState());
       // Update the information we have about all servers
       // in the topology.
-      MonitorData md = computeMonitorData();
+      MonitorData md = computeMonitorData(updateMonitorData);
 
       // Add the informations about the Replicas currently in
       // the topology.
@@ -2549,14 +2557,25 @@
    */
   /**
    * Retrieves the global monitor data.
+   * @param  updateMonitorData A boolean indicating if the monitor data should
+   *                           be updated. If false the last monitoring data
+   *                           that was computed will be returned. This is
+   *                           acceptable for most cases because the monitoring
+   *                           thread computes the monitoring data frequently.
+   *                           If true is used the calling thread may be
+   *                           blocked for a while.
    * @return The monitor data.
    * @throws DirectoryException When an error occurs.
    */
-  synchronized protected MonitorData computeMonitorData()
+  synchronized protected MonitorData computeMonitorData(
+      boolean updateMonitorData)
     throws DirectoryException
   {
-    // Update the monitorData of ALL domains if this was necessary.
-    replicationServer.computeMonitorData();
+    if (updateMonitorData)
+    {
+      // Update the monitorData of ALL domains if this was necessary.
+      replicationServer.computeMonitorData();
+    }
 
     // Returns the monitorData of THIS domain
     return monitorData;
@@ -3053,7 +3072,7 @@
 
     try
     {
-      MonitorData md = computeMonitorData();
+      MonitorData md = computeMonitorData(true);
 
       // Missing changes
       long missingChanges =

--
Gitblit v1.10.0