use of org.graylog2.inputs.transports.netty.EventLoopGroupFactory in project graylog2-server by Graylog2.
the class NetFlowUdpTransportTest method setUp.
@Before
public void setUp() {
final NettyTransportConfiguration nettyTransportConfiguration = new NettyTransportConfiguration("nio", "jdk", 1);
eventLoopGroupFactory = new EventLoopGroupFactory(nettyTransportConfiguration);
eventLoopGroup = new NioEventLoopGroup(1);
transport = new NetFlowUdpTransport(Configuration.EMPTY_CONFIGURATION, eventLoopGroupFactory, nettyTransportConfiguration, new ThroughputCounter(eventLoopGroup), new LocalMetricRegistry());
transport.setMessageAggregator(new NetflowV9CodecAggregator());
}
use of org.graylog2.inputs.transports.netty.EventLoopGroupFactory in project graylog2-server by Graylog2.
the class BeatsTransportTest method customChildChannelHandlersContainBeatsHandler.
@Test
public void customChildChannelHandlersContainBeatsHandler() {
final NettyTransportConfiguration nettyTransportConfiguration = new NettyTransportConfiguration("nio", "jdk", 1);
final EventLoopGroupFactory eventLoopGroupFactory = new EventLoopGroupFactory(nettyTransportConfiguration);
final BeatsTransport transport = new BeatsTransport(Configuration.EMPTY_CONFIGURATION, eventLoopGroup, eventLoopGroupFactory, nettyTransportConfiguration, new ThroughputCounter(eventLoopGroup), new LocalMetricRegistry(), tlsConfiguration);
final MessageInput input = mock(MessageInput.class);
assertThat(transport.getCustomChildChannelHandlers(input)).containsKey("beats");
}
use of org.graylog2.inputs.transports.netty.EventLoopGroupFactory in project graylog2-server by Graylog2.
the class AbstractTcpTransportTest method getChildChannelHandlersFailsIfTempDirIsNoDirectory.
@Test
public void getChildChannelHandlersFailsIfTempDirIsNoDirectory() throws IOException {
final File file = temporaryFolder.newFile();
assumeTrue(file.isFile());
System.setProperty("java.io.tmpdir", file.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: " + file.getAbsolutePath());
transport.getChildChannelHandlers(input);
}
use of org.graylog2.inputs.transports.netty.EventLoopGroupFactory in project graylog2-server by Graylog2.
the class AbstractTcpTransportTest method testTrafficCounter.
@Test
@Ignore("Disabled test due to being unreliable. For details see https://github.com/Graylog2/graylog2-server/issues/4702.")
public void testTrafficCounter() throws Exception {
final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "127.0.0.1", "port", 0));
final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, eventLoopGroup, eventLoopGroupFactory, nettyTransportConfiguration, tlsConfiguration) {
};
transport.launch(input);
await().atMost(5, TimeUnit.SECONDS).until(() -> transport.getLocalAddress() != null);
final InetSocketAddress localAddress = (InetSocketAddress) transport.getLocalAddress();
assertThat(localAddress).isNotNull();
final ChannelFuture channelFuture = clientChannel(localAddress.getHostString(), localAddress.getPort());
channelFuture.channel().writeAndFlush(Unpooled.copiedBuffer(new byte[1024])).syncUninterruptibly();
channelFuture.channel().writeAndFlush(Unpooled.copiedBuffer(new byte[1024])).addListener(ChannelFutureListener.CLOSE).syncUninterruptibly();
// Wait 1s so that the cumulative throughput can be calculated
Thread.sleep(1000L);
assertThat(throughputCounter.gauges().get(ThroughputCounter.READ_BYTES_TOTAL).getValue()).isEqualTo(2048L);
assertThat(throughputCounter.gauges().get(ThroughputCounter.READ_BYTES_1_SEC).getValue()).isEqualTo(2048L);
}
use of org.graylog2.inputs.transports.netty.EventLoopGroupFactory in project graylog2-server by Graylog2.
the class UdpTransportTest method setUp.
@Before
@SuppressForbidden("Executors#newSingleThreadExecutor() is okay for tests")
public void setUp() throws Exception {
eventLoopGroupFactory = new EventLoopGroupFactory(nettyTransportConfiguration);
localMetricRegistry = new LocalMetricRegistry();
eventLoopGroup = eventLoopGroupFactory.create(1, localMetricRegistry, "test");
throughputCounter = new ThroughputCounter(eventLoopGroup);
udpTransport = new UdpTransport(CONFIGURATION, eventLoopGroupFactory, nettyTransportConfiguration, throughputCounter, localMetricRegistry);
}
Aggregations