Package io.netty.channel

Examples of io.netty.channel.ChannelFuture.await()


        ChannelFuture f = bootstrap.connect();
       
        try
        {
            f.await();
        }
        catch (InterruptedException ex)
        {
            logger.error("Thread interrupted waiting for new connection to be made; {}",
                remoteAddress);
View Full Code Here


        ChannelFuture f = bootstrap.connect();
       
        try
        {
            f.await();
        }
        catch (InterruptedException ex)
        {
            logger.error("Thread interrupted waiting for new connection to be made; {}",
                remoteAddress);
View Full Code Here

    }

    @AfterClass
    public static void stopSimplePushServer() throws InterruptedException {
        final ChannelFuture disconnect = channel.disconnect();
        disconnect.await(1000);
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
        eventExecutorGroup.shutdownGracefully();
    }
View Full Code Here

                    p.addLast(testHandler);
                }
            });

            ChannelFuture cf = b.connect(DESTINATION).channel().closeFuture();
            boolean finished = cf.await(TIMEOUT * 2, TimeUnit.MILLISECONDS);
            finished &= testHandler.latch.await(TIMEOUT * 2, TimeUnit.MILLISECONDS);

            logger.debug("Recorded exceptions: {}", testHandler.exceptions);

            assertProxyHandlers(false);
View Full Code Here

    public void testConnectTimeout(Bootstrap cb) throws Throwable {
        cb.handler(new ChannelHandlerAdapter()).option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 2000);
        ChannelFuture future = cb.connect(BAD_HOST, BAD_PORT);
        try {
            assertThat(future.await(3000), is(true));
        } finally {
            future.channel().close();
        }
    }
View Full Code Here

    public void testConnectCancellation(Bootstrap cb) throws Throwable {
        cb.handler(new ChannelHandlerAdapter()).option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 4000);
        ChannelFuture future = cb.connect(BAD_HOST, BAD_PORT);
        try {
            if (future.await(1000)) {
                if (future.isSuccess()) {
                    fail("A connection attempt to " + BAD_HOST + " must not succeed.");
                } else {
                    throw future.cause();
                }
View Full Code Here

                        protected void initChannel(Channel ch) throws Exception {
                            /* Do nothing */
                        }
                    });
            ChannelFuture future = bootstrap.connect(address);
            assertTrue("Connection should finish, not time out", future.await(200));
        } finally {
            serverGroup.shutdownGracefully(0, 0, TimeUnit.SECONDS).await();
            clientGroup.shutdownGracefully(0, 0, TimeUnit.SECONDS).await();
        }
    }
View Full Code Here

        b.childHandler(new ChannelHandlerAdapter());
        ChannelFuture f1 = b.bind(0);
        f1.sync();

        ChannelFuture f2 = b.bind(0);
        f2.await();

        assertThat(f2.cause(), is(instanceOf(ChannelException.class)));
        assertThat(f2.cause().getMessage().toLowerCase(), containsString("too many channels"));

        final CountDownLatch notified = new CountDownLatch(1);
View Full Code Here

        Bootstrap cb = new Bootstrap();
        cb.channel(OioSocketChannel.class);
        cb.group(g);
        cb.handler(new ChannelHandlerAdapter());
        ChannelFuture f2 = cb.connect(NetUtil.LOCALHOST, ((InetSocketAddress) f1.channel().localAddress()).getPort());
        f2.await();

        assertThat(f2.cause(), is(instanceOf(ChannelException.class)));
        assertThat(f2.cause().getMessage().toLowerCase(), containsString("too many channels"));

        final CountDownLatch notified = new CountDownLatch(1);
View Full Code Here

        // Connect to the server using the asynchronous resolver.
        ChannelFuture connectFuture = bootstrapA.connect(localAddress);

        // Should fail with the UnknownHostException.
        assertThat(connectFuture.await(10000), is(true));
        assertThat(connectFuture.cause(), is(instanceOf(UnknownHostException.class)));
        assertThat(connectFuture.channel().isOpen(), is(false));
    }

    private static final class TestEventLoopGroup extends DefaultEventLoopGroup {
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.