hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r548056 - in /jakarta/httpcomponents/httpcore/trunk: module-main/src/main/java/org/apache/http/impl/ module-nio/src/main/java/org/apache/http/impl/nio/
Date Sun, 17 Jun 2007 16:11:02 GMT
Author: olegk
Date: Sun Jun 17 09:11:01 2007
New Revision: 548056

URL: http://svn.apache.org/viewvc?view=rev&rev=548056
Log:
HTTPCORE-21: Implemented HttpConnectionMetrics for non-blocking HTTP connections. Do not include
1xx responses into the total response count

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java?view=diff&rev=548056&r1=548055&r2=548056
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
Sun Jun 17 09:11:01 2007
@@ -202,7 +202,9 @@
         assertOpen();
         HttpResponse response = readResponseStatusLine();
         readResponseHeaders(response);
-        this.metrics.incrementResponseCount();
+        if (response.getStatusLine().getStatusCode() >= 200) {
+            this.metrics.incrementResponseCount();
+        }
         return response;
     }
     

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java?view=diff&rev=548056&r1=548055&r2=548056
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
Sun Jun 17 09:11:01 2007
@@ -133,6 +133,7 @@
         assertOpen();
         HttpRequest request = receiveRequestLine();
         receiveRequestHeaders(request);
+        this.metrics.incrementRequestCount();
         return request;
     }
     
@@ -183,6 +184,9 @@
         assertOpen();
         sendResponseStatusLine(response);
         sendResponseHeaders(response);
+        if (response.getStatusLine().getStatusCode() >= 200) {
+            this.metrics.incrementResponseCount();
+        }
     }
 
     public void sendResponseEntity(final HttpResponse response) 

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java?view=diff&rev=548056&r1=548055&r2=548056
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
Sun Jun 17 09:11:01 2007
@@ -96,6 +96,7 @@
                     if (this.response.getStatusLine().getStatusCode() >= 200) {
                         HttpEntity entity = prepareDecoder(this.response);
                         this.response.setEntity(entity);
+                        this.metrics.incrementRequestCount();
                     }
                     handler.responseReceived(this);
                     if (this.contentDecoder == null) {
@@ -192,6 +193,7 @@
             prepareEncoder(request);
             this.request = request;
         }
+        this.metrics.incrementRequestCount();
         this.session.setEvent(EventMask.WRITE);
     }
 

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java?view=diff&rev=548056&r1=548055&r2=548056
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
Sun Jun 17 09:11:01 2007
@@ -95,6 +95,7 @@
                         HttpEntity entity = prepareDecoder(this.request);
                         ((HttpEntityEnclosingRequest)this.request).setEntity(entity);
                     }
+                    this.metrics.incrementRequestCount();
                     handler.requestReceived(this);
                     if (this.contentDecoder == null) {
                         // No request entity is expected
@@ -187,11 +188,14 @@
         this.lineBuffer.clear();
         this.outbuf.writeLine(this.lineBuffer);
 
-        if (response.getStatusLine().getStatusCode() >= 200 
-                && response.getEntity() != null) {
-            this.response = response;
-            prepareEncoder(response);
+        if (response.getStatusLine().getStatusCode() >= 200) {
+            this.metrics.incrementRequestCount();
+            if (response.getEntity() != null) {
+                this.response = response;
+                prepareEncoder(response);
+            }
         }
+
         this.session.setEvent(EventMask.WRITE);
     }
 

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java?view=diff&rev=548056&r1=548055&r2=548056
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
Sun Jun 17 09:11:01 2007
@@ -47,6 +47,7 @@
 import org.apache.http.HttpResponse;
 import org.apache.http.entity.BasicHttpEntity;
 import org.apache.http.entity.ContentLengthStrategy;
+import org.apache.http.impl.HttpConnectionMetricsImpl;
 import org.apache.http.impl.entity.LaxContentLengthStrategy;
 import org.apache.http.impl.entity.StrictContentLengthStrategy;
 import org.apache.http.nio.ContentDecoder;
@@ -83,6 +84,7 @@
     protected final SessionInputBuffer inbuf;
     protected final SessionOutputBuffer outbuf;
     protected final CharArrayBuffer lineBuffer;
+    protected final HttpConnectionMetricsImpl metrics;
     
     protected volatile ContentDecoder contentDecoder;
     protected volatile boolean hasBufferedInput;
@@ -90,7 +92,7 @@
     protected volatile boolean hasBufferedOutput;
     protected volatile HttpRequest request;
     protected volatile HttpResponse response;
-    
+
     protected volatile boolean closed;
     
     public NHttpConnectionBase(
@@ -122,6 +124,8 @@
         this.incomingContentStrategy = new LaxContentLengthStrategy();
         this.outgoingContentStrategy = new StrictContentLengthStrategy();
         
+        this.metrics = new HttpConnectionMetricsImpl(null, null);
+        
         this.closed = false;
         this.session.setBufferStatus(this);
         this.session.setEvent(EventMask.READ);
@@ -275,7 +279,7 @@
     }
 
     public HttpConnectionMetrics getMetrics() {
-        return null;
+        return this.metrics;
     }
     
 }



Mime
View raw message