Search in sources :

Example 1 with PacketInformationDumper

use of org.graylog2.plugin.inputs.util.PacketInformationDumper 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;
}
Also used : ExceptionEvent(org.jboss.netty.channel.ExceptionEvent) ChannelHandlerContext(org.jboss.netty.channel.ChannelHandlerContext) SimpleChannelHandler(org.jboss.netty.channel.SimpleChannelHandler) ChannelHandler(org.jboss.netty.channel.ChannelHandler) SimpleChannelUpstreamHandler(org.jboss.netty.channel.SimpleChannelUpstreamHandler) PacketInformationDumper(org.graylog2.plugin.inputs.util.PacketInformationDumper) Callable(java.util.concurrent.Callable) MisfireException(org.graylog2.plugin.inputs.MisfireException)

Aggregations

Callable (java.util.concurrent.Callable)1 MisfireException (org.graylog2.plugin.inputs.MisfireException)1 PacketInformationDumper (org.graylog2.plugin.inputs.util.PacketInformationDumper)1 ChannelHandler (org.jboss.netty.channel.ChannelHandler)1 ChannelHandlerContext (org.jboss.netty.channel.ChannelHandlerContext)1 ExceptionEvent (org.jboss.netty.channel.ExceptionEvent)1 SimpleChannelHandler (org.jboss.netty.channel.SimpleChannelHandler)1 SimpleChannelUpstreamHandler (org.jboss.netty.channel.SimpleChannelUpstreamHandler)1