Search in sources :

Example 6 with EventLoopGroupFactory

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

the class UdpTransportTest method launchTransportForBootStrapTest.

private UdpTransport launchTransportForBootStrapTest(final ChannelInboundHandler channelHandler) throws MisfireException {
    final UdpTransport transport = new UdpTransport(CONFIGURATION, eventLoopGroupFactory, nettyTransportConfiguration, throughputCounter, new LocalMetricRegistry()) {

        @Override
        protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getChannelHandlers(MessageInput input) {
            final LinkedHashMap<String, Callable<? extends ChannelHandler>> handlers = new LinkedHashMap<>();
            handlers.put("logging", () -> new LoggingHandler(LogLevel.INFO));
            handlers.put("counter", () -> channelHandler);
            handlers.putAll(super.getChannelHandlers(input));
            return handlers;
        }
    };
    final MessageInput messageInput = mock(MessageInput.class);
    when(messageInput.getId()).thenReturn("TEST");
    when(messageInput.getName()).thenReturn("TEST");
    transport.launch(messageInput);
    return transport;
}
Also used : LoggingHandler(io.netty.handler.logging.LoggingHandler) MessageInput(org.graylog2.plugin.inputs.MessageInput) ChannelHandler(io.netty.channel.ChannelHandler) Callable(java.util.concurrent.Callable) LocalMetricRegistry(org.graylog2.plugin.LocalMetricRegistry) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with EventLoopGroupFactory

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

the class UdpTransportTest method receiveBufferSizeIsNotLimited.

@Test
public void receiveBufferSizeIsNotLimited() {
    final int recvBufferSize = Ints.saturatedCast(Size.megabytes(1L).toBytes());
    ImmutableMap<String, Object> source = ImmutableMap.of(NettyTransport.CK_BIND_ADDRESS, BIND_ADDRESS, NettyTransport.CK_PORT, PORT, NettyTransport.CK_RECV_BUFFER_SIZE, recvBufferSize);
    Configuration config = new Configuration(source);
    UdpTransport udpTransport = new UdpTransport(config, eventLoopGroupFactory, nettyTransportConfiguration, throughputCounter, new LocalMetricRegistry());
    assertThat(udpTransport.getBootstrap(mock(MessageInput.class)).config().options().get(ChannelOption.SO_RCVBUF)).isEqualTo(recvBufferSize);
}
Also used : Configuration(org.graylog2.plugin.configuration.Configuration) LocalMetricRegistry(org.graylog2.plugin.LocalMetricRegistry) Test(org.junit.Test)

Example 8 with EventLoopGroupFactory

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

the class AbstractTcpTransportTest method getChildChannelHandlersGeneratesSelfSignedCertificates.

@Test
public void getChildChannelHandlersGeneratesSelfSignedCertificates() {
    final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
    final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, eventLoopGroup, eventLoopGroupFactory, nettyTransportConfiguration, tlsConfiguration) {
    };
    final MessageInput input = mock(MessageInput.class);
    assertThat(transport.getChildChannelHandlers(input)).containsKey("tls");
}
Also used : Configuration(org.graylog2.plugin.configuration.Configuration) TLSProtocolsConfiguration(org.graylog2.configuration.TLSProtocolsConfiguration) NettyTransportConfiguration(org.graylog2.inputs.transports.NettyTransportConfiguration) MessageInput(org.graylog2.plugin.inputs.MessageInput) Test(org.junit.Test)

Example 9 with EventLoopGroupFactory

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

the class AbstractTcpTransportTest method getChildChannelHandlersFailsIfTempDirIsNotWritable.

@Test
public void getChildChannelHandlersFailsIfTempDirIsNotWritable() throws IOException {
    final File tmpDir = temporaryFolder.newFolder();
    assumeTrue(tmpDir.setWritable(false));
    assumeFalse(tmpDir.canWrite());
    System.setProperty("java.io.tmpdir", tmpDir.getAbsolutePath());
    final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
    final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, eventLoopGroup, eventLoopGroupFactory, nettyTransportConfiguration, tlsConfiguration) {
    };
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("Couldn't write to temporary directory: " + tmpDir.getAbsolutePath());
    transport.getChildChannelHandlers(input);
}
Also used : Configuration(org.graylog2.plugin.configuration.Configuration) TLSProtocolsConfiguration(org.graylog2.configuration.TLSProtocolsConfiguration) NettyTransportConfiguration(org.graylog2.inputs.transports.NettyTransportConfiguration) File(java.io.File) Test(org.junit.Test)

Example 10 with EventLoopGroupFactory

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

the class AbstractTcpTransportTest method setUp.

@Before
public void setUp() {
    eventLoopGroup = new NioEventLoopGroup();
    eventLoopGroupFactory = new EventLoopGroupFactory(nettyTransportConfiguration);
    throughputCounter = new ThroughputCounter(eventLoopGroup);
    localRegistry = new LocalMetricRegistry();
}
Also used : ThroughputCounter(org.graylog2.plugin.inputs.util.ThroughputCounter) EventLoopGroupFactory(org.graylog2.inputs.transports.netty.EventLoopGroupFactory) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) LocalMetricRegistry(org.graylog2.plugin.LocalMetricRegistry) Before(org.junit.Before)

Aggregations

NettyTransportConfiguration (org.graylog2.inputs.transports.NettyTransportConfiguration)8 Test (org.junit.Test)8 Configuration (org.graylog2.plugin.configuration.Configuration)7 TLSProtocolsConfiguration (org.graylog2.configuration.TLSProtocolsConfiguration)6 LocalMetricRegistry (org.graylog2.plugin.LocalMetricRegistry)6 EventLoopGroupFactory (org.graylog2.inputs.transports.netty.EventLoopGroupFactory)4 ThroughputCounter (org.graylog2.plugin.inputs.util.ThroughputCounter)4 File (java.io.File)3 MessageInput (org.graylog2.plugin.inputs.MessageInput)3 Before (org.junit.Before)3 ChannelFuture (io.netty.channel.ChannelFuture)2 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)2 InetSocketAddress (java.net.InetSocketAddress)2 Ignore (org.junit.Ignore)2 ChannelHandler (io.netty.channel.ChannelHandler)1 LoggingHandler (io.netty.handler.logging.LoggingHandler)1 LinkedHashMap (java.util.LinkedHashMap)1 Callable (java.util.concurrent.Callable)1 NetflowV9CodecAggregator (org.graylog.plugins.netflow.codecs.NetflowV9CodecAggregator)1 SuppressForbidden (org.graylog2.shared.SuppressForbidden)1