From d4a53237446485c4de48fc81fe00d1335b09bfef Mon Sep 17 00:00:00 2001
From: fguigues <fguigues@localhost>
Date: Thu, 13 Aug 2009 11:44:47 +0000
Subject: [PATCH] Fix the LDAPStatistics data and objects of LDAPConnectionHandler Fix the uninstall tool on windows (classpath too long when stop server is called)

---
 opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java       |    1 
 /dev/null                                                                    |  239 -----------
 opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java       |  821 ++++++++++++++--------------------------
 opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java |  119 -----
 4 files changed, 303 insertions(+), 877 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java b/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
index 1323cda..bfaa60f 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
@@ -141,6 +141,7 @@
       Map<String, String> env = pb.environment();
       env.put(SetupUtils.OPENDS_JAVA_HOME, System.getProperty("java.home"));
       env.remove(SetupUtils.OPENDS_JAVA_ARGS);
+      env.remove("CLASSPATH");
 
       LOG.log(Level.INFO, "Before calling stop-ds.  Is server running? "+
           installation.getStatus().isServerRunning());
diff --git a/opends/src/server/org/opends/server/monitors/CounterMonitor.java b/opends/src/server/org/opends/server/monitors/CounterMonitor.java
deleted file mode 100644
index e177b41..0000000
--- a/opends/src/server/org/opends/server/monitors/CounterMonitor.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at
- * trunk/opends/resource/legal-notices/OpenDS.LICENSE
- * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at
- * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
- * add the following below this CDDL HEADER, with the fields enclosed
- * by brackets "[]" replaced with your own identifying information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- */
-package org.opends.server.monitors;
-
-/**
- * This class implements a monitor a basic counter.
- */
-public class CounterMonitor {
-
-    // private counter
-    private int count=0;
-    // max counter
-    private int max=0;
-
-    // private constructor
-    private CounterMonitor() {
-    }
-
-    // private constructor
-    private CounterMonitor(CounterMonitor countMonitor) {
-        this.count=countMonitor.getCount();
-        this.max=countMonitor.getMax();
-    }
-
-    /**
-     * Gets a CounterMonitor Object.
-     * @return a counter monitor object.
-     */
-    public static CounterMonitor getCounter() {
-        return new CounterMonitor();
-    }
-
-    /**
-     * Gets a copy of the counter monitor.
-     * @return a duplicate object.
-     */
-    public CounterMonitor duplicate() {
-        return new CounterMonitor(this);
-    }
-
-    /**
-     * Adds a counter Monitor to the current counter object.
-     * @param countMonitor to add.
-     */
-    public void add(CounterMonitor countMonitor) {
-        this.count+=countMonitor.count;
-        if ((this.count>this.max) && (this.count>=countMonitor.max)) {
-            this.max=this.count;
-        }
-        else {
-            if (this.max<countMonitor.getMax()) {
-                this.max=countMonitor.getMax();
-            }
-        }
-    }
-
-    /**
-     * Increments the counter object.
-     */
-    public void increment() {
-        count++;
-        if (count>max) max=count;
-    }
-
-    /**
-     * Decrements the counter object.
-     */
-    public void decrement() {
-        count--;
-    }
-
-    /**
-     * Gets the current counter value.
-     * @return the current counter value.
-     */
-    public int getCount() {
-        return count;
-    }
-
-    /**
-     * Gets the maximum value the counter reached since the object creation.
-     * @return the maximum value.
-     */
-    public int getMax() {
-        return max;
-    }
-
-    /**
-     * Reset the counter values (Value and max).
-     */
-    public void reset() {
-        this.count=0;
-        this.max=0;
-    }
-
-}
diff --git a/opends/src/server/org/opends/server/monitors/OperationMonitor.java b/opends/src/server/org/opends/server/monitors/OperationMonitor.java
deleted file mode 100644
index 04011b6..0000000
--- a/opends/src/server/org/opends/server/monitors/OperationMonitor.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at
- * trunk/opends/resource/legal-notices/OpenDS.LICENSE
- * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at
- * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
- * add the following below this CDDL HEADER, with the fields enclosed
- * by brackets "[]" replaced with your own identifying information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- */
-package org.opends.server.monitors;
-
-import org.opends.server.api.MonitorProvider;
-import org.opends.server.protocols.ldap.LDAPStatistics;
-import org.opends.server.types.OperationType;
-
-/**
- * This class defines a monitor object which are able to measure
- * an elapse time (nanosecs), a number of times the measurement was done,
- * the minimum and the maximum.
- */
-public class OperationMonitor {
-
-    /**
-     * Undefined value for the timer.
-     */
-    public static long UNDEFINED_VALUE = 0;
-
-    // Lock object
-    private Object lock = new Object();
-    // Type of the operation
-    private OperationType opType;
-    // Date of creation of the object
-    private long creationTime;
-    // ElapseTime
-    private long eTime = UNDEFINED_VALUE;
-    // Date the start method was called
-    private long startTime = UNDEFINED_VALUE;
-    // Date stop method was called
-    private long stopTime = UNDEFINED_VALUE;
-    // Accumualted time
-    private long totalTime = UNDEFINED_VALUE;
-    // Min time
-    private long minTime = UNDEFINED_VALUE;
-    // Max time
-    private long maxTime = UNDEFINED_VALUE;
-
-    // Counter
-    private CounterMonitor counter;
-
-    // Private constructor
-    private OperationMonitor(OperationMonitor opMonitor) {
-        this.opType = opMonitor.getType();
-        this.eTime = opMonitor.getTime();
-        this.startTime = opMonitor.getStartTime();
-        this.stopTime = opMonitor.getStopTime();
-        this.totalTime = opMonitor.getTotalTime();
-        this.maxTime = opMonitor.getMaxTime();
-        this.minTime = opMonitor.getMinTime();
-        this.counter = opMonitor.getCounter().duplicate();
-    }
-
-    // Private constructor
-    private OperationMonitor(OperationType opType) {
-        this.opType = opType;
-        this.counter = CounterMonitor.getCounter();
-        this.creationTime = System.nanoTime();
-    }
-
-    /**
-     * Gets a Operation Monitor object od the specified type.
-     * @param opType of the monitor object.
-     * @return the Operation monitor object.
-     */
-    public static OperationMonitor getOperationMonitor(OperationType opType) {
-        return new OperationMonitor(opType);
-    }
-
-    /**
-     * Returns a duplicate object.
-     * @return the duplicate object.
-     */
-    public OperationMonitor duplicate() {
-        return new OperationMonitor(this);
-    }
-
-    /**
-     * Add the provider moniyot object to the current one.
-     * @param opMonitor to add.
-     */
-    public void add(OperationMonitor opMonitor) {
-        synchronized (lock) {
-            this.counter.add(opMonitor.getCounter());
-            this.totalTime += opMonitor.getTotalTime();
-            if ((this.minTime == UNDEFINED_VALUE) ||
-                    (this.minTime > opMonitor.getMinTime())) {
-                this.minTime = opMonitor.getMinTime();
-            }
-            if (this.maxTime < opMonitor.getMaxTime()) {
-                this.maxTime = opMonitor.getMaxTime();
-            }
-        }
-    }
-
-    /**
-     * Sets the starTime.
-     */
-    public void start() {
-        synchronized (lock) {
-            this.counter.increment();
-            this.startTime = System.nanoTime();
-        }
-    }
-
-    /**
-     * Sets the stopTime, process the elapseTime, min max and accumulated
-     * time.
-     */
-    public void stop() {
-        synchronized (lock) {
-            this.stopTime = System.nanoTime();
-            this.eTime = stopTime - startTime;
-            totalTime += eTime;
-            if ((this.minTime == UNDEFINED_VALUE) || (eTime < this.minTime)) {
-                this.minTime = this.eTime;
-            }
-            if (eTime > this.maxTime) {
-                this.maxTime = this.eTime;
-            }
-        }
-    }
-
-    /**
-     * Gets a elapse time.
-     * @return the elapse time.
-     */
-    public long getTime() {
-        return eTime;
-    }
-
-    /**
-     * Gets the Min time.
-     * @return the min time.
-     */
-    public long getMinTime() {
-        return this.minTime;
-    }
-
-    /**
-     * Gets the max time.
-     * @return the max time.
-     */
-    public long getMaxTime() {
-        return this.maxTime;
-    }
-
-    /**
-     * Gets the accumulated time.
-     * @return the accumulated time.
-     */
-    public long getTotalTime() {
-        return this.totalTime;
-    }
-
-    /**
-     * Gets the startTime.
-     * @return the date in a long format.
-     */
-    public long getStartTime() {
-        return this.startTime;
-    }
-
-    /**
-     * Get the stopTime.
-     * @return the date in long format.
-     */
-    public long getStopTime() {
-        return this.stopTime;
-    }
-
-    /**
-     * Gets the counter object.
-     * @return the counterMonitor object.
-     */
-    public CounterMonitor getCounter() {
-        return this.counter;
-    }
-
-    /**
-     * Gets the type of the OperationMonitor object.
-     * @return the OperationType.
-     */
-    public OperationType getType() {
-        return this.opType;
-    }
-
-    /**
-     * Reset the values to 0.
-     */
-    public void reset() {
-        this.counter.reset();
-        this.totalTime=UNDEFINED_VALUE;
-        this.minTime=UNDEFINED_VALUE;
-        this.maxTime=UNDEFINED_VALUE;
-    }
-
-    /**
-     * Updates the associated monitor provider object calling
-     * updateMonitorData() method of the monitorProvider object.
-     * @param provider to update.
-     */
-    public void updateMonitorProvider(MonitorProvider provider) {
-        provider.updateMonitorData();
-    }
-
-    /**
-     * Updates the associated monitor provider object.
-     * @param stats provider to update.
-     */
-    public void updateMonitorProvider(LDAPStatistics stats) {
-        stats.updateMonitor(this);
-    }
-}
diff --git a/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java b/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
index b73b946..b14755b 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
@@ -72,7 +72,6 @@
 import org.opends.server.extensions.TLSByteChannel;
 import org.opends.server.extensions.TLSCapableConnection;
 import org.opends.server.loggers.debug.DebugTracer;
