Package io.netty.channel

Examples of io.netty.channel.Channel


            // set the pipeline factory, which creates the pipeline for each newly created channels
            connectionlessClientBootstrap.handler(pipelineFactory);
            // bind and store channel so we can close it when stopping
            ChannelFuture channelFuture = connectionlessClientBootstrap.bind(new InetSocketAddress(0));
            channelFuture.awaitUninterruptibly();
            Channel channel = channelFuture.channel();
            allChannels.add(channel);
            answer = connectionlessClientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));

            if (LOG.isDebugEnabled()) {
                LOG.debug("Created new UDP client bootstrap connecting to {}:{} with options: {}",
View Full Code Here


            if (channelFuture.cause() != null) {
                cause.initCause(channelFuture.cause());
            }
            throw cause;
        }
        Channel answer = channelFuture.channel();
        // to keep track of all channels in use
        allChannels.add(answer);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating connector to address: {}", configuration.getAddress());
View Full Code Here

    private final class NettyProducerPoolableObjectFactory implements PoolableObjectFactory<Channel> {

        @Override
        public Channel makeObject() throws Exception {
            ChannelFuture channelFuture = openConnection();
            Channel answer = openChannel(channelFuture);
            LOG.trace("Created channel: {}", answer);
            return answer;
        }
View Full Code Here

    // HACK so we send all message from the same thread
    private final Executor singleThread = Executors.newSingleThreadExecutor();

    @Override
    public void send(final LobbySession key, final Message message) {
        final Channel chc = getChannel(key);
        if (chc!=null) {
            if (DEBUG_SEND) {
                logger.log(Level.FINE, "sending "+System.identityHashCode(message)+" "+message);
            }
            // HACK to fix ordering of messages
            singleThread.execute(new Runnable() { @Override public void run() {
                try {
                    chc.writeAndFlush(message);
                }
                catch (Exception ex) {
                    logger.log(Level.WARNING,"Failed to send "+key+" "+message,ex);
                }
            }});
View Full Code Here

        }
    }

    @Override
    public void kick(LobbySession key) {
        Channel chc = getChannel(key);
        if (chc!=null) {
            chc.close();
        }
        else {
            logger.warning("LobbySession: "+key+" NOT FOUND! can not kick");
        }
    }
View Full Code Here

        }
    }

    @Override
    public boolean isConnected(LobbySession key) {
        Channel chc = getChannel(key);
        if (chc!=null) {
            return chc.isOpen();
        }
        else {
            return false;
        }
    }
View Full Code Here

    public void nodeStartsMinConnections() throws InterruptedException, UnknownHostException
    {
        final int MIN_CONNECTIONS = 5;

        ChannelFuture future = mock(ChannelFuture.class);
        Channel c = mock(Channel.class);
        Bootstrap bootstrap = PowerMockito.spy(new Bootstrap());

        doReturn(future).when(c).closeFuture();
        doReturn(true).when(c).isOpen();
        doReturn(future).when(future).await();
View Full Code Here

    public void NodeRespectsMax() throws InterruptedException, UnknownHostException, Exception
    {
        final int MAX_CONNECTIONS = 2;

        ChannelFuture future = mock(ChannelFuture.class);
        Channel c = mock(Channel.class);
        Bootstrap bootstrap = PowerMockito.spy(new Bootstrap());

        doReturn(future).when(c).closeFuture();
        doReturn(true).when(c).isOpen();
        doReturn(future).when(future).await();
View Full Code Here

    public void channelsReturnedCorrectly() throws InterruptedException, UnknownHostException, Exception
    {
        final int MAX_CONNECTIONS = 1;

        ChannelFuture future = mock(ChannelFuture.class);
        Channel c = mock(Channel.class);
        Bootstrap bootstrap = PowerMockito.spy(new Bootstrap());

        doReturn(future).when(c).closeFuture();
        doReturn(true).when(c).isOpen();
        doReturn(future).when(future).await();
View Full Code Here

    @Test
    public void healthCheckChangesState()
        throws InterruptedException, UnknownHostException, Exception
    {
        ChannelFuture future = mock(ChannelFuture.class);
        Channel c = mock(Channel.class);
        Bootstrap bootstrap = PowerMockito.spy(new Bootstrap());

        doReturn(future).when(c).closeFuture();
        doReturn(true).when(c).isOpen();
        doReturn(future).when(future).await();
View Full Code Here

TOP

Related Classes of io.netty.channel.Channel

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.