Examples of ListenerEndpoint


Examples of org.apache.http.nio.reactor.ListenerEndpoint

        handler = new ServerHandler(cfgCtx, params, sslContext != null, metrics, parser, executor);
        final IOEventDispatch ioEventDispatch = getEventDispatch(handler,
                sslContext, sslIOSessionHandler, params);
        state = BaseConstants.STARTED;
       
        ListenerEndpoint endpoint;
        try {
            if (bindAddress == null) {
                endpoint = ioReactor.listen(new InetSocketAddress(port));
            } else {
                endpoint = ioReactor.listen(new InetSocketAddress(
                    InetAddress.getByName(bindAddress), port));
            }
        } catch (IOException e) {
            handleException("Encountered an I/O error: " + e.getMessage(), e);
            return;
        }
       
        // start the IO reactor in a new separate thread
        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    ioReactor.execute(ioEventDispatch);
                } catch (InterruptedIOException ex) {
                    log.fatal("Reactor Interrupted", ex);
                } catch (IOException e) {
                    log.fatal("Encountered an I/O error: " + e.getMessage(), e);
                } catch (Exception e) {
                    log.fatal("Unexpected exception in I/O reactor", e);
                }
                log.info((sslContext == null ? "HTTP" : "HTTPS") + " Listener Shutdown");
            }
        }, "HttpCoreNIOListener");

        t.start();
       
        // Wait for the endpoint to become ready, i.e. for the listener to start accepting
        // requests.
        try {
            endpoint.waitFor();
        } catch (InterruptedException e) {
            log.warn("HttpCoreNIOListener#start() was interrupted");
        }
       
        log.info((sslContext == null ? "HTTP" : "HTTPS") + " Listener started on" +
View Full Code Here

Examples of org.apache.http.nio.reactor.ListenerEndpoint

        this.server.start(serviceHandler);
        this.client.start(clientHandler);
       
       
        ListenerEndpoint endpoint = this.server.getListenerEndpoint();
        endpoint.waitFor();
        InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
       
        for (int i = 0; i < connNo; i++) {
            this.client.openConnection(
                    new InetSocketAddress("localhost", serverAddress.getPort()),
                    null);
View Full Code Here

Examples of org.apache.http.nio.reactor.ListenerEndpoint

                new SimpleEventListener());

        this.server.start(serviceHandler);
        this.client.start(clientHandler);
       
        ListenerEndpoint endpoint = this.server.getListenerEndpoint();
        endpoint.waitFor();
        InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
       
        this.client.openConnection(
                new InetSocketAddress("localhost", serverAddress.getPort()),
                null);
    
View Full Code Here

Examples of org.apache.http.nio.reactor.ListenerEndpoint

        this.server.setExceptionHandler(exceptionHandler);
       
        this.server.start(serviceHandler);
        this.client.start(clientHandler);
       
        ListenerEndpoint endpoint = this.server.getListenerEndpoint();
        endpoint.waitFor();
        InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
       
        this.client.openConnection(
                new InetSocketAddress("localhost", serverAddress.getPort()),
                null);
    
View Full Code Here

Examples of org.apache.http.nio.reactor.ListenerEndpoint

        this.server.setExceptionHandler(exceptionHandler);
       
        this.server.start(serviceHandler);
        this.client.start(clientHandler);
       
        ListenerEndpoint endpoint = this.server.getListenerEndpoint();
        endpoint.waitFor();
        InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
       
        this.client.openConnection(
                new InetSocketAddress("localhost", serverAddress.getPort()),
                null);
    
View Full Code Here

Examples of org.apache.http.nio.reactor.ListenerEndpoint

        tmfactory.init(keystore);
        TrustManager[] trustmanagers = tmfactory.getTrustManagers();
        SSLContext sslcontext = SSLContext.getInstance("TLS");
        sslcontext.init(null, trustmanagers, null);       

        ListenerEndpoint endpoint = this.server.getListenerEndpoint();
        endpoint.waitFor();
        InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
       
        Socket socket = sslcontext.getSocketFactory().createSocket("localhost", serverAddress.getPort());
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        //            123456789012345678901234567890
        writer.write("GET / HTTP/1.1\r\n");
View Full Code Here

Examples of org.apache.http.nio.reactor.ListenerEndpoint

       
        Set<ListenerEndpoint> endpoints = ioreactor.getEndpoints();
        assertNotNull(endpoints);
        assertEquals(0, endpoints.size());
       
        ListenerEndpoint port9998 = ioreactor.listen(new InetSocketAddress(9998));
        port9998.waitFor();

        ListenerEndpoint port9999 = ioreactor.listen(new InetSocketAddress(9999));
        port9999.waitFor();

        endpoints = ioreactor.getEndpoints();
        assertNotNull(endpoints);
        assertEquals(2, endpoints.size());
       
        port9998.close();

        endpoints = ioreactor.getEndpoints();
        assertNotNull(endpoints);
        assertEquals(1, endpoints.size());
       
        ListenerEndpoint endpoint = endpoints.iterator().next();
       
        assertEquals(9999, ((InetSocketAddress) endpoint.getAddress()).getPort());
       
        ioreactor.shutdown(1000);
        t.join(1000);
       
        assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
View Full Code Here

Examples of org.apache.http.nio.reactor.ListenerEndpoint

           
        });
       
        t.start();
       
        ListenerEndpoint endpoint1 = ioreactor.listen(new InetSocketAddress(9999));
        endpoint1.waitFor();

        ListenerEndpoint endpoint2 = ioreactor.listen(new InetSocketAddress(9999));
        endpoint2.waitFor();
        assertNotNull(endpoint2.getException());

        // I/O reactor is now expected to be shutting down
        latch.await(2000, TimeUnit.MILLISECONDS);
        assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
       
View Full Code Here

Examples of org.apache.http.nio.reactor.ListenerEndpoint

           
        });
       
        t.start();
       
        ListenerEndpoint endpoint1 = ioreactor.listen(new InetSocketAddress(9999));
        endpoint1.waitFor();

        ListenerEndpoint endpoint2 = ioreactor.listen(new InetSocketAddress(9999));
        endpoint2.waitFor();
        assertNotNull(endpoint2.getException());

        // Sleep a little to make sure the I/O reactor is not shutting down
        Thread.sleep(500);
       
        assertEquals(IOReactorStatus.ACTIVE, ioreactor.getStatus());
View Full Code Here

Examples of org.apache.http.nio.reactor.ListenerEndpoint

                clientEventListener);

        this.server.start(serviceHandler);
        this.client.start(clientHandler);
       
        ListenerEndpoint endpoint = this.server.getListenerEndpoint();
        endpoint.waitFor();
        InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
       
        for (int i = 0; i < connNo; i++) {
            this.client.openConnection(
                    new InetSocketAddress("localhost", serverAddress.getPort()),
                    null);
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.