-import org.opends.server.monitors.OperationMonitor;
 import org.opends.server.protocols.asn1.ASN1;
 import org.opends.server.protocols.asn1.ASN1ByteChannelReader;
 import org.opends.server.protocols.asn1.ASN1Reader;
@@ -207,9 +206,8 @@
 
   // The statistics tracker associated with this client connection.
   private final LDAPStatistics statTracker;
+  private boolean useNanoTime=false;
 
-  // The connectionHandler statistic tracker.
-  private final LDAPStatistics parentTracker;
 
   // The connection ID assigned to this connection.
   private final long connectionID;
@@ -248,19 +246,6 @@
   private volatile ConnectionSecurityProvider tlsPendingProvider = null;
   private volatile ConnectionSecurityProvider saslPendingProvider = null;
 
-  // Statistics for the processed operations
-  private OperationMonitor addMonitor;
-  private OperationMonitor searchMonitor;
-  private OperationMonitor abandonMonitor;
-  private OperationMonitor bindMonitor;
-  private OperationMonitor compareMonitor;
-  private OperationMonitor delMonitor;
-  private OperationMonitor extendedMonitor;
-  private OperationMonitor modMonitor;
-  private OperationMonitor moddnMonitor;
-  private OperationMonitor unbindMonitor;
-
-
 
   /**
    * Creates a new LDAP client connection with the provided information.
@@ -304,15 +289,14 @@
     serverAddress =
         clientChannel.socket().getLocalAddress().getHostAddress();
     serverPort = clientChannel.socket().getLocalPort();
-    parentTracker = connectionHandler.getStatTracker();
-    String instanceName =
-        parentTracker.getMonitorInstanceName() + " for " + toString();
-    this.initializeOperationMonitors();
-    statTracker = new LDAPStatistics(instanceName, parentTracker);
+
+    statTracker =
+            this.connectionHandler.getStatTracker();
 
     if (keepStats)
     {
       statTracker.updateConnect();
+      this.useNanoTime=DirectoryServer.getUseNanoTime();
     }
 
     tlsChannel =
@@ -331,8 +315,6 @@
     }
   }
 
-
-
   /**
    * Retrieves the connection ID assigned to this connection.
    *
@@ -545,6 +527,19 @@
     // can't be canceled after this point, and this will avoid potential
     // race conditions in which the client immediately sends another
     // request with the same message ID as was used for this operation.
+
+    if (keepStats) {
+        long time;
+        if (useNanoTime) {
+            time = operation.getProcessingNanoTime();
+        } else {
+            time = operation.getProcessingTime();
+        }
+        this.statTracker.updateOperationMonitoringData(
+                operation.getOperationType(),
+                time);
+    }
+
     removeOperationInProgress(operation.getMessageID());
 
     LDAPMessage message = operationToResponseLDAPMessage(operation);
@@ -1528,25 +1523,12 @@
       switch (message.getProtocolOpType())
       {
       case OP_TYPE_ABANDON_REQUEST:
-        if (keepStats) this.abandonMonitor.start();
         result = processAbandonRequest(message, opControls);
-        if (keepStats)
-        {
-          this.abandonMonitor.stop();
-          this.abandonMonitor.updateMonitorProvider(statTracker);
-        }
         return result;
       case OP_TYPE_ADD_REQUEST:
-        if (keepStats) this.addMonitor.start();
         result = processAddRequest(message, opControls);
-        if (keepStats)
-        {
-          this.addMonitor.stop();
-          this.addMonitor.updateMonitorProvider(statTracker);
-        }
         return result;
       case OP_TYPE_BIND_REQUEST:
-        if (keepStats) this.bindMonitor.start();
         bindOrStartTLSInProgress.set(true);
         if(message.getBindRequestProtocolOp().
             getAuthenticationType() == AuthenticationType.SASL)
@@ -1563,32 +1545,14 @@
             saslBindInProgress.set(false);
           }
         }
-        if (keepStats)
-        {
-          this.bindMonitor.stop();
-          this.bindMonitor.updateMonitorProvider(statTracker);
-        }
         return result;
       case OP_TYPE_COMPARE_REQUEST:
-        if (keepStats) this.compareMonitor.start();
         result = processCompareRequest(message, opControls);
-        if (keepStats)
-        {
-          this.compareMonitor.stop();
-          this.compareMonitor.updateMonitorProvider(statTracker);
-        }
         return result;
       case OP_TYPE_DELETE_REQUEST:
-        if (keepStats) this.delMonitor.start();
         result = processDeleteRequest(message, opControls);
-        if (keepStats)
-        {
-          this.delMonitor.stop();
-          this.delMonitor.updateMonitorProvider(statTracker);
-        }
         return result;
       case OP_TYPE_EXTENDED_REQUEST:
-        if (keepStats) this.extendedMonitor.start();
         if(message.getExtendedRequestProtocolOp().getOID().equals(
             OID_START_TLS_REQUEST))
         {
@@ -1601,47 +1565,18 @@
         {
           bindOrStartTLSInProgress.set(false);
         }
-        if (keepStats)
-        {
-          this.extendedMonitor.stop();
-          this.extendedMonitor.updateMonitorProvider(statTracker);
-        }
         return result;
       case OP_TYPE_MODIFY_REQUEST:
-        if (keepStats) this.modMonitor.start();
         result = processModifyRequest(message, opControls);
-        if (keepStats)
-        {
-          this.modMonitor.stop();
-          this.modMonitor.updateMonitorProvider(statTracker);
-        }
         return result;
       case OP_TYPE_MODIFY_DN_REQUEST:
-        if (keepStats) this.moddnMonitor.start();
         result = processModifyDNRequest(message, opControls);
-        if (keepStats)
-        {
-          this.moddnMonitor.stop();
-          this.moddnMonitor.updateMonitorProvider(statTracker);
-        }
         return result;
       case OP_TYPE_SEARCH_REQUEST:
-        if (keepStats) this.searchMonitor.start();
         result = processSearchRequest(message, opControls);
-        if (keepStats)
-        {
-          this.searchMonitor.stop();
-          this.searchMonitor.updateMonitorProvider(statTracker);
-        }
         return result;
       case OP_TYPE_UNBIND_REQUEST:
-        if (keepStats) this.unbindMonitor.start();
         result = processUnbindRequest(message, opControls);
-        if (keepStats)
-        {
-          this.unbindMonitor.stop();
-          this.unbindMonitor.updateMonitorProvider(statTracker);
-        }
         return result;
       default:
         Message msg =
@@ -2620,24 +2555,6 @@
       return APPLICATION_BUFFER_SIZE;
   }
 
-
-
-  private void initializeOperationMonitors()
-  {
-    this.addMonitor = OperationMonitor.getOperationMonitor(ADD);
-    this.searchMonitor = OperationMonitor.getOperationMonitor(SEARCH);
-    this.abandonMonitor = OperationMonitor.getOperationMonitor(ABANDON);
-    this.bindMonitor = OperationMonitor.getOperationMonitor(BIND);
-    this.compareMonitor = OperationMonitor.getOperationMonitor(COMPARE);
-    this.delMonitor = OperationMonitor.getOperationMonitor(DELETE);
-    this.extendedMonitor =
-        OperationMonitor.getOperationMonitor(EXTENDED);
-    this.modMonitor = OperationMonitor.getOperationMonitor(MODIFY);
-    this.moddnMonitor = OperationMonitor.getOperationMonitor(MODIFY_DN);
-    this.unbindMonitor = OperationMonitor.getOperationMonitor(UNBIND);
-  }
-
-
   /**
    * {@inheritDoc}
    */
