Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F03972A49 for ; Sat, 23 Apr 2011 09:16:45 +0000 (UTC) Received: (qmail 79316 invoked by uid 500); 23 Apr 2011 09:16:45 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 79254 invoked by uid 500); 23 Apr 2011 09:16:44 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 79243 invoked by uid 99); 23 Apr 2011 09:16:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 Apr 2011 09:16:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 Apr 2011 09:16:43 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id B6B7AAED0D for ; Sat, 23 Apr 2011 09:16:05 +0000 (UTC) Date: Sat, 23 Apr 2011 09:16:05 +0000 (UTC) From: "Oleg Kalnichevski (JIRA)" To: dev@hc.apache.org Message-ID: <1448566481.78103.1303550165745.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <2040046833.77447.1303510926338.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (HTTPASYNC-3) I/O reactor has been shut down (Example code is attached) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HTTPASYNC-3?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Oleg Kalnichevski updated HTTPASYNC-3: -------------------------------------- Priority: Major (was: Critical) Fix Version/s: (was: 4.0-alpha2) I cannot reproduce the problem. Code does not compile because HttpCallback class is not defined. Oleg > I/O reactor has been shut down (Example code is attached) > --------------------------------------------------------- > > Key: HTTPASYNC-3 > URL: https://issues.apache.org/jira/browse/HTTPASYNC-3 > Project: HttpComponents HttpAsyncClient > Issue Type: Bug > Affects Versions: 4.0-alpha1 > Reporter: Lokesh > Original Estimate: 1m > Remaining Estimate: 1m > > here is an example code to use the HTTP AsyncClient and seeing an exception. Please also let me know how to deal with this issue, > /* > * To change this template, choose Tools | Templates > * and open the template in the editor. > */ > package httpanalysis.apache; > import java.util.concurrent.CountDownLatch; > import java.util.concurrent.Future; > import java.util.concurrent.TimeUnit; > import java.util.logging.Level; > import java.util.logging.Logger; > import org.apache.http.HttpHost; > import org.apache.http.HttpResponse; > import org.apache.http.client.methods.HttpGet; > import org.apache.http.impl.nio.client.DefaultHttpAsyncClient; > import org.apache.http.impl.nio.conn.PoolingClientConnectionManager; > import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor; > import org.apache.http.nio.client.HttpAsyncClient; > import org.apache.http.nio.conn.scheme.Scheme; > import org.apache.http.nio.conn.scheme.SchemeRegistry; > import org.apache.http.nio.reactor.ConnectingIOReactor; > import org.apache.http.nio.reactor.IOReactorException; > import org.apache.http.params.BasicHttpParams; > import org.apache.http.params.CoreConnectionPNames; > /** > * > * @author lokesh > */ > public class HttpAnalysis { > PoolingClientConnectionManager poolManager; > HttpAsyncClient httpclient = null; > private PoolingClientConnectionManager sessionManager; > /** > * @param args the command line arguments > */ > public static void main(String[] args) { > HttpAnalysis analysis = new HttpAnalysis(); > analysis.process(); > } > public HttpAnalysis() { > try { > BasicHttpParams basicHttpParams = new BasicHttpParams(); > basicHttpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 1); > basicHttpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, 2); > basicHttpParams.setParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 2 * 1024); > basicHttpParams.setParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false); > basicHttpParams.setParameter(CoreConnectionPNames.SO_REUSEADDR, false); > > > > > ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(2, basicHttpParams); > SchemeRegistry schemeRegistry = new SchemeRegistry(); > schemeRegistry.register(new Scheme("http", 80, null)); > this.sessionManager = new PoolingClientConnectionManager(ioReactor, schemeRegistry, 5, TimeUnit.MINUTES); > sessionManager.setTotalMax(50); > sessionManager.setDefaultMaxPerHost(25); > > this.httpclient = new DefaultHttpAsyncClient(ioReactor, sessionManager,basicHttpParams); > } catch (IOReactorException ex) { > Logger.getLogger(HttpAnalysis.class.getName()).log(Level.SEVERE, null, ex); > } > } > private void process() { > try { > int numRequests = 10000; > httpclient.start(); > long startTime = System.currentTimeMillis(); > final CountDownLatch countDownLatch = new CountDownLatch(numRequests); > for (int i = 0; i < numRequests; i++) { > HttpGet request = new HttpGet("http://hc.apache.org/"); > Future future = httpclient.execute(request, new HttpCallback(this, countDownLatch)); > if(future == null){ > countDownLatch.countDown(); > } > System.out.println("Request number = " + i); > //sessionManager.closeExpiredConnections(); > } > countDownLatch.await(); > System.out.println((System.currentTimeMillis() - startTime)); > System.exit(1); > } catch (Exception ex) { > Logger.getLogger(HttpAnalysis.class.getName()).log(Level.SEVERE, null, ex); > } > } > } -- 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