Search in sources :

Example 1 with NettyTransportType

use of org.graylog2.inputs.transports.netty.NettyTransportType in project graylog2-server by Graylog2.

the class UdpTransport method getBootstrap.

@VisibleForTesting
Bootstrap getBootstrap(MessageInput input) {
    LOG.debug("Setting UDP receive buffer size to {} bytes", getRecvBufferSize());
    final NettyTransportType transportType = nettyTransportConfiguration.getType();
    eventLoopGroup = eventLoopGroupFactory.create(workerThreads, localRegistry, "workers");
    return new Bootstrap().group(eventLoopGroup).channelFactory(new DatagramChannelFactory(transportType)).option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(getRecvBufferSize())).option(ChannelOption.SO_RCVBUF, getRecvBufferSize()).option(UnixChannelOption.SO_REUSEPORT, true).handler(getChannelInitializer(getChannelHandlers(input))).validate();
}
Also used : FixedRecvByteBufAllocator(io.netty.channel.FixedRecvByteBufAllocator) NettyTransportType(org.graylog2.inputs.transports.netty.NettyTransportType) Bootstrap(io.netty.bootstrap.Bootstrap) DatagramChannelFactory(org.graylog2.inputs.transports.netty.DatagramChannelFactory) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with NettyTransportType

use of org.graylog2.inputs.transports.netty.NettyTransportType in project graylog2-server by Graylog2.

the class UdpTransport method launch.

@Override
public void launch(final MessageInput input) throws MisfireException {
    try {
        bootstrap = getBootstrap(input);
        final NettyTransportType transportType = nettyTransportConfiguration.getType();
        int numChannels = (transportType == NettyTransportType.EPOLL || transportType == NettyTransportType.KQUEUE) ? workerThreads : 1;
        for (int i = 0; i < numChannels; i++) {
            LOG.debug("Starting channel on {}", socketAddress);
            bootstrap.bind(socketAddress).addListener(new InputLaunchListener(channels, input, getRecvBufferSize())).syncUninterruptibly();
        }
    } catch (Exception e) {
        throw new MisfireException(e);
    }
}
Also used : MisfireException(org.graylog2.plugin.inputs.MisfireException) NettyTransportType(org.graylog2.inputs.transports.netty.NettyTransportType) MisfireException(org.graylog2.plugin.inputs.MisfireException)

Aggregations

NettyTransportType (org.graylog2.inputs.transports.netty.NettyTransportType)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Bootstrap (io.netty.bootstrap.Bootstrap)1 FixedRecvByteBufAllocator (io.netty.channel.FixedRecvByteBufAllocator)1 DatagramChannelFactory (org.graylog2.inputs.transports.netty.DatagramChannelFactory)1 MisfireException (org.graylog2.plugin.inputs.MisfireException)1