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;
}
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);
}
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");
}
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);
}
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();
}
Aggregations