Search in sources :

Example 6 with LocalMetricRegistry

use of org.graylog2.plugin.LocalMetricRegistry 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 7 with LocalMetricRegistry

use of org.graylog2.plugin.LocalMetricRegistry in project graylog2-server by Graylog2.

the class UdpTransportTest method launchTransportForBootStrapTest.

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

        @Override
        protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(MessageInput input) {
            final LinkedHashMap<String, Callable<? extends ChannelHandler>> handlers = new LinkedHashMap<>();
            handlers.put("counter", Callables.returning(channelHandler));
            handlers.putAll(super.getFinalChannelHandlers(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 : MessageInput(org.graylog2.plugin.inputs.MessageInput) ChannelHandler(org.jboss.netty.channel.ChannelHandler) Callable(java.util.concurrent.Callable) LocalMetricRegistry(org.graylog2.plugin.LocalMetricRegistry) LinkedHashMap(java.util.LinkedHashMap)

Example 8 with LocalMetricRegistry

use of org.graylog2.plugin.LocalMetricRegistry in project graylog2-server by Graylog2.

the class GrokExtractorTest method makeExtractor.

@SuppressForbidden("Allow using default thread factory")
private GrokExtractor makeExtractor(String pattern, Map<String, Object> config) {
    config.put("grok_pattern", pattern);
    final ClusterEventBus clusterEventBus = new ClusterEventBus("cluster-event-bus", Executors.newSingleThreadExecutor());
    final EventBus clusterBus = new EventBus();
    final GrokPatternService grokPatternService = new InMemoryGrokPatternService(clusterEventBus);
    try {
        grokPatternService.saveAll(patternSet, DROP_ALL_EXISTING);
    } catch (Exception e) {
        fail("Could not save grok patter: " + e.getMessage());
    }
    final GrokPatternRegistry grokPatternRegistry = new GrokPatternRegistry(clusterBus, grokPatternService, Executors.newScheduledThreadPool(1));
    try {
        return new GrokExtractor(new LocalMetricRegistry(), grokPatternRegistry, "id", "title", 0, Extractor.CursorStrategy.COPY, "message", "message", config, "admin", Lists.newArrayList(), Extractor.ConditionType.NONE, null);
    } catch (Extractor.ReservedFieldException | ConfigurationException e) {
        fail("Test setup is wrong: " + e.getMessage());
        throw new RuntimeException(e);
    }
}
Also used : ConfigurationException(org.graylog2.ConfigurationException) InMemoryGrokPatternService(org.graylog2.grok.InMemoryGrokPatternService) GrokPatternService(org.graylog2.grok.GrokPatternService) InMemoryGrokPatternService(org.graylog2.grok.InMemoryGrokPatternService) GrokPatternRegistry(org.graylog2.grok.GrokPatternRegistry) EventBus(com.google.common.eventbus.EventBus) ClusterEventBus(org.graylog2.events.ClusterEventBus) ClusterEventBus(org.graylog2.events.ClusterEventBus) ConfigurationException(org.graylog2.ConfigurationException) LocalMetricRegistry(org.graylog2.plugin.LocalMetricRegistry) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Example 9 with LocalMetricRegistry

use of org.graylog2.plugin.LocalMetricRegistry 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

LocalMetricRegistry (org.graylog2.plugin.LocalMetricRegistry)9 EventLoopGroupFactory (org.graylog2.inputs.transports.netty.EventLoopGroupFactory)4 ThroughputCounter (org.graylog2.plugin.inputs.util.ThroughputCounter)4 MessageInput (org.graylog2.plugin.inputs.MessageInput)3 Before (org.junit.Before)3 Test (org.junit.Test)3 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)2 LinkedHashMap (java.util.LinkedHashMap)2 Callable (java.util.concurrent.Callable)2 NettyTransportConfiguration (org.graylog2.inputs.transports.NettyTransportConfiguration)2 SuppressForbidden (org.graylog2.shared.SuppressForbidden)2 EventBus (com.google.common.eventbus.EventBus)1 ChannelHandler (io.netty.channel.ChannelHandler)1 LoggingHandler (io.netty.handler.logging.LoggingHandler)1 NetflowV9CodecAggregator (org.graylog.plugins.netflow.codecs.NetflowV9CodecAggregator)1 ConfigurationException (org.graylog2.ConfigurationException)1 ClusterEventBus (org.graylog2.events.ClusterEventBus)1 GrokPatternRegistry (org.graylog2.grok.GrokPatternRegistry)1 GrokPatternService (org.graylog2.grok.GrokPatternService)1 InMemoryGrokPatternService (org.graylog2.grok.InMemoryGrokPatternService)1