Package org.apache.mina.transport.socket.nio

Examples of org.apache.mina.transport.socket.nio.SocketConnector


        List<IoFilter> filters = configuration.getFilters();
        final int processorCount = Runtime.getRuntime().availableProcessors() + 1;

        IoAcceptor acceptor = new SocketAcceptor(processorCount,
                getCamelContext().getExecutorServiceStrategy().newCachedThreadPool(this, "MinaSocketAcceptor"));
        IoConnector connector = new SocketConnector(processorCount,
                getCamelContext().getExecutorServiceStrategy().newCachedThreadPool(this, "MinaSocketConnector"));
        SocketAddress address = new InetSocketAddress(configuration.getHost(), configuration.getPort());

        // connector config
        SocketConnectorConfig connectorConfig = new SocketConnectorConfig();
View Full Code Here


    public static final <E> E connect(SocketAddress address,
                                      Binding<E,java.nio.ByteBuffer> binding)
    {
        MinaHandler<E> handler = new MinaHandler<E>(binding);
        SocketConnector connector = new SocketConnector();
        IoServiceConfig acceptorConfig = connector.getDefaultConfig();
        acceptorConfig.setThreadModel(ThreadModel.MANUAL);
        SocketSessionConfig scfg = (SocketSessionConfig) acceptorConfig.getSessionConfig();
        scfg.setTcpNoDelay(Boolean.getBoolean("amqj.tcpNoDelay"));
        Integer sendBufferSize = Integer.getInteger("amqj.sendBufferSize");
        if (sendBufferSize != null && sendBufferSize > 0)
        {
            scfg.setSendBufferSize(sendBufferSize);
        }
        Integer receiveBufferSize = Integer.getInteger("amqj.receiveBufferSize");
        if (receiveBufferSize != null && receiveBufferSize > 0)
        {
            scfg.setReceiveBufferSize(receiveBufferSize);
        }
        else if (scfg.getReceiveBufferSize() > MAX_RCVBUF)
        {
            scfg.setReceiveBufferSize(MAX_RCVBUF);
        }
        connector.setWorkerTimeout(0);
        ConnectFuture cf = connector.connect(address, handler);
        cf.join();
        IoSession ssn = cf.getSession();

        // We need to synchronize and wait here because the MINA
        // connect future returns the session prior to the attachment
View Full Code Here

            System.out.println(Main.class.getName() + " <hostname> <port>");
            return;
        }

        // Create TCP/IP connector.
        SocketConnector connector = new SocketConnector();

        // Set connect timeout.
        ((IoConnectorConfig) connector.getDefaultConfig())
                .setConnectTimeout(30);

        // Start communication.
        ConnectFuture cf = connector.connect(new InetSocketAddress(
                args[0], Integer.parseInt(args[1])), new NetCatProtocolHandler());
       
        // Wait for the connection attempt to be finished.
        cf.join();
        cf.getSession();
View Full Code Here

        case TCP:
            _instance = new SocketTransportConnection(new SocketTransportConnection.SocketConnectorFactory()
                    {
                        public IoConnector newSocketConnector()
                        {
                            SocketConnector result;
                            // FIXME - this needs to be sorted to use the new Mina MultiThread SA.
                            if (Boolean.getBoolean("qpidnio"))
                            {
                                _logger.error("Using Qpid NIO - sysproperty 'qpidnio' is set.");
                                // result = new org.apache.qpid.nio.SocketConnector(); // non-blocking connector
                            }
                            // else

                            {
                                _logger.info("Using Mina NIO");
                                result = new SocketConnector(); // non-blocking connector
                            }

                            // Don't have the connector's worker thread wait around for other connections (we only use
                            // one SocketConnector per connection at the moment anyway). This allows short-running
                            // clients (like unit tests) to complete quickly.
                            result.setWorkerTimeout(0);

                            return result;
                        }
                    });
            break;