diff --git a/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java b/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java
index 74e28f0..65f5113 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java
@@ -30,20 +30,20 @@
 
 import static org.opends.messages.ProtocolMessages.*;
 import static org.opends.server.protocols.ldap.LDAPConstants.*;
-import static org.opends.server.types.OperationType.*;
 
 import java.util.ArrayList;
 
+import java.util.concurrent.atomic.AtomicLong;
 import org.opends.messages.Message;
 import org.opends.server.admin.std.server.MonitorProviderCfg;
 import org.opends.server.api.MonitorProvider;
 import org.opends.server.config.ConfigException;
 import org.opends.server.core.DirectoryServer;
-import org.opends.server.monitors.OperationMonitor;
 import org.opends.server.types.Attribute;
 import org.opends.server.types.AttributeBuilder;
 import org.opends.server.types.AttributeType;
 import org.opends.server.types.AttributeValues;
+import org.opends.server.types.OperationType;
 
 
 
@@ -74,87 +74,61 @@
 {
 
   // The statistics maintained by this class.
-  private long abandonRequests;
-  private long addRequests;
-  private long addResponses;
-  private long bindRequests;
-  private long bindResponses;
-  private long bytesRead;
-  private long bytesWritten;
-  private long compareRequests;
-  private long compareResponses;
-  private long connectionsClosed;
-  private long connectionsEstablished;
-  private long deleteRequests;
-  private long deleteResponses;
-  private long extendedRequests;
-  private long extendedResponses;
-  private long messagesRead;
-  private long messagesWritten;
-  private long modifyRequests;
-  private long modifyResponses;
-  private long modifyDNRequests;
-  private long modifyDNResponses;
-  private long operationsAbandoned;
-  private long operationsCompleted;
-  private long operationsInitiated;
-  private long searchRequests;
-  private long searchResultEntries;
-  private long searchResultReferences;
-  private long searchResultsDone;
-  private long unbindRequests;
+  private AtomicLong abandonRequests = new AtomicLong(0);
+  private AtomicLong addRequests = new AtomicLong(0);
+  private AtomicLong bindRequests = new AtomicLong(0);
+  private AtomicLong addResponses = new AtomicLong(0);
+  private AtomicLong bindResponses = new AtomicLong(0);
+  private AtomicLong bytesRead = new AtomicLong(0);
+  private AtomicLong bytesWritten = new AtomicLong(0);
+  private AtomicLong compareRequests = new AtomicLong(0);
+  private AtomicLong compareResponses = new AtomicLong(0);
+  private AtomicLong connectionsClosed = new AtomicLong(0);
+  private AtomicLong connectionsEstablished = new AtomicLong(0);
+  private AtomicLong deleteRequests = new AtomicLong(0);
+  private AtomicLong deleteResponses = new AtomicLong(0);
+  private AtomicLong extendedRequests = new AtomicLong(0);
+  private AtomicLong extendedResponses = new AtomicLong(0);
+  private AtomicLong messagesRead = new AtomicLong(0);
+  private AtomicLong messagesWritten = new AtomicLong(0);
+  private AtomicLong modifyRequests = new AtomicLong(0);
+  private AtomicLong modifyResponses = new AtomicLong(0);
+  private AtomicLong modifyDNRequests = new AtomicLong(0);
+  private AtomicLong modifyDNResponses = new AtomicLong(0);
+  private AtomicLong operationsAbandoned = new AtomicLong(0);
+  private AtomicLong operationsCompleted = new AtomicLong(0);
+  private AtomicLong operationsInitiated = new AtomicLong(0);
+  private AtomicLong searchRequests = new AtomicLong(0);
+  private AtomicLong searchResultEntries = new AtomicLong(0);
+  private AtomicLong searchResultReferences = new AtomicLong(0);
+  private AtomicLong searchResultsDone = new AtomicLong(0);
+  private AtomicLong unbindRequests = new AtomicLong(0);
 
-  // The parent that should also be updated whenever statistics in this
-  // object are updated.
-  private final LDAPStatistics parent;
-
-  // The locks used to provide threadsafe access to this class. In this
-  // case, read and write refer to the type of LDAP communication, not
-  // access to the protected data.
-  private final Object abandonLock;
-  private final Object connectLock;
-  private final Object disconnectLock;
-  private final Object readLock;
-  private final Object writeLock;
 
   // The instance name for this monitor provider instance.
   private final String instanceName;
 
-  // Monitor Objects : for Operations.
-  private final OperationMonitor addRequestsMonitor =
-      OperationMonitor.getOperationMonitor(ADD);
-  private final OperationMonitor searchRequestsMonitor =
-      OperationMonitor.getOperationMonitor(SEARCH);
-  private final OperationMonitor delRequestsMonitor =
-      OperationMonitor.getOperationMonitor(DELETE);
-  private final OperationMonitor bindRequestsMonitor =
-      OperationMonitor.getOperationMonitor(BIND);
-  private final OperationMonitor unbindRequestsMonitor =
-      OperationMonitor.getOperationMonitor(UNBIND);
-  private final OperationMonitor compareRequestsMonitor =
-      OperationMonitor.getOperationMonitor(COMPARE);
-  private final OperationMonitor modRequestsMonitor =
-      OperationMonitor.getOperationMonitor(MODIFY);
-  private final OperationMonitor moddnRequestsMonitor =
-      OperationMonitor.getOperationMonitor(MODIFY);
-  private final OperationMonitor abandonRequestsMonitor =
-      OperationMonitor.getOperationMonitor(ABANDON);
-  private final OperationMonitor extendedRequestsMonitor =
-      OperationMonitor.getOperationMonitor(EXTENDED);
-
-
-
-  /**
-   * Creates a new instance of this class with no parent.
-   *
-   * @param instanceName
-   *          The name for this monitor provider instance.
-   */
-  public LDAPStatistics(String instanceName)
-  {
-    this(instanceName, null);
-  }
-
+  // Monitor Objects : for Operations (count and time)
+  private AtomicLong addOperationCount = new AtomicLong(0);
+  private AtomicLong addOperationTime = new AtomicLong(0);
+  private AtomicLong searchOperationCount = new AtomicLong(0);
+  private AtomicLong searchOperationTime = new AtomicLong(0);
+  private AtomicLong delOperationCount = new AtomicLong(0);
+  private AtomicLong delOperationTime = new AtomicLong(0);
+  private AtomicLong bindOperationCount = new AtomicLong(0);
+  private AtomicLong bindOperationTime = new AtomicLong(0);
+  private AtomicLong unbindOperationCount = new AtomicLong(0);
+  private AtomicLong unbindOperationTime = new AtomicLong(0);
+  private AtomicLong compOperationCount = new AtomicLong(0);
+  private AtomicLong compOperationTime = new AtomicLong(0);
+  private AtomicLong modOperationCount = new AtomicLong(0);
+  private AtomicLong modOperationTime = new AtomicLong(0);
+  private AtomicLong moddnOperationCount = new AtomicLong(0);
+  private AtomicLong moddnOperationTime = new AtomicLong(0);
+  private AtomicLong abandonOperationCount = new AtomicLong(0);
+  private AtomicLong abandonOperationTime = new AtomicLong(0);
+  private AtomicLong extOperationCount = new AtomicLong(0);
+  private AtomicLong extOperationTime = new AtomicLong(0);
 
 
   /**
@@ -162,53 +136,11 @@
    *
    * @param instanceName
    *          The name for this monitor provider instance.
-   * @param parent
-   *          The parent object that should also be updated whenever
-   *          this class is updated. It may be null if there should not
-   *          be a parent.
    */
-  public LDAPStatistics(String instanceName, LDAPStatistics parent)
+  public LDAPStatistics(String instanceName)
   {
     super("LDAP Statistics Monitor Provider");
-
     this.instanceName = instanceName;
-    this.parent = parent;
-
-    abandonLock = new Object();
-    connectLock = new Object();
-    disconnectLock = new Object();
-    readLock = new Object();
-    writeLock = new Object();
-
-    abandonRequests = 0;
-    addRequests = 0;
-    addResponses = 0;
-    bindRequests = 0;
-    bindResponses = 0;
-    bytesRead = 0;
-    bytesWritten = 0;
-    compareRequests = 0;
-    compareResponses = 0;
-    connectionsClosed = 0;
-    connectionsEstablished = 0;
-    deleteRequests = 0;
-    deleteResponses = 0;
-    extendedRequests = 0;
-    extendedResponses = 0;
-    messagesRead = 0;
-    messagesWritten = 0;
-    modifyRequests = 0;
-    modifyResponses = 0;
-    modifyDNRequests = 0;
-    modifyDNResponses = 0;
-    operationsAbandoned = 0;
-    operationsCompleted = 0;
-    operationsInitiated = 0;
-    searchRequests = 0;
-    searchResultEntries = 0;
-    searchResultReferences = 0;
-    searchResultsDone = 0;
-    unbindRequests = 0;
   }
 
 
@@ -295,86 +227,59 @@
   @Override
   public ArrayList<Attribute> getMonitorData()
   {
-    ArrayList<Attribute> attrs = new ArrayList<Attribute>(29);
 
-    long tmpAbandonRequests;
-    long tmpAddRequests;
-    long tmpAddResponses;
-    long tmpBindRequests;
-    long tmpBindResponses;
-    long tmpBytesRead;
-    long tmpBytesWritten;
-    long tmpCompareRequests;
-    long tmpCompareResponses;
-    long tmpConnectionsClosed;
-    long tmpConnectionsEstablished;
-    long tmpDeleteRequests;
-    long tmpDeleteResponses;
-    long tmpExtendedRequests;
-    long tmpExtendedResponses;
-    long tmpMessagesRead;
-    long tmpMessagesWritten;
-    long tmpModifyRequests;
-    long tmpModifyResponses;
-    long tmpModifyDNRequests;
-    long tmpModifyDNResponses;
-    long tmpOperationsAbandoned;
-    long tmpOperationsCompleted;
-    long tmpOperationsInitiated;
-    long tmpSearchRequests;
-    long tmpSearchEntries;
-    long tmpSearchReferences;
-    long tmpSearchResultsDone;
-    long tmpUnbindRequests;
+      ArrayList<Attribute> attrs = new ArrayList<Attribute>();
 
-    // Quickly grab the locks and store consistent copies of the
-    // information. Note that when grabbing multiple locks, it is
-    // essential that they are all acquired in the same order to prevent
-    // deadlocks.
-    synchronized (abandonLock)
-    {
-      synchronized (connectLock)
-      {
-        synchronized (disconnectLock)
-        {
-          synchronized (writeLock)
-          {
-            synchronized (readLock)
-            {
-              tmpAbandonRequests = abandonRequests;
-              tmpAddRequests = addRequests;
-              tmpAddResponses = addResponses;
-              tmpBindRequests = bindRequests;
-              tmpBindResponses = bindResponses;
-              tmpBytesRead = bytesRead;
-              tmpBytesWritten = bytesWritten;
-              tmpCompareRequests = compareRequests;
-              tmpCompareResponses = compareResponses;
-              tmpConnectionsClosed = connectionsClosed;
-              tmpConnectionsEstablished = connectionsEstablished;
-              tmpDeleteRequests = deleteRequests;
-              tmpDeleteResponses = deleteResponses;
-              tmpExtendedRequests = extendedRequests;
-              tmpExtendedResponses = extendedResponses;
-              tmpMessagesRead = messagesRead;
-              tmpMessagesWritten = messagesWritten;
-              tmpModifyRequests = modifyRequests;
-              tmpModifyResponses = modifyResponses;
-              tmpModifyDNRequests = modifyDNRequests;
-              tmpModifyDNResponses = modifyDNResponses;
-              tmpOperationsAbandoned = operationsAbandoned;
-              tmpOperationsCompleted = operationsCompleted;
-              tmpOperationsInitiated = operationsInitiated;
-              tmpSearchRequests = searchRequests;
-              tmpSearchEntries = searchResultEntries;
-              tmpSearchReferences = searchResultReferences;
-              tmpSearchResultsDone = searchResultsDone;
-              tmpUnbindRequests = unbindRequests;
-            }
-          }
-        }
-      }
-    }
+      long tmpAbandonRequests = abandonRequests.get();
+      long tmpAddRequests = addRequests.get();
+      long tmpAddResponses = addResponses.get();
+      long tmpBindRequests = bindRequests.get();
+      long tmpBindResponses = bindResponses.get();
+      long tmpBytesRead = bytesRead.get();
+      long tmpBytesWritten = bytesWritten.get();
+      long tmpCompareRequests = compareRequests.get();
+      long tmpCompareResponses = compareResponses.get();
+      long tmpConnectionsClosed = connectionsClosed.get();
+      long tmpConnectionsEstablished = connectionsEstablished.get();
+      long tmpDeleteRequests = deleteRequests.get();
+      long tmpDeleteResponses = deleteResponses.get();
+      long tmpExtendedRequests = extendedRequests.get();
+      long tmpExtendedResponses = extendedResponses.get();
+      long tmpMessagesRead = messagesRead.get();
+      long tmpMessagesWritten = messagesWritten.get();
+      long tmpModifyRequests = modifyRequests.get();
+      long tmpModifyResponses = modifyResponses.get();
+      long tmpModifyDNRequests = modifyDNRequests.get();
+      long tmpModifyDNResponses = modifyDNResponses.get();
+      long tmpOperationsAbandoned = operationsAbandoned.get();
+      long tmpOperationsCompleted = operationsCompleted.get();
+      long tmpOperationsInitiated = operationsInitiated.get();
+      long tmpSearchRequests = searchRequests.get();
+      long tmpSearchEntries = searchResultEntries.get();
+      long tmpSearchReferences = searchResultReferences.get();
+      long tmpSearchResultsDone = searchResultsDone.get();
+      long tmpUnbindRequests = unbindRequests.get();
+      long tmpAddOperationCount = addOperationCount.get();
+      long tmpAddOperationTime = addOperationTime.get();
+      long tmpSearchOperationCount = searchOperationCount.get();
+      long tmpSearchOperationTime = searchOperationTime.get();
+      long tmpDelOperationCount = delOperationCount.get();
+      long tmpDelOperationTime = delOperationTime.get();
+      long tmpBindOperationCount = bindOperationCount.get();
+      long tmpBindOperationTime = bindOperationTime.get();
+      long tmpUnbindOperationCount = unbindOperationCount.get();
+      long tmpUnbindOperationTime = unbindOperationTime.get();
+      long tmpCompOperationCount = compOperationCount.get();
+      long tmpCompOperationTime = compOperationTime.get();
+      long tmpModOperationCount = modOperationCount.get();
+      long tmpModOperationTime = modOperationTime.get();
+      long tmpModdnOperationCount = moddnOperationCount.get();
+      long tmpModdnOperationTime = moddnOperationTime.get();
+      long tmpAbandonOperationCount = abandonOperationCount.get();
+      long tmpAbandonOperationTime = abandonOperationTime.get();
+      long tmpExtOperationCount = extOperationCount.get();
+      long tmpExtOperationTime = extOperationTime.get();
+
 
     // Construct the list of attributes to return.
     attrs.add(createAttribute("connectionsEstablished", String
@@ -438,78 +343,76 @@
 
     // adds
     attrs.add(createAttribute("ds-mon-add-operations-total-count",
-        String.valueOf(addRequestsMonitor.getCounter().getCount())));
+        String.valueOf(tmpAddOperationCount)));
+
     attrs.add(createAttribute(
         "ds-mon-resident-time-add-operations-total-time", String
-            .valueOf(addRequestsMonitor.getTotalTime())));
+            .valueOf(tmpAddOperationTime)));
 
     // search
     attrs.add(createAttribute("ds-mon-search-operations-total-count",
-        String.valueOf(searchRequestsMonitor.getCounter().getCount())));
+        String.valueOf(tmpSearchOperationCount)));
     attrs.add(createAttribute(
         "ds-mon-resident-time-search-operations-total-time", String
-            .valueOf(searchRequestsMonitor.getTotalTime())));
+            .valueOf(tmpSearchOperationTime)));
 
     // bind
     attrs.add(createAttribute("ds-mon-bind-operations-total-count",
-        String.valueOf(bindRequestsMonitor.getCounter().getCount())));
+        String.valueOf(tmpBindOperationCount)));
     attrs.add(createAttribute(
         "ds-mon-resident-time-bind-operations-total-time", String
-            .valueOf(bindRequestsMonitor.getTotalTime())));
+            .valueOf(tmpBindOperationTime)));
 
     // unbind
     attrs.add(createAttribute("ds-mon-unbind-operations-total-count",
-        String.valueOf(unbindRequestsMonitor.getCounter().getCount())));
+        String.valueOf(tmpUnbindOperationCount)));
     attrs.add(createAttribute(
         "ds-mon-resident-time-unbind-operations-total-time", String
-            .valueOf(unbindRequestsMonitor.getTotalTime())));
+            .valueOf(tmpUnbindOperationTime)));
 
     // compare
     attrs
         .add(createAttribute("ds-mon-compare-operations-total-count",
-            String.valueOf(compareRequestsMonitor.getCounter()
-                .getCount())));
+            String.valueOf(tmpCompOperationCount)));
     attrs.add(createAttribute(
         "ds-mon-resident-time-compare-operations-total-time", String
-            .valueOf(compareRequestsMonitor.getTotalTime())));
+            .valueOf(tmpCompOperationTime)));
     // del
     attrs.add(createAttribute("ds-mon-delete-operations-total-count",
-        String.valueOf(delRequestsMonitor.getCounter().getCount())));
+        String.valueOf(tmpDelOperationCount)));
     attrs.add(createAttribute(
         "ds-mon-resident-time-delete-operations-total-time", String
-            .valueOf(delRequestsMonitor.getTotalTime())));
+            .valueOf(tmpDelOperationTime)));
 
     // mod
     attrs.add(createAttribute("ds-mon-mod-operations-total-count",
-        String.valueOf(modRequestsMonitor.getCounter().getCount())));
+        String.valueOf(tmpModOperationCount)));
     attrs.add(createAttribute(
         "ds-mon-resident-time-mod-operations-total-time", String
-            .valueOf(modRequestsMonitor.getTotalTime())));
+            .valueOf(tmpModOperationTime)));
 
     // moddn
     attrs.add(createAttribute("ds-mon-moddn-operations-total-count",
-        String.valueOf(moddnRequestsMonitor.getCounter().getCount())));
+        String.valueOf(tmpModdnOperationCount)));
     attrs.add(createAttribute(
         "ds-mon-resident-time-moddn-operations-total-time", String
-            .valueOf(moddnRequestsMonitor.getTotalTime())));
+            .valueOf(tmpModdnOperationTime)));
 
     // abandon
     attrs
         .add(createAttribute("ds-mon-abandon-operations-total-count",
-            String.valueOf(abandonRequestsMonitor.getCounter()
-                .getCount())));
+            String.valueOf(tmpAbandonOperationCount)));
     attrs.add(createAttribute(
         "ds-mon-resident-time-abandon-operations-total-time", String
-            .valueOf(abandonRequestsMonitor.getTotalTime())));
+            .valueOf(tmpAbandonOperationTime)));
 
     // extended
     attrs
         .add(createAttribute("ds-mon-extended-operations-total-count",
-            String.valueOf(extendedRequestsMonitor.getCounter()
-                .getCount())));
+            String.valueOf(tmpExtOperationCount)));
     attrs.add(createAttribute(
         "ds-mon-resident-time-extended-operations-total-time", String
-            .valueOf(extendedRequestsMonitor.getTotalTime())));
+            .valueOf(tmpExtOperationTime)));
 
     return attrs;
   }
