From d90a8f4889fdc359bfe5f089b937b303a4d58973 Mon Sep 17 00:00:00 2001
From: fguigues <fguigues@localhost>
Date: Fri, 12 Dec 2008 13:13:01 +0000
Subject: [PATCH] * Ability to create monitor provider with hierarchical naming * Modification of Network Monitor provider names (includes hierarchical naming) * Provide basic Monitoring objects. * Add monitoring instrumentation for the connection handlers. * Add the ability to do a subtree search in the monitor backend.

---
 opends/src/server/org/opends/server/monitors/ClientConnectionMonitorProvider.java |   72 ++++++++++++++++++++++++-----------
 1 files changed, 49 insertions(+), 23 deletions(-)

diff --git a/opends/src/server/org/opends/server/monitors/ClientConnectionMonitorProvider.java b/opends/src/server/org/opends/server/monitors/ClientConnectionMonitorProvider.java
index 58294d6..65feaa3 100644
--- a/opends/src/server/org/opends/server/monitors/ClientConnectionMonitorProvider.java
+++ b/opends/src/server/org/opends/server/monitors/ClientConnectionMonitorProvider.java
@@ -56,13 +56,26 @@
 public class ClientConnectionMonitorProvider
        extends MonitorProvider<ClientConnectionMonitorProviderCfg>
 {
+
+  private ConnectionHandler<?> handler;
+
   /**
    * Creates an instance of this monitor provider.
    */
   public ClientConnectionMonitorProvider()
   {
     super("Client Connection Monitor Provider");
+    // No initialization should be performed here.
+  }
 
+  /**
+   * Creates an instance of this monitor provider.
+   * @param handler to which the monitor provider is associated.
+   */
+  public ClientConnectionMonitorProvider(ConnectionHandler handler)
+  {
+    super("Client Connection Monitor Provider");
+    this.handler=handler;
     // No initialization should be performed here.
   }
 
@@ -88,7 +101,14 @@
    */
   public String getMonitorInstanceName()
   {
-    return "Client Connections";
+    if (this.handler==null) {
+       return "Client Connections";
+    }
+    else {
+       // Client connections of a connection handler
+       return "Client Connections"+",cn="+
+               this.handler.getConnectionHandlerName();
+    }
   }
 
 
@@ -135,31 +155,38 @@
    */
   public ArrayList<Attribute> getMonitorData()
   {
-    // Get information about all the available connections.
-    ArrayList<Collection<ClientConnection>> connCollections =
-         new ArrayList<Collection<ClientConnection>>();
-    for (ConnectionHandler<?> handler : DirectoryServer.getConnectionHandlers())
-    {
-      ConnectionHandler<? extends ConnectionHandlerCfg> connHandler =
-           (ConnectionHandler<? extends ConnectionHandlerCfg>) handler;
-      connCollections.add(connHandler.getClientConnections());
-    }
-
-
     // Re-order the connections by connection ID.
     TreeMap<Long,ClientConnection> connMap =
-         new TreeMap<Long,ClientConnection>();
-    for (Collection<ClientConnection> collection : connCollections)
-    {
-      for (ClientConnection conn : collection)
-      {
-        connMap.put(conn.getConnectionID(), conn);
-      }
+             new TreeMap<Long,ClientConnection>();
+
+    if (this.handler==null) {
+        // Get information about all the available connections.
+        ArrayList<Collection<ClientConnection>> connCollections =
+             new ArrayList<Collection<ClientConnection>>();
+        for (ConnectionHandler<?> hdl : DirectoryServer.getConnectionHandlers())
+        {
+          ConnectionHandler<? extends ConnectionHandlerCfg> connHandler =
+               (ConnectionHandler<? extends ConnectionHandlerCfg>) hdl;
+          connCollections.add(connHandler.getClientConnections());
+        }
+        for (Collection<ClientConnection> collection : connCollections)
+        {
+          for (ClientConnection conn : collection)
+          {
+            connMap.put(conn.getConnectionID(), conn);
+          }
+        }
+
+    }
+    else {
+       Collection<ClientConnection> collection =
+               this.handler.getClientConnections();
+       for (ClientConnection conn : collection) {
+            connMap.put(conn.getConnectionID(), conn);
+       }
     }
 
 
-    // Iterate through all the client connections and create a one-line summary
-    // of each.
     AttributeType attrType = DirectoryServer
         .getDefaultAttributeType("connection");
     AttributeBuilder builder = new AttributeBuilder(attrType);
@@ -168,8 +195,7 @@
       builder.add(new AttributeValue(attrType, conn.getMonitorSummary()));
     }
 
-
-    ArrayList<Attribute> attrs = new ArrayList<Attribute>(1);
+    ArrayList<Attribute> attrs = new ArrayList<Attribute>(2);
     attrs.add(builder.toAttribute());
     return attrs;
   }

--
Gitblit v1.10.0