use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project mongo-java-driver by mongodb.
the class NettyStream method adjustTimeout.
private void adjustTimeout(final boolean disable) {
ChannelHandler timeoutHandler = channel.pipeline().get(READ_HANDLER_NAME);
if (timeoutHandler != null) {
final ReadTimeoutHandler readTimeoutHandler = (ReadTimeoutHandler) timeoutHandler;
final ChannelHandlerContext handlerContext = channel.pipeline().context(timeoutHandler);
EventExecutor executor = handlerContext.executor();
if (disable) {
if (executor.inEventLoop()) {
readTimeoutHandler.removeTimeout(handlerContext);
} else {
executor.submit(new Runnable() {
@Override
public void run() {
readTimeoutHandler.removeTimeout(handlerContext);
}
});
}
} else {
if (executor.inEventLoop()) {
readTimeoutHandler.scheduleTimeout(handlerContext);
} else {
executor.submit(new Runnable() {
@Override
public void run() {
readTimeoutHandler.scheduleTimeout(handlerContext);
}
});
}
}
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project camel by apache.
the class LumberjackServer method start.
/**
* Starts the server.
*
* @throws InterruptedException when interrupting while connecting the socket
*/
public void start() throws InterruptedException {
LOG.info("Starting the LUMBERJACK server (host={}, port={}).", host, port);
// Create the group that will listen for incoming connections
bossGroup = new NioEventLoopGroup(1);
// Create the group that will process the connections
workerGroup = new NioEventLoopGroup(WORKER_THREADS);
// Create the executor service that will process the payloads without blocking netty threads
executorService = new DefaultEventExecutorGroup(WORKER_THREADS, threadFactory);
// Create the channel initializer
ChannelHandler initializer = new LumberjackChannelInitializer(sslContext, executorService, messageProcessor);
// Bootstrap the netty server
ServerBootstrap serverBootstrap = //
new ServerBootstrap().group(bossGroup, //
workerGroup).channel(//
NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, //
100).childHandler(//
initializer);
// Connect the socket
channel = serverBootstrap.bind(host, port).sync().channel();
LOG.info("LUMBERJACK server is started (host={}, port={}).", host, port);
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project netty by netty.
the class Http2FrameCodecTest method connectionHandlerShouldBeAddedBeforeFramingHandler.
@Test
public void connectionHandlerShouldBeAddedBeforeFramingHandler() {
Iterator<Entry<String, ChannelHandler>> iter = channel.pipeline().iterator();
while (iter.hasNext()) {
ChannelHandler handler = iter.next().getValue();
if (handler instanceof Http2ConnectionHandler) {
break;
}
}
assertTrue(iter.hasNext());
assertThat(iter.next().getValue(), instanceOf(Http2FrameCodec.class));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project pulsar by yahoo.
the class ServerCnx method handleConnect.
@Override
protected void handleConnect(CommandConnect connect) {
checkArgument(state == State.Start);
if (service.isAuthenticationEnabled()) {
try {
String authMethod = "none";
if (connect.hasAuthMethodName()) {
authMethod = connect.getAuthMethodName();
} else if (connect.hasAuthMethod()) {
// Legacy client is passing enum
authMethod = connect.getAuthMethod().name().substring(10).toLowerCase();
}
String authData = connect.getAuthData().toStringUtf8();
ChannelHandler sslHandler = ctx.channel().pipeline().get(PulsarChannelInitializer.TLS_HANDLER);
SSLSession sslSession = null;
if (sslHandler != null) {
sslSession = ((SslHandler) sslHandler).engine().getSession();
}
authRole = getBrokerService().getAuthenticationService().authenticate(new AuthenticationDataCommand(authData, remoteAddress, sslSession), authMethod);
log.info("[{}] Client successfully authenticated with {} role {}", remoteAddress, authMethod, authRole);
} catch (AuthenticationException e) {
String msg = "Unable to authenticate";
log.warn("[{}] {}: {}", remoteAddress, msg, e.getMessage());
ctx.writeAndFlush(Commands.newError(-1, ServerError.AuthenticationError, msg));
close();
return;
}
}
if (log.isDebugEnabled()) {
log.debug("Received CONNECT from {}", remoteAddress);
}
ctx.writeAndFlush(Commands.newConnected(connect));
state = State.Connected;
remoteEndpointProtocolVersion = connect.getProtocolVersion();
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project riposte by Nike-Inc.
the class HttpChannelInitializerTest method initChannel_does_not_add_debugLoggingHandler_if_debugChannelLifecycleLoggingEnabled_is_false.
@Test
public void initChannel_does_not_add_debugLoggingHandler_if_debugChannelLifecycleLoggingEnabled_is_false() throws SSLException {
// given
HttpChannelInitializer hci = basicHttpChannelInitializer(new JdkSslClientContext(), 42, 100, false, mock(RequestValidator.class), createRequestAndResponseFilterMock());
// when
hci.initChannel(socketChannelMock);
// then
ArgumentCaptor<ChannelHandler> channelHandlerArgumentCaptor = ArgumentCaptor.forClass(ChannelHandler.class);
verify(channelPipelineMock, atLeastOnce()).addLast(anyString(), channelHandlerArgumentCaptor.capture());
List<ChannelHandler> handlers = channelHandlerArgumentCaptor.getAllValues();
assertThat(findChannelHandler(handlers, LoggingHandler.class), nullValue());
}
Aggregations