@@ -521,74 +424,68 @@
    */
   public void clearStatistics()
   {
-    // Quickly grab the locks and store consistent copies of the
-    // information. Note that when grabbing multiple locks, it is
-    // essential that they are all acquired in the same order to prevent
-    // deadlocks.
-    synchronized (abandonLock)
-    {
-      synchronized (connectLock)
-      {
-        synchronized (disconnectLock)
-        {
-          synchronized (writeLock)
-          {
-            synchronized (readLock)
-            {
-              abandonRequests = 0;
-              addRequests = 0;
-              addResponses = 0;
-              bindRequests = 0;
-              bindResponses = 0;
-              bytesRead = 0;
-              bytesWritten = 0;
-              compareRequests = 0;
-              compareResponses = 0;
-              connectionsClosed = 0;
-              connectionsEstablished = 0;
-              deleteRequests = 0;
-              deleteResponses = 0;
-              extendedRequests = 0;
-              extendedResponses = 0;
-              messagesRead = 0;
-              messagesWritten = 0;
-              modifyRequests = 0;
-              modifyResponses = 0;
-              modifyDNRequests = 0;
-              modifyDNResponses = 0;
-              operationsAbandoned = 0;
-              operationsCompleted = 0;
-              operationsInitiated = 0;
-              searchRequests = 0;
-              searchResultEntries = 0;
-              searchResultReferences = 0;
-              searchResultsDone = 0;
-              unbindRequests = 0;
-            }
-          }
-        }
-      }
-    }
+      abandonRequests.set(0);
+      addRequests.set(0);
+      addResponses.set(0);
+      bindRequests.set(0);
+      bindResponses.set(0);
+      bytesRead.set(0);
+      bytesWritten.set(0);
+      compareRequests.set(0);
+      compareResponses.set(0);
+      connectionsClosed.set(0);
+      connectionsEstablished.set(0);
+      deleteRequests.set(0);
+      deleteResponses.set(0);
+      extendedRequests.set(0);
+      extendedResponses.set(0);
+      messagesRead.set(0);
+      messagesWritten.set(0);
+      modifyRequests.set(0);
+      modifyResponses.set(0);
+      modifyDNRequests.set(0);
+      modifyDNResponses.set(0);
+      operationsAbandoned.set(0);
+      operationsCompleted.set(0);
+      operationsInitiated.set(0);
+      searchRequests.set(0);
+      searchResultEntries.set(0);
+      searchResultReferences.set(0);
+      searchResultsDone.set(0);
+      unbindRequests.set(0);
+
+      addOperationCount.set(0);
+      addOperationTime.set(0);
+      searchOperationCount.set(0);
+      searchOperationTime.set(0);
+      delOperationCount.set(0);
+      delOperationTime.set(0);
+      bindOperationCount.set(0);
+      bindOperationTime.set(0);
+      unbindOperationCount.set(0);
+      unbindOperationTime.set(0);
+      compOperationCount.set(0);
+      compOperationTime.set(0);
+      modOperationCount.set(0);
+      modOperationTime.set(0);
+      moddnOperationCount.set(0);
+      moddnOperationTime.set(0);
+      abandonOperationCount.set(0);
+      abandonOperationTime.set(0);
+      extOperationCount.set(0);
+      extOperationTime.set(0);
   }
 
 
 
