You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2011/04/12 01:08:05 UTC

[jira] [Created] (HTTPCORE-253) getMetrics() does not work for HEAD or other early release methods

getMetrics() does not work for HEAD or other early release methods
------------------------------------------------------------------

                 Key: HTTPCORE-253
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-253
             Project: HttpComponents HttpCore
          Issue Type: Bug
            Reporter: Sebb


The following code works fine for GET:

           HttpResponse httpResponse =
httpClient.execute(httpRequest, localContext);
           HttpConnection conn = (HttpConnection)
localContext.getAttribute(ExecutionContext.HTTP_CONNECTION);
           HttpConnectionMetrics metrics = conn.getMetrics();

but fails on the getMetrics() call when the request is HEAD:

       org.apache.http.impl.conn.ConnectionShutdownException
       at org.apache.http.impl.conn.AbstractClientConnAdapter.assertValid(AbstractClientConnAdapter.java:154)
       at org.apache.http.impl.conn.AbstractClientConnAdapter.getMetrics(AbstractClientConnAdapter.java:190)

This is because the getMetrics() method calls assertValid() which checks that the connection has not been released, and the HEAD request is released as soon as it completes, before returning to the caller.

Possible solutions:
- don't call assertValid() in getMetrics()
- store a pointer to the metrics in the local context

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Moved] (HTTPCLIENT-1081) getMetrics() does not work for HEAD or other early release methods

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1081?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski moved HTTPCORE-253 to HTTPCLIENT-1081:
--------------------------------------------------------

    Fix Version/s:     (was: 4.2)
                   4.2 Final
         Workflow: Default workflow, editable Closed status  (was: jira)
              Key: HTTPCLIENT-1081  (was: HTTPCORE-253)
          Project: HttpComponents HttpClient  (was: HttpComponents HttpCore)

> getMetrics() does not work for HEAD or other early release methods
> ------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1081
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1081
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 4.2 Final
>
>
> The following code works fine for GET:
>            HttpResponse httpResponse =
> httpClient.execute(httpRequest, localContext);
>            HttpConnection conn = (HttpConnection)
> localContext.getAttribute(ExecutionContext.HTTP_CONNECTION);
>            HttpConnectionMetrics metrics = conn.getMetrics();
> but fails on the getMetrics() call when the request is HEAD:
>        org.apache.http.impl.conn.ConnectionShutdownException
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.assertValid(AbstractClientConnAdapter.java:154)
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.getMetrics(AbstractClientConnAdapter.java:190)
> This is because the getMetrics() method calls assertValid() which checks that the connection has not been released, and the HEAD request is released as soon as it completes, before returning to the caller.
> Possible solutions:
> - don't call assertValid() in getMetrics()
> - store a pointer to the metrics in the local context

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Commented] (HTTPCORE-253) getMetrics() does not work for HEAD or other early release methods

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019293#comment-13019293 ] 

Oleg Kalnichevski commented on HTTPCORE-253:
--------------------------------------------

> In which case, maybe we should consider moving the metrics to the request, rather than the connection?

Connection metrics were intended primarily for custom connection keep-alive strategies so one could choose to close a connection after a certain number of messages or bytes of data transferred over that connection.

Actually I do not think there is anything in HttpCore that needs fixing as far as the connection metrics are concerned. We just need to think how to maintain counts of message / bytes transferred on the HttpClient level given that connections can be released to the pool early. One possibility I was thinking about was to make managed connections (AbstractClientConnAdaptor and its super classes) retain a deep copy of HttpConnectionMetrics after releasing the underlying connection back to the manager. This would enable the users to read the metrics off the connection object obtained from the local execution context.

Anyway, feel free to propose a solution that makes most sense from your perspective and with your JMeter hat on.

Oleg

> getMetrics() does not work for HEAD or other early release methods
> ------------------------------------------------------------------
>
>                 Key: HTTPCORE-253
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-253
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 4.2
>
>
> The following code works fine for GET:
>            HttpResponse httpResponse =
> httpClient.execute(httpRequest, localContext);
>            HttpConnection conn = (HttpConnection)
> localContext.getAttribute(ExecutionContext.HTTP_CONNECTION);
>            HttpConnectionMetrics metrics = conn.getMetrics();
> but fails on the getMetrics() call when the request is HEAD:
>        org.apache.http.impl.conn.ConnectionShutdownException
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.assertValid(AbstractClientConnAdapter.java:154)
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.getMetrics(AbstractClientConnAdapter.java:190)
> This is because the getMetrics() method calls assertValid() which checks that the connection has not been released, and the HEAD request is released as soon as it completes, before returning to the caller.
> Possible solutions:
> - don't call assertValid() in getMetrics()
> - store a pointer to the metrics in the local context

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Updated] (HTTPCORE-253) getMetrics() does not work for HEAD or other early release methods

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-253?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCORE-253:
---------------------------------------

    Fix Version/s: 4.2

It may be not enough to store a reference to the metrics as the HTTP connection can be immediately leased by another thread of execution, which may alter the metrics. I suspect we will have to create a deep copy of the metrics object if you want to preserve the exact state of the metrics object as it was at the end of the request execution.

Oleg  

