From d13f4bb71bcd9e903cd87e6f2625a9f8dc1b5ed6 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 21 May 2013 12:47:35 +0000
Subject: [PATCH] OPENDJ-902 (CR-1702) Add connectionID to the HTTP access log + move to extended log format OPENDJ-858 (CR-1702) Add stats tracking to HTTP client connections

---
 opends/src/server/org/opends/server/protocols/http/HTTPClientConnection.java |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/opends/src/server/org/opends/server/protocols/http/HTTPClientConnection.java b/opends/src/server/org/opends/server/protocols/http/HTTPClientConnection.java
index c142413..6a4506e 100644
--- a/opends/src/server/org/opends/server/protocols/http/HTTPClientConnection.java
+++ b/opends/src/server/org/opends/server/protocols/http/HTTPClientConnection.java
@@ -186,6 +186,9 @@
   private final HTTPStatistics statTracker;
   private boolean useNanoTime = false;
 
+  /** Total execution time for this request. */
+  private AtomicLong totalProcessingTime = new AtomicLong();
+
   /** The protocol in use for this client connection. */
   private String protocol;
 
@@ -298,6 +301,13 @@
 
   /** {@inheritDoc} */
   @Override
+  public long getTotalProcessingTime()
+  {
+    return totalProcessingTime.get();
+  }
+
+  /** {@inheritDoc} */
+  @Override
   public String getProtocol()
   {
     return protocol;
@@ -370,17 +380,11 @@
   @Override
   public void sendResponse(Operation operation)
   {
+    final long time = getProcessingTime(operation);
+    this.totalProcessingTime.addAndGet(time);
+
     if (keepStats)
     {
-      long time;
-      if (useNanoTime)
-      {
-        time = operation.getProcessingNanoTime();
-      }
-      else
-      {
-        time = operation.getProcessingTime();
-      }
       this.statTracker.updateRequestMonitoringData(getMethod(), time);
       this.statTracker.updateOperationMonitoringData(operation
           .getOperationType(), time);
@@ -407,6 +411,15 @@
     }
   }
 
+  private long getProcessingTime(Operation operation)
+  {
+    if (useNanoTime)
+    {
+      return operation.getProcessingNanoTime();
+    }
+    return operation.getProcessingTime();
+  }
+
   private ProtocolOp toResponseProtocolOp(Operation operation)
   {
     final int resultCode = operation.getResultCode().getIntValue();

--
Gitblit v1.10.0