+
   /**
    * Updates the appropriate set of counters to indicate that a new
    * connection has been established.
    */
   public void updateConnect()
   {
-    synchronized (connectLock)
-    {
-      connectionsEstablished++;
-    }
-
-    // Update the parent if there is one.
-    if (parent != null)
-    {
-      parent.updateConnect();
-    }
+    connectionsEstablished.getAndIncrement();
   }
 
 
@@ -599,16 +496,7 @@
    */
   public void updateDisconnect()
   {
-    synchronized (disconnectLock)
-    {
-      connectionsClosed++;
-    }
-
-    // Update the parent if there is one.
-    if (parent != null)
-    {
-      parent.updateDisconnect();
-    }
+      connectionsClosed.getAndIncrement();
   }
 
 
@@ -622,16 +510,7 @@
    */
   public void updateBytesRead(int bytesRead)
   {
-    synchronized (readLock)
-    {
-      this.bytesRead += bytesRead;
-    }
-
-    // Update the parent if there is one.
-    if (parent != null)
-    {
-      parent.updateBytesRead(bytesRead);
-    }
+     this.bytesRead.getAndAdd(bytesRead);
   }
 
 
@@ -645,51 +524,42 @@
    */
   public void updateMessageRead(LDAPMessage message)
   {
-    synchronized (readLock)
-    {
-      messagesRead++;
-      operationsInitiated++;
+      messagesRead.getAndIncrement();
+      operationsInitiated.getAndIncrement();
 
       switch (message.getProtocolOp().getType())
       {
       case OP_TYPE_ABANDON_REQUEST:
-        abandonRequests++;
+        abandonRequests.getAndIncrement();
         break;
       case OP_TYPE_ADD_REQUEST:
-        addRequests++;
+        addRequests.getAndIncrement();
         break;
       case OP_TYPE_BIND_REQUEST:
-        bindRequests++;
+        bindRequests.getAndIncrement();
         break;
       case OP_TYPE_COMPARE_REQUEST:
-        compareRequests++;
+        compareRequests.getAndIncrement();
         break;
       case OP_TYPE_DELETE_REQUEST:
-        deleteRequests++;
+        deleteRequests.getAndIncrement();
         break;
       case OP_TYPE_EXTENDED_REQUEST:
-        extendedRequests++;
+        extendedRequests.getAndIncrement();
         break;
       case OP_TYPE_MODIFY_REQUEST:
-        modifyRequests++;
+        modifyRequests.getAndIncrement();
         break;
       case OP_TYPE_MODIFY_DN_REQUEST:
-        modifyDNRequests++;
+        modifyDNRequests.getAndIncrement();
         break;
       case OP_TYPE_SEARCH_REQUEST:
-        searchRequests++;
+        searchRequests.getAndIncrement();
         break;
       case OP_TYPE_UNBIND_REQUEST:
-        unbindRequests++;
+        unbindRequests.getAndIncrement();
         break;
       }
-    }
-
-    // Update the parent if there is one.
-    if (parent != null)
-    {
-      parent.updateMessageRead(message);
-    }
   }
 
 