> getMetrics() does not work for HEAD or other early release methods
> ------------------------------------------------------------------
>
>                 Key: HTTPCORE-253
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-253
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 4.2
>
>
> The following code works fine for GET:
>            HttpResponse httpResponse =
> httpClient.execute(httpRequest, localContext);
>            HttpConnection conn = (HttpConnection)
> localContext.getAttribute(ExecutionContext.HTTP_CONNECTION);
>            HttpConnectionMetrics metrics = conn.getMetrics();
> but fails on the getMetrics() call when the request is HEAD:
>        org.apache.http.impl.conn.ConnectionShutdownException
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.assertValid(AbstractClientConnAdapter.java:154)
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.getMetrics(AbstractClientConnAdapter.java:190)
> This is because the getMetrics() method calls assertValid() which checks that the connection has not been released, and the HEAD request is released as soon as it completes, before returning to the caller.
> Possible solutions:
> - don't call assertValid() in getMetrics()
> - store a pointer to the metrics in the local context

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Updated] (HTTPCLIENT-1081) getMetrics() does not work for HEAD or other early release methods

Posted by "Oleg Kalnichevski (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1081?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCLIENT-1081:
------------------------------------------

    Fix Version/s:     (was: 4.2 Alpha2)
                   4.2 Final
    
> getMetrics() does not work for HEAD or other early release methods
> ------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1081
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1081
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 4.2 Final
>
>
> The following code works fine for GET:
>            HttpResponse httpResponse =
> httpClient.execute(httpRequest, localContext);
>            HttpConnection conn = (HttpConnection)
> localContext.getAttribute(ExecutionContext.HTTP_CONNECTION);
>            HttpConnectionMetrics metrics = conn.getMetrics();
> but fails on the getMetrics() call when the request is HEAD:
>        org.apache.http.impl.conn.ConnectionShutdownException
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.assertValid(AbstractClientConnAdapter.java:154)
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.getMetrics(AbstractClientConnAdapter.java:190)
> This is because the getMetrics() method calls assertValid() which checks that the connection has not been released, and the HEAD request is released as soon as it completes, before returning to the caller.
> Possible solutions:
> - don't call assertValid() in getMetrics()
> - store a pointer to the metrics in the local context

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Issue Comment Edited] (HTTPCORE-253) getMetrics() does not work for HEAD or other early release methods

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13018787#comment-13018787 ] 

Sebb edited comment on HTTPCORE-253 at 4/12/11 10:26 AM:
---------------------------------------------------------

In which case, maybe we should consider moving the metrics to the request, rather than the connection? Or have metrics objects for both?

JMeter needs metrics for the individual method invocations, but there's probably a use case for connection-based metrics too and/or httpclient metrics.

In the case of JMeter, httpclient metrics might be an alternative as one could just look at the differences.
JMeter deliberately does not share connections between threads, so the re-lease problem does not arise, but in general of course that needs to be fixed.

      was (Author: sebb@apache.org):
    In which case, maybe we should consider moving the metrics to the method, rather than the connection? Or have metrics objects for both?

JMeter needs metrics for the individual method invocations, but there's probably a use case for connection-based metrics too and/or httpclient metrics.

In the case of JMeter, httpclient metrics might be an alternative as one could just look at the differences.
JMeter deliberately does not share connections between threads, so the re-lease problem does not arise, but in general of course that needs to be fixed.
  
> getMetrics() does not work for HEAD or other early release methods
> ------------------------------------------------------------------
>
>                 Key: HTTPCORE-253
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-253
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 4.2
>
>
> The following code works fine for GET:
>            HttpResponse httpResponse =
> httpClient.execute(httpRequest, localContext);
>            HttpConnection conn = (HttpConnection)
> localContext.getAttribute(ExecutionContext.HTTP_CONNECTION);
>            HttpConnectionMetrics metrics = conn.getMetrics();
> but fails on the getMetrics() call when the request is HEAD:
>        org.apache.http.impl.conn.ConnectionShutdownException
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.assertValid(AbstractClientConnAdapter.java:154)
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.getMetrics(AbstractClientConnAdapter.java:190)
> This is because the getMetrics() method calls assertValid() which checks that the connection has not been released, and the HEAD request is released as soon as it completes, before returning to the caller.
> Possible solutions:
> - don't call assertValid() in getMetrics()
> - store a pointer to the metrics in the local context

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Commented] (HTTPCORE-253) getMetrics() does not work for HEAD or other early release methods

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13018787#comment-13018787 ] 

Sebb commented on HTTPCORE-253:
-------------------------------

In which case, maybe we should consider moving the metrics to the method, rather than the connection? Or have metrics objects for both?

JMeter needs metrics for the individual method invocations, but there's probably a use case for connection-based metrics too and/or httpclient metrics.

In the case of JMeter, httpclient metrics might be an alternative as one could just look at the differences.
JMeter deliberately does not share connections between threads, so the re-lease problem does not arise, but in general of course that needs to be fixed.

> getMetrics() does not work for HEAD or other early release methods
> ------------------------------------------------------------------
>
>                 Key: HTTPCORE-253
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-253
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 4.2
>
>
> The following code works fine for GET:
>            HttpResponse httpResponse =
> httpClient.execute(httpRequest, localContext);
>            HttpConnection conn = (HttpConnection)
> localContext.getAttribute(ExecutionContext.HTTP_CONNECTION);
>            HttpConnectionMetrics metrics = conn.getMetrics();
> but fails on the getMetrics() call when the request is HEAD:
>        org.apache.http.impl.conn.ConnectionShutdownException
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.assertValid(AbstractClientConnAdapter.java:154)
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.getMetrics(AbstractClientConnAdapter.java:190)
> This is because the getMetrics() method calls assertValid() which checks that the connection has not been released, and the HEAD request is released as soon as it completes, before returning to the caller.
> Possible solutions:
> - don't call assertValid() in getMetrics()
> - store a pointer to the metrics in the local context

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org