Re: HttpClient behavior on close with active connections

2016-11-10 Thread Shawn Heisey
On 11/10/2016 3:21 AM, Oleg Kalnichevski wrote:
> On Wed, 2016-11-09 at 13:43 -0700, Shawn Heisey wrote:
>> What happens to a long-lived HTTP connection if another thread calls
>> close() on the HttpClient? Does the connection immediately die and
>> throw an exception, or would the connection finish as expected in its
>> own time? 
> Yes, it does. CloseableHttpClient#close immediately purges the
> internal pool of all connections both active (leased) and inactive
> (kept alive). HC 5.0 will support graceful shutdown option whereby one
> can give connections some grace period to complete ongoing exchanges
> prior to shutting down. 

Thank you!  I prefer to have everything shut down immediately, so this
is good news.  If the exception that happens in the background thread is
different enough from exceptions indicating "real" problems, I will be
able to detect that situation and log a short warning, instead of a full
stacktrace.  I will be on the lookout for this when I've written enough
of the code to test it.

Thanks,
Shawn


-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org



Re: HttpClient behavior on close with active connections

2016-11-10 Thread Oleg Kalnichevski
On Wed, 2016-11-09 at 13:43 -0700, Shawn Heisey wrote:
> I'm using SolrJ 6.2.1 in the program I'm writing, which pulls in
> httpclient/httpmime 4.5.2 and httpcore 4.4.5 as dependencies.
> 
> One of the things that my SolrJ code does takes over an hour to
> complete.  The HTTP connection is kept open for all that time.  I'd like
> to find a way for the Solr server to respond immediately and continue
> the operation in the background, but currently there doesn't seem to be
> a way to do that.
> 
> Now I am attempting to make it possible to gracefully shut down
> everything related to what my code does, turn everything into garbage,
> reload the configuration, and build it all back up.  Therefore I need to
> know how certain things behave at close/shutdown, assuming everything is
> not idle.
> 
> What happens to a long-lived HTTP connection if another thread calls
> close() on the HttpClient?  Does the connection immediately die and
> throw an exception, or would the connection finish as expected in its
> own time? 

Hi Shawn

Yes, it does. CloseableHttpClient#close immediately purges the internal
pool of all connections both active (leased) and inactive (kept alive).
HC 5.0 will support graceful shutdown option whereby one can give
connections some grace period to complete ongoing exchanges prior to
shutting down. 
  
Hope this helps

Oleg

>  If the connection remains open until completion, does the
> close() call return immediately, or wait until that connection ends,
> whether successful or not?  Are all object references (threads in
> particular) properly released and turned into garbage?  I tried to
> follow the code, but got lost quickly.  If it's documented somewhere,
> please point me at that documentation.
> 
> Thanks,
> Shawn
> 
> 
> -
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
> 



-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org



HttpClient behavior on close with active connections

2016-11-09 Thread Shawn Heisey
I'm using SolrJ 6.2.1 in the program I'm writing, which pulls in
httpclient/httpmime 4.5.2 and httpcore 4.4.5 as dependencies.

One of the things that my SolrJ code does takes over an hour to
complete.  The HTTP connection is kept open for all that time.  I'd like
to find a way for the Solr server to respond immediately and continue
the operation in the background, but currently there doesn't seem to be
a way to do that.

Now I am attempting to make it possible to gracefully shut down
everything related to what my code does, turn everything into garbage,
reload the configuration, and build it all back up.  Therefore I need to
know how certain things behave at close/shutdown, assuming everything is
not idle.

What happens to a long-lived HTTP connection if another thread calls
close() on the HttpClient?  Does the connection immediately die and
throw an exception, or would the connection finish as expected in its
own time?  If the connection remains open until completion, does the
close() call return immediately, or wait until that connection ends,
whether successful or not?  Are all object references (threads in
particular) properly released and turned into garbage?  I tried to
follow the code, but got lost quickly.  If it's documented somewhere,
please point me at that documentation.

Thanks,
Shawn


-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org