@@ -705,65 +575,56 @@
    */
   public void updateMessageWritten(LDAPMessage message, int bytesWritten)
   {
-    synchronized (writeLock)
-    {
-      this.bytesWritten += bytesWritten;
-      messagesWritten++;
+      this.bytesWritten.getAndAdd(bytesWritten);
+      messagesWritten.getAndIncrement();
 
       switch (message.getProtocolOp().getType())
       {
       case OP_TYPE_ADD_RESPONSE:
-        addResponses++;
-        operationsCompleted++;
+        addResponses.getAndIncrement();
+        operationsCompleted.getAndIncrement();
         break;
       case OP_TYPE_BIND_RESPONSE:
-        bindResponses++;
-        operationsCompleted++;
+        bindResponses.getAndIncrement();
+        operationsCompleted.getAndIncrement();
         break;
       case OP_TYPE_COMPARE_RESPONSE:
-        compareResponses++;
-        operationsCompleted++;
+        compareResponses.getAndIncrement();
+        operationsCompleted.getAndIncrement();
         break;
       case OP_TYPE_DELETE_RESPONSE:
-        deleteResponses++;
-        operationsCompleted++;
+        deleteResponses.getAndIncrement();
+        operationsCompleted.getAndIncrement();
         break;
       case OP_TYPE_EXTENDED_RESPONSE:
-        extendedResponses++;
+        extendedResponses.getAndIncrement();
 
         // We don't want to include unsolicited notifications as
         // "completed" operations.
         if (message.getMessageID() > 0)
         {
-          operationsCompleted++;
+          operationsCompleted.getAndIncrement();
         }
         break;
       case OP_TYPE_MODIFY_RESPONSE:
-        modifyResponses++;
-        operationsCompleted++;
+        modifyResponses.getAndIncrement();
+        operationsCompleted.getAndIncrement();
         break;
       case OP_TYPE_MODIFY_DN_RESPONSE:
-        modifyDNResponses++;
-        operationsCompleted++;
+        modifyDNResponses.getAndIncrement();
+        operationsCompleted.getAndIncrement();
         break;
       case OP_TYPE_SEARCH_RESULT_ENTRY:
-        searchResultEntries++;
+        searchResultEntries.getAndIncrement();
         break;
       case OP_TYPE_SEARCH_RESULT_REFERENCE:
-        searchResultReferences++;
+        searchResultReferences.getAndIncrement();
         break;
       case OP_TYPE_SEARCH_RESULT_DONE:
-        searchResultsDone++;
-        operationsCompleted++;
+        searchResultsDone.getAndIncrement();
+        operationsCompleted.getAndIncrement();
         break;
       }
-    }
-
-    // Update the parent if there is one.
-    if (parent != null)
-    {
-      parent.updateMessageWritten(message, bytesWritten);
-    }
   }
 
 