View Full Code Here

    {
        IoAcceptor acceptor = new SocketAcceptor();
        ( ( SocketAcceptorConfig ) acceptor.getDefaultConfig() ).setReuseAddress( true );
        SocketAddress address = new InetSocketAddress( "localhost", AvailablePortFinder.getNextAvailable() );

        IoConnector connector = new SocketConnector();

        FixedRandomInputStream stream = new FixedRandomInputStream( 4 * 1024 * 1024 );

        SenderHandler sender = new SenderHandler( stream );
        ReceiverHandler receiver = new ReceiverHandler( stream.size );

        acceptor.bind( address, sender );

        synchronized( sender.lock )
        {
            synchronized( receiver.lock )
            {
                connector.connect( address, receiver );

                sender.lock.wait();
                receiver.lock.wait();
            }
        }
View Full Code Here

    }

    private ConnectFuture connectImpl()
    {
        _logger.info("Connecting to cluster peer: " + getDetails());
        SocketConnector ioConnector = new SocketConnector();
        SocketConnectorConfig cfg = (SocketConnectorConfig) ioConnector.getDefaultConfig();

        SocketSessionConfig scfg = (SocketSessionConfig) cfg.getSessionConfig();
        scfg.setTcpNoDelay(true);
        scfg.setSendBufferSize(32768);
        scfg.setReceiveBufferSize(32768);
        InetSocketAddress address = new InetSocketAddress(getHost(), getPort());
        return ioConnector.connect(address, _binding);
    }
View Full Code Here

        // Create TCP/IP acceptor.
        IoAcceptor acceptor = new SocketAcceptor();
        ( ( SocketAcceptorConfig ) acceptor.getDefaultConfig() ).setReuseAddress( true );
       
        // Create TCP/IP connector.
        IoConnector connector = new SocketConnector();

        // Set connect timeout.
        ( ( IoConnectorConfig ) connector.getDefaultConfig()).setConnectTimeout( 30 );
       
        ClientToProxyIoHandler handler = new ClientToProxyIoHandler(
                new ServerToProxyIoHandler(), connector,
                new InetSocketAddress( args[ 1 ],
                        Integer.parseInt( args[ 2 ] ) ) );
View Full Code Here

            System.out.println( Main.class.getName() + " <hostname> <port>" );
            return;
        }

        // Create TCP/IP connector.
        SocketConnector connector = new SocketConnector();

        // Set connect timeout.
        ( ( IoConnectorConfig ) connector.getDefaultConfig()).setConnectTimeout( 30 );
       
        // Start communication.
        connector.connect(
                new InetSocketAddress( args[ 0 ],
                Integer.parseInt( args[ 1 ] ) ),
                new NetCatProtocolHandler() );
    }
View Full Code Here

        {
            values[ i ] = Integer.parseInt( args[ i ] );
        }

        // Set connect timeout.
        IoConnector connector = new SocketConnector();
        ( ( IoConnectorConfig ) connector.getDefaultConfig() ).setConnectTimeout( CONNECT_TIMEOUT );
       
        IoSession session;
        for( ;; )
        {
            try
            {
                ConnectFuture future = connector.connect(
                        new InetSocketAddress( HOSTNAME, PORT ),
                        new ClientSessionHandler( USE_CUSTOM_CODEC, values ) );
               
                future.join();
                session = future.getSession();
View Full Code Here

    {
        IoAcceptor acceptor = new SocketAcceptor();
        ( ( SocketAcceptorConfig ) acceptor.getDefaultConfig() ).setReuseAddress( true );
        SocketAddress address = new InetSocketAddress( "localhost", AvailablePortFinder.getNextAvailable() );

        IoConnector connector = new SocketConnector();
        connector.getDefaultConfig().getFilterChain().addFirst( "threadPool", new ThreadPoolFilter() );
       
        FixedRandomInputStream stream = new FixedRandomInputStream( 4 * 1024 * 1024 );
       
        SenderHandler sender = new SenderHandler( stream );
        ReceiverHandler receiver = new ReceiverHandler( stream.size );
       
        acceptor.bind( address, sender );
       
        synchronized( sender.lock )
        {
            synchronized( receiver.lock )
            {
                connector.connect( address, receiver );
               
                sender.lock.wait();
                receiver.lock.wait();
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.mina.transport.socket.nio.SocketConnector

Copyright © 2018 www.massapicom. 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.