From 78d0902c64346883885504cfc43ec335951429c2 Mon Sep 17 00:00:00 2001
From: floblanc <floblanc@localhost>
Date: Thu, 06 Nov 2008 09:26:29 +0000
Subject: [PATCH] Implement statistics for the network group. The stats are available under cn=monitor.
---
opends/src/server/org/opends/server/core/networkgroups/ResourceLimits.java | 30 +++++++++++++++++++++++++-----
1 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/networkgroups/ResourceLimits.java b/opends/src/server/org/opends/server/core/networkgroups/ResourceLimits.java
index e34dfd5..9904e93 100644
--- a/opends/src/server/org/opends/server/core/networkgroups/ResourceLimits.java
+++ b/opends/src/server/org/opends/server/core/networkgroups/ResourceLimits.java
@@ -79,10 +79,17 @@
private int minSearchSubstringLength;
// The number of connections in the group
- private int numConnections;
+ private int numConnections = 0;
+
+ // The maximum number of simultaneous connections in the group
+ // since group creation
+ private int maxNumConnections = 0;
+
+ // The total number of connections managed by the group
+ private int totalNumConnections = 0;
// Map containing the connections sorted by incoming IP address
- HashMap<String, Integer> connectionsPerIpMap;
+ HashMap<String, Integer> connectionsPerIpMap = new HashMap<String, Integer>();
// The lock for the counter numConnections and the map connectionsPerIpMap
Object connMutex = new Object();
@@ -111,8 +118,6 @@
searchSizeLimit = -1;
searchTimeLimit = -1;
minSearchSubstringLength = 0;
- numConnections = 0;
- connectionsPerIpMap = new HashMap<String, Integer>();
isConfigured = false;
if (config != null) {
config.removeChangeListener(this);
@@ -136,7 +141,6 @@
searchSizeLimit = resourcesCfg.getSearchSizeLimit();
searchTimeLimit = (int) resourcesCfg.getSearchTimeLimit();
minSearchSubstringLength = resourcesCfg.getMinSubstringLength();
- connectionsPerIpMap = new HashMap<String, Integer>();
if (config == null) {
resourcesCfg.addChangeListener(this);
@@ -248,6 +252,10 @@
synchronized(connMutex) {
// increment the number of connections managed by the network group
numConnections++;
+ totalNumConnections++;
+ if (numConnections > maxNumConnections) {
+ maxNumConnections = numConnections;
+ }
// increment the number of connections from the given IP address
String ip = connection.getClientAddress();
@@ -418,6 +426,18 @@
}
}
+ /**
+ * Retrieves the statistics associated to the resource limits.
+ * @return the statistics
+ */
+ public ResourceLimitsStat getStat() {
+ ResourceLimitsStat stat;
+ synchronized(connMutex) {
+ stat = new ResourceLimitsStat(
+ numConnections, maxNumConnections, totalNumConnections);
+ }
+ return stat;
+ }
/**
* {@inheritDoc}
--
Gitblit v1.10.0