From 40e2acfd1e9676f3b63385b15075bf1395d4543e Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Fri, 01 Feb 2008 13:21:19 +0000
Subject: [PATCH] Fix 2598 - fixes for global replication monitoring

---
 opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java |   50 +++++++++++++++++++++++++-------------------------
 1 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java b/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java
index 0c42763..077a79c 100644
--- a/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java
@@ -200,16 +200,6 @@
   @Override
   public ArrayList<Attribute> getMonitorData()
   {
-    if (debugEnabled())
-      TRACER.debugInfo(
-          "In " +
-          this.replServerHandler.getDomain().getReplicationServer().
-          getMonitorInstanceName()+
-          " LWSH for remote server " + this.serverId +
-          " connected to:" + this.replServerHandler.getMonitorInstanceName() +
-      " getMonitor data");
-
-
     ArrayList<Attribute> attributes = new ArrayList<Attribute>();
 
     attributes.add(new Attribute("server-id",
@@ -220,12 +210,12 @@
         replServerHandler.getMonitorInstanceName()));
 
     // Retrieves the topology counters
+    MonitorData md;
     try
     {
-      rsDomain.retrievesRemoteMonitorData();
+      md = rsDomain.getMonitorData();
 
-      // Compute the latency for the current SH
-      ServerState remoteState = rsDomain.getServerState(serverId);
+      ServerState remoteState = md.getLDAPServerState(serverId);
       if (remoteState == null)
       {
         remoteState = new ServerState();
@@ -241,29 +231,39 @@
       {
         values.add(new AttributeValue(type,str));
       }
+      if (values.size() == 0)
+      {
+        values.add(new AttributeValue(type,"unknown"));
+      }
       Attribute attr = new Attribute(type, ATTR_SERVER_STATE, values);
       attributes.add(attr);
 
-      // add the latency attribute to our monitor data
-      // Compute the latency for the current SH
-      int missingChanges = rsDomain.getMissingChanges(remoteState);
-      attributes.add(new Attribute("missing-changes",
-          String.valueOf(missingChanges)));
-
-      // Add the oldest missing update
-      Long olderUpdateTime = rsDomain.getApproxFirstMissingDate(serverId);
-      if (olderUpdateTime != null)
+      // Oldest missing update
+      Long approxFirstMissingDate=md.getApproxFirstMissingDate(serverId);
+      if ((approxFirstMissingDate != null) && (approxFirstMissingDate>0))
       {
-        Date date = new Date(olderUpdateTime);
+        Date date = new Date(approxFirstMissingDate);
         attributes.add(new Attribute("approx-older-change-not-synchronized",
           date.toString()));
         attributes.add(
-          new Attribute("approx-older-change-not-synchronized-millis",
-          String.valueOf(olderUpdateTime)));
+            new Attribute("approx-older-change-not-synchronized-millis",
+            String.valueOf(approxFirstMissingDate)));
       }
+
+      // Missing changes
+      long missingChanges = md.getMissingChanges(serverId);
+      attributes.add(new Attribute("missing-changes",
+          String.valueOf(missingChanges)));
+
+      // Replication delay
+      long delay = md.getApproxDelay(serverId);
+      attributes.add(new Attribute("approximate-delay",
+          String.valueOf(delay)));
+
     }
     catch(Exception e)
     {
+      // TODO: improve the log
       // We failed retrieving the remote monitor data.
       attributes.add(new Attribute("error",
         stackTraceToSingleLineString(e)));

--
Gitblit v1.10.0