use of org.jboss.netty.channel.SimpleChannelUpstreamHandler in project graylog2-server by Graylog2.
the class NettyTransport method getBaseChannelHandlers.
/**
* Subclasses can override this to add additional ChannelHandlers to the pipeline to support additional features.
* <p/>
* Some common use cases are to add SSL/TLS, connection counters or throttling traffic shapers.
*
* @param input
* @return the list of initial channelhandlers to add to the {@link org.jboss.netty.channel.ChannelPipelineFactory}
*/
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(final MessageInput input) {
LinkedHashMap<String, Callable<? extends ChannelHandler>> handlerList = Maps.newLinkedHashMap();
handlerList.put("exception-logger", new Callable<ChannelHandler>() {
@Override
public ChannelHandler call() throws Exception {
return new SimpleChannelUpstreamHandler() {
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
if ("Connection reset by peer".equals(e.getCause().getMessage())) {
log.trace("{} in Input [{}/{}] (channel {})", e.getCause().getMessage(), input.getName(), input.getId(), e.getChannel());
} else {
log.error("Error in Input [{}/{}] (channel {})", input.getName(), input.getId(), e.getChannel(), e.getCause());
}
super.exceptionCaught(ctx, e);
}
};
}
});
handlerList.put("packet-meta-dumper", new Callable<ChannelHandler>() {
@Override
public ChannelHandler call() throws Exception {
return new PacketInformationDumper(input);
}
});
handlerList.put("traffic-counter", Callables.returning(throughputCounter));
return handlerList;
}
use of org.jboss.netty.channel.SimpleChannelUpstreamHandler in project cdap by caskdata.
the class NettyRouter method startUp.
@Override
protected void startUp() throws ServiceBindException {
ChannelUpstreamHandler connectionTracker = new SimpleChannelUpstreamHandler() {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
channelGroup.add(e.getChannel());
super.channelOpen(ctx, e);
}
};
tokenValidator.startAndWait();
timer = new HashedWheelTimer(new ThreadFactoryBuilder().setDaemon(true).setNameFormat("router-idle-event-generator-timer").build());
bootstrapClient(connectionTracker);
bootstrapServer(connectionTracker);
}
Aggregations