ChannelFuture future = b.register(); Throwable cause = future.cause(); if (cause != null) {
ch = (DatagramChannel) b.register().channel(); ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(maxPayloadSize));
/** * {@inheritDoc} * * @throws IllegalStateException If manager is already closed. */ @Override public Channel openChannel() throws IOException, IllegalStateException { assertOpen(); try { return this.bootstrap.clone().register().sync().channel(); } catch (Exception e) { throw new IOException("Could not open channel.", e); } }
/** * {@inheritDoc} * * @throws IllegalStateException If manager is already closed. */ @Override public Channel openChannel() throws IOException, IllegalStateException { assertOpen(); try { return this.bootstrap.clone().register().sync().channel(); } catch (Exception e) { throw new IOException("Could not open channel.", e); } }
/** * {@inheritDoc} * * @throws IllegalStateException If manager is already closed. */ @Override public Channel openChannel() throws IOException, IllegalStateException { assertOpen(); try { return this.bootstrap.clone().register().sync().channel(); } catch (Exception e) { throw new IOException("Could not open channel.", e); } }
/** * {@inheritDoc} * * @throws IllegalStateException If manager is already closed. */ @Override public void openChannel(FutureCallback<Channel> callback) throws IllegalStateException { assertOpen(); ChannelFuture future = this.bootstrap.clone().register(); future.addListener(new NetworkManagerChannelFutureCallback(callback)); }
/** * {@inheritDoc} * * @throws IllegalStateException If manager is already closed. */ @Override public void openChannel(FutureCallback<Channel> callback) throws IllegalStateException { assertOpen(); ChannelFuture future = this.bootstrap.clone().register(); future.addListener(new NetworkManagerChannelFutureCallback(callback)); }
/** * {@inheritDoc} * * @throws IllegalStateException If manager is already closed. */ @Override public void openChannel(FutureCallback<Channel> callback) throws IllegalStateException { assertOpen(); ChannelFuture future = this.bootstrap.clone().register(); future.addListener(new NetworkManagerChannelFutureCallback(callback)); }
public void testMultipleConnect(ServerBootstrap sb, Bootstrap cb) throws Exception { Channel sc = null; Channel cc = null; try { sb.childHandler(new ChannelInboundHandlerAdapter()); sc = sb.bind(NetUtil.LOCALHOST, 0).syncUninterruptibly().channel(); cb.handler(new ChannelInboundHandlerAdapter()); cc = cb.register().syncUninterruptibly().channel(); cc.connect(sc.localAddress()).syncUninterruptibly(); ChannelFuture connectFuture2 = cc.connect(sc.localAddress()).await(); assertTrue(connectFuture2.cause() instanceof AlreadyConnectedException); } finally { if (cc != null) { cc.close(); } if (sc != null) { sc.close(); } } }
public void testLocalAddressAfterConnect(ServerBootstrap sb, Bootstrap cb) throws Throwable { Channel serverChannel = null; Channel clientChannel = null; try { final Promise<InetSocketAddress> localAddressPromise = ImmediateEventExecutor.INSTANCE.newPromise(); serverChannel = sb.childHandler(new ChannelInboundHandlerAdapter() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { localAddressPromise.setSuccess((InetSocketAddress) ctx.channel().localAddress()); } }).bind().syncUninterruptibly().channel(); clientChannel = cb.handler(new ChannelInboundHandlerAdapter()).register().syncUninterruptibly().channel(); assertNull(clientChannel.localAddress()); assertNull(clientChannel.remoteAddress()); clientChannel.connect(serverChannel.localAddress()).syncUninterruptibly().channel(); assertLocalAddress((InetSocketAddress) clientChannel.localAddress()); assertNotNull(clientChannel.remoteAddress()); assertLocalAddress(localAddressPromise.get()); } finally { if (clientChannel != null) { clientChannel.close().syncUninterruptibly(); } if (serverChannel != null) { serverChannel.close().syncUninterruptibly(); } } }
} else { cb.option(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION, true); cc = cb.register().sync().channel();
ChannelFuture future = b.register(); Throwable cause = future.cause(); if (cause != null) {
ch = (DatagramChannel) b.register().channel(); ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(maxPayloadSize));
ch = (DatagramChannel) b.register().channel(); ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(maxPayloadSize));
@Test public void testConnectionTimeoutConfig() throws Exception { final int timeout = 23456; TransportConfiguration transport = new TransportConfiguration(NETTY_CONNECTOR_FACTORY); transport.getParams().put(TransportConstants.NETTY_CONNECT_TIMEOUT, timeout); ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(transport); ClientSessionFactoryImpl factory = (ClientSessionFactoryImpl) locator.createSessionFactory(); NettyConnector connector = (NettyConnector) factory.getConnector(); Bootstrap bootstrap = connector.getBootStrap(); assertEquals(timeout, bootstrap.register().channel().config().getConnectTimeoutMillis()); factory.close(); locator.close(); } }