@@ -774,16 +635,7 @@
    */
   public void updateAbandonedOperation()
   {
-    synchronized (abandonLock)
-    {
-      operationsAbandoned++;
-    }
-
-    // Update the parent if there is one.
-    if (parent != null)
-    {
-      parent.updateAbandonedOperation();
-    }
+      operationsAbandoned.getAndIncrement();
   }
 
 
@@ -820,10 +672,7 @@
    */
   public long getConnectionsEstablished()
   {
-    synchronized (connectLock)
-    {
-      return connectionsEstablished;
-    }
+   return connectionsEstablished.get();
   }
 
 
@@ -835,10 +684,8 @@
    */
   public long getConnectionsClosed()
   {
-    synchronized (disconnectLock)
-    {
-      return connectionsClosed;
-    }
+      return connectionsClosed.get();
+
   }
 
 
@@ -850,10 +697,7 @@
    */
   public long getBytesRead()
   {
-    synchronized (readLock)
-    {
-      return bytesRead;
-    }
+      return bytesRead.get();
   }
 
 
@@ -865,10 +709,7 @@
    */
   public long getBytesWritten()
   {
-    synchronized (writeLock)
-    {
-      return bytesWritten;
-    }
+      return bytesWritten.get();
   }
 
 
@@ -882,10 +723,7 @@
    */
   public long getMessagesRead()
   {
-    synchronized (readLock)
-    {
-      return messagesRead;
-    }
+    return messagesRead.get();
   }
 
 
@@ -899,10 +737,7 @@
    */
   public long getMessagesWritten()
   {
-    synchronized (writeLock)
-    {
-      return messagesWritten;
-    }
+   return messagesWritten.get();
   }
 
 
@@ -916,10 +751,7 @@
    */
   public long getOperationsInitiated()
   {
-    synchronized (readLock)
-    {
-      return operationsInitiated;
-    }
+    return operationsInitiated.get();
   }
 
 
@@ -933,10 +765,7 @@
    */
   public long getOperationsCompleted()
   {
-    synchronized (writeLock)
-    {
-      return operationsCompleted;
-    }
+      return operationsCompleted.get();
   }
 
 
@@ -950,10 +779,7 @@
    */
   public long getOperationsAbandoned()
   {
-    synchronized (abandonLock)
-    {
-      return operationsAbandoned;
-    }
+      return operationsAbandoned.get();
   }
 
 
@@ -965,10 +791,7 @@
    */
   public long getAbandonRequests()
   {
-    synchronized (readLock)
-    {
-      return abandonRequests;
-    }
+      return abandonRequests.get();
   }
 
 
@@ -980,10 +803,7 @@
    */
   public long getAddRequests()
   {
-    synchronized (readLock)
-    {
-      return addRequests;
-    }
+      return addRequests.get();
   }
 
 
@@ -995,10 +815,7 @@
    */
   public long getAddResponses()
   {
-    synchronized (writeLock)
-    {
-      return addResponses;
-    }
+      return addResponses.get();
   }
 
 
@@ -1010,10 +827,7 @@
    */
   public long getBindRequests()
   {
-    synchronized (readLock)
-    {
-      return bindRequests;
-    }
+      return bindRequests.get();
   }
 
 
