Examples of DefaultConnectingIOReactor


Examples of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor

        preserveServerHeader = NHttpConfiguration.getInstance().isPreserveServerHeader();

        HttpParams params = getClientParameters();
        try {
            String prefix = (sslContext == null ? "http" : "https") + "-Sender I/O dispatcher";
            ioReactor = new DefaultConnectingIOReactor(
                NHttpConfiguration.getInstance().getClientIOWorkers(),
                new NativeThreadFactory(new ThreadGroup(prefix + " thread group"), prefix), params);
            ioReactor.setExceptionHandler(new IOReactorExceptionHandler() {
                public boolean handle(IOException ioException) {
                    log.warn("System may be unstable: IOReactor encountered a checked exception : " +
View Full Code Here

Examples of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor

            return;
        }
        // Create client-side I/O reactor
        final IOEventDispatch ioEventDispatch = new DefaultHttpClientIODispatch(new HttpAsyncRequestExecutor(),
                                                                                new BasicHttpParams());
        ioReactor = new DefaultConnectingIOReactor(config);
       

        // Run the I/O reactor in a separate thread
        Thread t = new Thread(new Runnable() {
View Full Code Here

Examples of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor

        preserveServerHeader = NHttpConfiguration.getInstance().isPreserveServerHeader();

        HttpParams params = getClientParameters();
        try {
            String prefix = (sslContext == null ? "http" : "https") + "-Sender I/O dispatcher";
            ioReactor = new DefaultConnectingIOReactor(
                NHttpConfiguration.getInstance().getClientIOWorkers(),
                new NativeThreadFactory(new ThreadGroup(prefix + " thread group"), prefix), params);
            ioReactor.setExceptionHandler(new IOReactorExceptionHandler() {
                public boolean handle(IOException ioException) {
                    log.warn("System may be unstable: IOReactor encountered a checked exception : " +
View Full Code Here

Examples of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor

            .setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024)
            .setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, false)
            .setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true)
            .setParameter(HttpProtocolParams.USER_AGENT, "Jakarta-HttpComponents-NIO/1.1");

        final ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(2, params);

        BasicHttpProcessor httpproc = new BasicHttpProcessor();
        httpproc.addInterceptor(new RequestContent());
        httpproc.addInterceptor(new RequestTargetHost());
        httpproc.addInterceptor(new RequestConnControl());
        httpproc.addInterceptor(new RequestUserAgent());
        httpproc.addInterceptor(new RequestExpectContinue());
       
        BufferingHttpClientHandler handler = new BufferingHttpClientHandler(
                httpproc,
                new MyHttpRequestExecutionHandler(),
                new DefaultConnectionReuseStrategy(),
                params);

        handler.setEventListener(new EventLogger());
       
        final IOEventDispatch ioEventDispatch = new DefaultClientIOEventDispatch(handler, params);
       
        Thread t = new Thread(new Runnable() {
        
            public void run() {
                try {
                    ioReactor.execute(ioEventDispatch);
                } catch (InterruptedIOException ex) {
                    System.err.println("Interrupted");
                } catch (IOException e) {
                    System.err.println("I/O error: " + e.getMessage());
                }
                System.out.println("Shutdown");
            }
           
        });
        t.start();

        SessionRequest[] reqs = new SessionRequest[3];
        reqs[0] = ioReactor.connect(
                new InetSocketAddress("www.yahoo.com", 80),
                null,
                new HttpHost("www.yahoo.com"),
                null);
        reqs[1] = ioReactor.connect(
                new InetSocketAddress("www.google.com", 80),
                null,
                new HttpHost("www.google.ch"),
                null);
        reqs[2] = ioReactor.connect(
                new InetSocketAddress("www.apache.org", 80),
                null,
                new HttpHost("www.apache.org"),
                null);
       
View Full Code Here

Examples of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor

   
    public TestHttpSSLClient(final HttpParams params) throws Exception {
        super();
        this.params = params;
        this.ioReactor = new DefaultConnectingIOReactor(2, this.params);
       
        ClassLoader cl = getClass().getClassLoader();
        URL url = cl.getResource("test.keystore");
        KeyStore keystore  = KeyStore.getInstance("jks");
        keystore.load(url.openStream(), "nopassword".toCharArray());
View Full Code Here

Examples of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor

            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
            .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
            .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
            .setParameter(CoreProtocolPNames.USER_AGENT, "Jakarta-HttpComponents-NIO/1.1");

        final ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(2, params);

        BasicHttpProcessor httpproc = new BasicHttpProcessor();
        httpproc.addInterceptor(new RequestContent());
        httpproc.addInterceptor(new RequestTargetHost());
        httpproc.addInterceptor(new RequestConnControl());
        httpproc.addInterceptor(new RequestUserAgent());
        httpproc.addInterceptor(new RequestExpectContinue());
       
        // Initialize default SSL context
        SSLContext sslcontext = SSLContext.getInstance("SSL");
        sslcontext.init(null, null, null);
       
        // We are going to use this object to synchronize between the
        // I/O event and main threads
        RequestCount requestCount = new RequestCount(3);
       
        BufferingHttpClientHandler handler = new BufferingHttpClientHandler(
                httpproc,
                new MyHttpRequestExecutionHandler(requestCount),
                new DefaultConnectionReuseStrategy(),
                params);

        handler.setEventListener(new EventLogger());
       
        final IOEventDispatch ioEventDispatch = new SSLClientIOEventDispatch(
                handler,
                sslcontext,
                params);
       
        Thread t = new Thread(new Runnable() {
        
            public void run() {
                try {
                    ioReactor.execute(ioEventDispatch);
                } catch (InterruptedIOException ex) {
                    System.err.println("Interrupted");
                } catch (IOException e) {
                    System.err.println("I/O error: " + e.getMessage());
                }
                System.out.println("Shutdown");
            }
           
        });
        t.start();

        SessionRequest[] reqs = new SessionRequest[requestCount.getValue()];
        reqs[0] = ioReactor.connect(
                new InetSocketAddress("www.netscape.com", 443),
                null,
                new HttpHost("www.netscape.com", 443),
                null);
        reqs[1] = ioReactor.connect(
                new InetSocketAddress("www.verisign.com", 443),
                null,
                new HttpHost("www.verisign.com", 443),
                null);
        reqs[2] = ioReactor.connect(
                new InetSocketAddress("www.yahoo.com", 443),
                null,
                new HttpHost("www.yahoo.com", 443),
                null);
    
        // Block until all connections signal
        // completion of the request execution
        synchronized (requestCount) {
            while (requestCount.getValue() > 0) {
                requestCount.wait();
            }
        }

        System.out.println("Shutting down I/O reactor");
       
        ioReactor.shutdown();
       
        System.out.println("Done");
    }
View Full Code Here

Examples of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor

   
    private volatile IOReactorThread thread;

    public TestHttpClient(final HttpParams params) throws IOException {
        super();
        this.ioReactor = new DefaultConnectingIOReactor(2, params);
        this.params = params;
    }
View Full Code Here

Examples of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor

            .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
            .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
            .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1")
            .setParameter(CoreProtocolPNames.USER_AGENT, "HttpComponents/1.1");

        final ConnectingIOReactor connectingIOReactor = new DefaultConnectingIOReactor(
                1, params);

        final ListeningIOReactor listeningIOReactor = new DefaultListeningIOReactor(
                1, params);
       
        BasicHttpProcessor originServerProc = new BasicHttpProcessor();
        originServerProc.addInterceptor(new RequestContent());
        originServerProc.addInterceptor(new RequestTargetHost());
        originServerProc.addInterceptor(new RequestConnControl());
        originServerProc.addInterceptor(new RequestUserAgent());
        originServerProc.addInterceptor(new RequestExpectContinue());
       
        BasicHttpProcessor clientProxyProcessor = new BasicHttpProcessor();
        clientProxyProcessor.addInterceptor(new ResponseDate());
        clientProxyProcessor.addInterceptor(new ResponseServer());
        clientProxyProcessor.addInterceptor(new ResponseContent());
        clientProxyProcessor.addInterceptor(new ResponseConnControl());
       
        NHttpClientHandler connectingHandler = new ConnectingHandler(
                originServerProc,
                new DefaultConnectionReuseStrategy(),
                params);

        NHttpServiceHandler listeningHandler = new ListeningHandler(
                targetHost,
                connectingIOReactor,
                clientProxyProcessor,
                new DefaultHttpResponseFactory(),
                new DefaultConnectionReuseStrategy(),
                params);
       
        final IOEventDispatch connectingEventDispatch = new DefaultClientIOEventDispatch(
                connectingHandler, params);

        final IOEventDispatch listeningEventDispatch = new DefaultServerIOEventDispatch(
                listeningHandler, params);
       
        Thread t = new Thread(new Runnable() {
           
            public void run() {
                try {
                    connectingIOReactor.execute(connectingEventDispatch);
                } catch (InterruptedIOException ex) {
                    System.err.println("Interrupted");
                } catch (IOException e) {
                    System.err.println("I/O error: " + e.getMessage());
                }
View Full Code Here

Examples of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor

            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
            .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
            .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
            .setParameter(CoreProtocolPNames.USER_AGENT, "HttpComponents/1.1");

        final ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(2, params);

        BasicHttpProcessor httpproc = new BasicHttpProcessor();
        httpproc.addInterceptor(new RequestContent());
        httpproc.addInterceptor(new RequestTargetHost());
        httpproc.addInterceptor(new RequestConnControl());
        httpproc.addInterceptor(new RequestUserAgent());
        httpproc.addInterceptor(new RequestExpectContinue());
       
        // We are going to use this object to synchronize between the
        // I/O event and main threads
        RequestCount requestCount = new RequestCount(3);
       
        BufferingHttpClientHandler handler = new BufferingHttpClientHandler(
                httpproc,
                new MyHttpRequestExecutionHandler(requestCount),
                new DefaultConnectionReuseStrategy(),
                params);

        handler.setEventListener(new EventLogger());
       
        final IOEventDispatch ioEventDispatch = new DefaultClientIOEventDispatch(handler, params);
       
        Thread t = new Thread(new Runnable() {
        
            public void run() {
                try {
                    ioReactor.execute(ioEventDispatch);
                } catch (InterruptedIOException ex) {
                    System.err.println("Interrupted");
                } catch (IOException e) {
                    System.err.println("I/O error: " + e.getMessage());
                }
                System.out.println("Shutdown");
            }
           
        });
        t.start();

        SessionRequest[] reqs = new SessionRequest[requestCount.getValue()];
        reqs[0] = ioReactor.connect(
                new InetSocketAddress("www.yahoo.com", 80),
                null,
                new HttpHost("www.yahoo.com"),
                null);
        reqs[1] = ioReactor.connect(
                new InetSocketAddress("www.google.com", 80),
                null,
                new HttpHost("www.google.ch"),
                null);
        reqs[2] = ioReactor.connect(
                new InetSocketAddress("www.apache.org", 80),
                null,
                new HttpHost("www.apache.org"),
                null);
    
        // Block until all connections signal
        // completion of the request execution
        synchronized (requestCount) {
            while (requestCount.getValue() > 0) {
                requestCount.wait();
            }
        }

        System.out.println("Shutting down I/O reactor");
       
        ioReactor.shutdown();
       
        System.out.println("Done");
    }
View Full Code Here

Examples of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor

                new ResponseConnControl()
        });
    }

    public void initClient() throws Exception {
        this.ioreactor = new DefaultConnectingIOReactor();
        AsyncSchemeRegistry schemeRegistry = new AsyncSchemeRegistry();
        schemeRegistry.register(new AsyncScheme("http", 80, null));
        this.connMgr = new PoolingAsyncClientConnectionManager(this.ioreactor, schemeRegistry);
        this.httpclient = new DefaultHttpAsyncClient(this.connMgr);
        this.httpclient.getParams()
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.