use of io.netty.util.concurrent.DefaultPromise in project bgpcep by opendaylight.
the class FiniteStateMachineTest method setup.
@Before
public void setup() {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open localPrefs = new OpenBuilder().setKeepalive((short) 1).build();
this.serverSession = new DefaultPCEPSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE), this.channel, this.listener, (short) 1, 20, localPrefs);
this.tlsSessionNegotiator = new DefaultPCEPSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE), this.channel, this.listener, (short) 1, 20, localPrefs, new TlsBuilder().build());
}
use of io.netty.util.concurrent.DefaultPromise in project bgpcep by opendaylight.
the class PCEPDispatcherImpl method createServerBootstrap.
synchronized ServerBootstrap createServerBootstrap(final ChannelPipelineInitializer initializer) {
final ServerBootstrap b = new ServerBootstrap();
b.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(final SocketChannel ch) {
initializer.initializeChannel(ch, new DefaultPromise<>(PCEPDispatcherImpl.this.executor));
}
});
b.option(ChannelOption.SO_BACKLOG, SOCKET_BACKLOG_SIZE);
b.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
if (Epoll.isAvailable()) {
b.channel(EpollServerSocketChannel.class);
b.childOption(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED);
} else {
b.channel(NioServerSocketChannel.class);
}
if (!this.keys.isEmpty()) {
if (Epoll.isAvailable()) {
b.option(EpollChannelOption.TCP_MD5SIG, this.keys);
} else {
throw new UnsupportedOperationException(Epoll.unavailabilityCause().getCause());
}
}
// Make sure we are doing round-robin processing
b.childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(1));
if (b.config().group() == null) {
b.group(this.bossGroup, this.workerGroup);
}
return b;
}
use of io.netty.util.concurrent.DefaultPromise in project teiid by teiid.
the class SSLAwareChannelHandler method channelActive.
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
ChannelListener listener = this.listenerFactory.createChannelListener(new ObjectChannelImpl(ctx.channel()));
this.listeners.put(ctx.channel(), listener);
maxChannels = Math.max(maxChannels, this.listeners.size());
SslHandler sslHandler = ctx.pipeline().get(SslHandler.class);
if (sslHandler != null) {
sslHandler.handshakeFuture().addListener(new GenericFutureListener<DefaultPromise<Channel>>() {
@Override
public void operationComplete(DefaultPromise<Channel> future) throws Exception {
onConnection(ctx.channel());
}
});
} else {
onConnection(ctx.channel());
}
}
use of io.netty.util.concurrent.DefaultPromise in project drill by apache.
the class WebSessionResourcesTest method testCloseWithListener.
/**
* Validates successful {@link WebSessionResources#close()} with valid CloseFuture and {@link TestClosedListener}
* getting invoked which is added to the close future.
* @throws Exception
*/
@Test
public void testCloseWithListener() throws Exception {
try {
// Assign latch, executor and closeListener for this test case
GenericFutureListener<Future<Void>> closeListener = new TestClosedListener();
latch = new CountDownLatch(1);
executor = TransportCheck.createEventLoopGroup(1, "Test-Thread").next();
Promise<Void> closeFuture = new DefaultPromise(executor);
// create WebSessionResources with above ChannelPromise to notify listener
webSessionResources = new WebSessionResources(mock(BufferAllocator.class), mock(SocketAddress.class), mock(UserSession.class), closeFuture);
// Add the Test Listener to close future
assertTrue(!listenerComplete);
closeFuture.addListener(closeListener);
// Close the WebSessionResources
webSessionResources.close();
// Verify the states
verify(webSessionResources.getAllocator()).close();
verify(webSessionResources.getSession()).close();
assertTrue(webSessionResources.getCloseFuture() == null);
// Since listener will be invoked so test should not wait forever
latch.await();
assertTrue(listenerComplete);
} catch (Exception e) {
fail();
} finally {
listenerComplete = false;
executor.shutdownGracefully();
}
}
use of io.netty.util.concurrent.DefaultPromise in project drill by apache.
the class WebSessionResourcesTest method testChannelPromiseWithValidExecutor.
/**
* Validates successful {@link WebSessionResources#close()} with valid CloseFuture and other parameters.
* @throws Exception
*/
@Test
public void testChannelPromiseWithValidExecutor() throws Exception {
try {
EventExecutor mockExecutor = mock(EventExecutor.class);
Promise<Void> closeFuture = new DefaultPromise(mockExecutor);
webSessionResources = new WebSessionResources(mock(BufferAllocator.class), mock(SocketAddress.class), mock(UserSession.class), closeFuture);
webSessionResources.close();
verify(webSessionResources.getAllocator()).close();
verify(webSessionResources.getSession()).close();
assertTrue(webSessionResources.getCloseFuture() == null);
assertTrue(!listenerComplete);
} catch (Exception e) {
fail();
}
}
Aggregations