hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ortwin Glück <ortwin.glu...@nose.ch>
Subject Re: ExecutorService, Future, and HttpClient with a MultiThreadedHttpConnectionManager
Date Thu, 31 Mar 2005 14:31:10 GMT
Kent,

Some possibilities:

* You are leaking connections. Make sure to call releaseConnection in a 
finally clause that is executed unconditionally if a method was allocated.

* You are running out of file descriptors. Especially under some Unix 
systems with many short-lived connections this can be a problem.

* The priority queue of the connection manager starves because GC is 
deferred. This can happen when you have a large heap and the pool is 
exhausted before the GC ever kicked in. Some explicit calls to the GC 
may help. Also consider a different GC algorithm.

Ortwin Glück

Kent Gibson wrote:
> Hi-ya All
> 
> I am probably doing something really silly, but I
> decided to use the java 1.5 ExecutorService, the
> Future class and a  HttpClient with a
> MultiThreadedHttpConnectionManager.
> 
> The idea was that I could cancel a thread if I wanted
> to. 
> 
> Anyways it runs ok, but then after x number of
> connects I only get java.net.SocketTimeoutException:
> Read timed out.
> 
> I am always releasing the connection. Maybe I am even
> releasing the connection after it has been released.
> Could this be the problem?
> 
> This is basically the pattern, or perhaps even
> anti-pattern.
> 
> Future futures[] = new Future[CONCURRENT_THREADS];
>  RomeFeedMMThread workers[] = new
> RomeFeedMMThread[CONCURRENT_THREADS];
> ExecutorService tpes =
> Executors.newFixedThreadPool(CONCURRENT_THREADS);
> HttpClient httpClient = new HttpClient(new
> MultiThreadedHttpConnectionManager());
> 
> RomeFeedMMThread get = new RomeFeedMMThread(urls[i],
> inputs[j], httpClient);
> workers[j] = get;
> futures[j] = tpes.submit(workers[j]);
> 
> then in my thread:
> 
> httpClient.executeMethod(get);
> byte[] bytes = get.getResponseBody();
> get.releaseConnection();
> 
> then (still in the same thread)depending on what was
> in the body (the response body is an xml file with
> urls):
> 
> loop :
>   GetMethod get2 = new GetMethod(url.toString());
>   byte[] bytes = get2.getResponseBody();
>   get2.releaseConnection();
> 
> whatcha think?
> 
> regards
> 
> kent
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/ 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
> 

-- 
  _________________________________________________________________
  NOSE applied intelligence ag

  ortwin glück                      [www]      http://www.nose.ch
  software engineer
  hardturmstrasse 171               [pgp id]           0x81CF3416
  8005 zürich                       [office]      +41-1-277 57 35
  switzerland                       [fax]         +41-1-277 57 12

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


Mime
View raw message