@@ -1025,10 +839,7 @@
    */
   public long getBindResponses()
   {
-    synchronized (writeLock)
-    {
-      return bindResponses;
-    }
+      return bindResponses.get();
   }
 
 
@@ -1040,10 +851,7 @@
    */
   public long getCompareRequests()
   {
-    synchronized (readLock)
-    {
-      return compareRequests;
-    }
+      return compareRequests.get();
   }
 
 
@@ -1055,10 +863,7 @@
    */
   public long getCompareResponses()
   {
-    synchronized (writeLock)
-    {
-      return compareResponses;
-    }
+      return compareResponses.get();
   }
 
 
@@ -1070,10 +875,7 @@
    */
   public long getDeleteRequests()
   {
-    synchronized (readLock)
-    {
-      return deleteRequests;
-    }
+      return deleteRequests.get();
   }
 
 
@@ -1085,10 +887,7 @@
    */
   public long getDeleteResponses()
   {
-    synchronized (writeLock)
-    {
-      return deleteResponses;
-    }
+      return deleteResponses.get();
   }
 
 
@@ -1100,10 +899,7 @@
    */
   public long getExtendedRequests()
   {
-    synchronized (readLock)
-    {
-      return extendedRequests;
-    }
+      return extendedRequests.get();
   }
 
 
@@ -1115,10 +911,7 @@
    */
   public long getExtendedResponses()
   {
-    synchronized (writeLock)
-    {
-      return extendedResponses;
-    }
+      return extendedResponses.get();
   }
 
 
@@ -1130,10 +923,7 @@
    */
   public long getModifyRequests()
   {
-    synchronized (readLock)
-    {
-      return modifyRequests;
-    }
+      return modifyRequests.get();
   }
 
 
@@ -1145,10 +935,7 @@
    */
   public long getModifyResponses()
   {
-    synchronized (writeLock)
-    {
-      return modifyResponses;
-    }
+      return modifyResponses.get();
   }
 
 
@@ -1160,10 +947,7 @@
    */
   public long getModifyDNRequests()
   {
-    synchronized (readLock)
-    {
-      return modifyDNRequests;
-    }
+      return modifyDNRequests.get();
   }
 
 
@@ -1175,10 +959,7 @@
    */
   public long getModifyDNResponses()
   {
-    synchronized (writeLock)
-    {
-      return modifyDNResponses;
-    }
+      return modifyDNResponses.get();
   }
 
 
@@ -1190,10 +971,7 @@
    */
   public long getSearchRequests()
   {
-    synchronized (readLock)
-    {
-      return searchRequests;
-    }
+      return searchRequests.get();
   }
 
 
@@ -1205,10 +983,7 @@
    */
   public long getSearchResultEntries()
   {
-    synchronized (writeLock)
-    {
-      return searchResultEntries;
-    }
+      return searchResultEntries.get();
   }
 
 
@@ -1221,10 +996,7 @@
    */
   public long getSearchResultReferences()
   {
-    synchronized (writeLock)
-    {
-      return searchResultReferences;
-    }
+      return searchResultReferences.get();
   }
 
 
@@ -1238,10 +1010,7 @@
    */
   public long getSearchResultsDone()
   {
-    synchronized (writeLock)
-    {
-      return searchResultsDone;
-    }
+      return searchResultsDone.get();
   }
 
 
@@ -1253,78 +1022,56 @@
    */
   public long getUnbindRequests()
   {
-    synchronized (readLock)
-    {
-      return unbindRequests;
-    }
+      return unbindRequests.get();
   }
 
-
-
   /**
-   * Retrieves the parent statistics tracker that will also be updated
-   * whenever this tracker is updated.
-   *
-   * @return The parent statistics tracker, or {@code null} if there is
-   *         none.
+   * Update the operation counters and times depending on the OperationType.
+   * @param type of the operation.
+   * @param time of the operation execution.
    */
-  public LDAPStatistics getParent()
-  {
-    return parent;
-  }
 
-
-
-  /**
-   * Updates the monitor object.
-   *
-   * @param opMonitor
-   *          monitor object.
-   */
-  public void updateMonitor(OperationMonitor opMonitor)
-  {
-    synchronized (readLock)
-    {
-      switch (opMonitor.getType())
-      {
-      case ABANDON:
-        this.abandonRequestsMonitor.add(opMonitor);
-        break;
-      case ADD:
-        this.addRequestsMonitor.add(opMonitor);
-        break;
-      case BIND:
-        this.bindRequestsMonitor.add(opMonitor);
-        break;
-      case COMPARE:
-        this.compareRequestsMonitor.add(opMonitor);
-        break;
-      case DELETE:
-        this.delRequestsMonitor.add(opMonitor);
-        break;
-      case EXTENDED:
-        this.extendedRequestsMonitor.add(opMonitor);
-        break;
-      case MODIFY:
-        this.modRequestsMonitor.add(opMonitor);
-        break;
-      case MODIFY_DN:
-        this.moddnRequestsMonitor.add(opMonitor);
-        break;
-      case SEARCH:
-        this.searchRequestsMonitor.add(opMonitor);
-        break;
-      case UNBIND:
-        this.unbindRequestsMonitor.add(opMonitor);
-        break;
-      default:
+  public void updateOperationMonitoringData(OperationType type, long time) {
+      if (type.equals(OperationType.ADD)) {
+          addOperationCount.getAndIncrement();
+          addOperationTime.getAndAdd(time);
       }
-      if (parent != null)
-      {
-        parent.updateMonitor(opMonitor);
+      else if (type.equals(OperationType.SEARCH)) {
+          searchOperationCount.getAndIncrement();
+          searchOperationTime.getAndAdd(time);
       }
-      opMonitor.reset();
-    }
+      else if (type.equals(OperationType.ABANDON)) {
+          abandonOperationCount.getAndIncrement();
+          abandonOperationTime.getAndAdd(time);
+      }
+      else if (type.equals(OperationType.BIND)) {
+          bindOperationCount.getAndIncrement();
+          bindOperationTime.getAndAdd(time);
+      }
+      else if (type.equals(OperationType.UNBIND)) {
+          unbindOperationCount.getAndIncrement();
+          unbindOperationTime.getAndAdd(time);
+      }
+      else if (type.equals(OperationType.COMPARE)) {
+          compOperationCount.getAndIncrement();
+          compOperationTime.getAndAdd(time);
+      }
+      else if (type.equals(OperationType.DELETE)) {
+          delOperationCount.getAndIncrement();
+          delOperationTime.getAndAdd(time);
+      }
+      else if (type.equals(OperationType.EXTENDED)) {
+          extOperationCount.getAndIncrement();
+          extOperationTime.getAndAdd(time);
+      }
+      else if (type.equals(OperationType.MODIFY)) {
+          modOperationCount.getAndIncrement();
+          modOperationTime.getAndAdd(time);
+      }
+      else if (type.equals(OperationType.MODIFY_DN)) {
+          moddnOperationCount.getAndIncrement();
+          moddnOperationTime.getAndAdd(time);
+      }
   }
 
 }

--
Gitblit v1.10.0