Search in sources :

Example 1 with InMemoryGrokPatternService

use of org.graylog2.grok.InMemoryGrokPatternService in project graylog2-server by Graylog2.

the class GrokPatternFacadeTest method setUp.

@Before
@SuppressForbidden("Using Executors.newSingleThreadExecutor() is okay in tests")
public void setUp() throws Exception {
    final ClusterEventBus clusterEventBus = new ClusterEventBus("cluster-event-bus", Executors.newSingleThreadExecutor());
    grokPatternService = new InMemoryGrokPatternService(clusterEventBus);
    facade = new GrokPatternFacade(objectMapper, grokPatternService);
}
Also used : InMemoryGrokPatternService(org.graylog2.grok.InMemoryGrokPatternService) ClusterEventBus(org.graylog2.events.ClusterEventBus) Before(org.junit.Before) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Example 2 with InMemoryGrokPatternService

use of org.graylog2.grok.InMemoryGrokPatternService in project graylog2-server by Graylog2.

the class InputFacadeTest method setUp.

@Before
@SuppressForbidden("Using Executors.newSingleThreadExecutor() is okay in tests")
public void setUp() throws Exception {
    final MetricRegistry metricRegistry = new MetricRegistry();
    final ClusterEventBus clusterEventBus = new ClusterEventBus("cluster-event-bus", Executors.newSingleThreadExecutor());
    final GrokPatternService grokPatternService = new InMemoryGrokPatternService(clusterEventBus);
    grokPatternService.save(GrokPattern.create("GREEDY", ".*"));
    final EventBus clusterBus = new EventBus();
    final GrokPatternRegistry grokPatternRegistry = new GrokPatternRegistry(clusterBus, grokPatternService, Executors.newScheduledThreadPool(1));
    final ExtractorFactory extractorFactory = new ExtractorFactory(metricRegistry, grokPatternRegistry, lookupTableService);
    final ConverterFactory converterFactory = new ConverterFactory(lookupTableService);
    inputService = new InputServiceImpl(mongodb.mongoConnection(), extractorFactory, converterFactory, messageInputFactory, clusterEventBus);
    final InputRegistry inputRegistry = new InputRegistry();
    Set<PluginMetaData> pluginMetaData = new HashSet<>();
    Map<String, MessageInput.Factory<? extends MessageInput>> inputFactories = new HashMap<>();
    final FakeHttpMessageInput.Factory fakeHttpMessageInputFactory = mock(FakeHttpMessageInput.Factory.class);
    final FakeHttpMessageInput.Descriptor fakeHttpMessageInputDescriptor = mock(FakeHttpMessageInput.Descriptor.class);
    when(fakeHttpMessageInputFactory.getDescriptor()).thenReturn(fakeHttpMessageInputDescriptor);
    final RawUDPInput.Factory rawUDPInputFactory = mock(RawUDPInput.Factory.class);
    final RawUDPInput.Descriptor rawUDPInputDescriptor = mock(RawUDPInput.Descriptor.class);
    when(rawUDPInputFactory.getDescriptor()).thenReturn(rawUDPInputDescriptor);
    inputFactories.put("org.graylog2.inputs.random.FakeHttpMessageInput", fakeHttpMessageInputFactory);
    inputFactories.put("org.graylog2.inputs.raw.udp.RawUDPInput", rawUDPInputFactory);
    facade = new InputFacade(objectMapper, inputService, inputRegistry, dbLookupTableService, grokPatternService, messageInputFactory, extractorFactory, converterFactory, serverStatus, pluginMetaData, inputFactories);
}
Also used : HashMap(java.util.HashMap) InMemoryGrokPatternService(org.graylog2.grok.InMemoryGrokPatternService) ExtractorFactory(org.graylog2.inputs.extractors.ExtractorFactory) PluginMetaData(org.graylog2.plugin.PluginMetaData) MessageInputFactory(org.graylog2.shared.inputs.MessageInputFactory) ConverterFactory(org.graylog2.inputs.converters.ConverterFactory) ExtractorFactory(org.graylog2.inputs.extractors.ExtractorFactory) FakeHttpMessageInput(org.graylog2.inputs.random.FakeHttpMessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) ConverterFactory(org.graylog2.inputs.converters.ConverterFactory) ClusterEventBus(org.graylog2.events.ClusterEventBus) EventBus(com.google.common.eventbus.EventBus) InputRegistry(org.graylog2.shared.inputs.InputRegistry) InputServiceImpl(org.graylog2.inputs.InputServiceImpl) GrokPatternService(org.graylog2.grok.GrokPatternService) InMemoryGrokPatternService(org.graylog2.grok.InMemoryGrokPatternService) GrokPatternRegistry(org.graylog2.grok.GrokPatternRegistry) HashSet(java.util.HashSet) MetricRegistry(com.codahale.metrics.MetricRegistry) ClusterEventBus(org.graylog2.events.ClusterEventBus) FakeHttpMessageInput(org.graylog2.inputs.random.FakeHttpMessageInput) RawUDPInput(org.graylog2.inputs.raw.udp.RawUDPInput) Before(org.junit.Before) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Example 3 with InMemoryGrokPatternService

use of org.graylog2.grok.InMemoryGrokPatternService in project graylog2-server by Graylog2.

the class GrokResourceTest method setUp.

@Before
@SuppressForbidden("Using Executors.newSingleThreadExecutor() is okay in tests")
public void setUp() {
    paginatedGrokPatternService = mock(PaginatedGrokPatternService.class);
    final ClusterEventBus clusterBus = new ClusterEventBus("cluster-event-bus", Executors.newSingleThreadExecutor());
    grokPatternService = new InMemoryGrokPatternService(clusterBus);
    subscriber = new GrokPatternsChangedEventSubscriber();
    clusterBus.registerClusterEventSubscriber(subscriber);
    grokResource = new PermittedTestResource(grokPatternService, paginatedGrokPatternService);
}
Also used : InMemoryGrokPatternService(org.graylog2.grok.InMemoryGrokPatternService) PaginatedGrokPatternService(org.graylog2.grok.PaginatedGrokPatternService) ClusterEventBus(org.graylog2.events.ClusterEventBus) Before(org.junit.Before) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Example 4 with InMemoryGrokPatternService

use of org.graylog2.grok.InMemoryGrokPatternService 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 5 with InMemoryGrokPatternService

use of org.graylog2.grok.InMemoryGrokPatternService in project graylog2-server by Graylog2.

the class GrokTesterResourceTest method setUp.

@Before
@SuppressForbidden("Using Executors.newSingleThreadExecutor() is okay in tests")
public void setUp() throws Exception {
    final ClusterEventBus clusterEventBus = new ClusterEventBus("cluster-event-bus", Executors.newSingleThreadExecutor());
    final InMemoryGrokPatternService grokPatternService = new InMemoryGrokPatternService(clusterEventBus);
    grokPatternService.save(GrokPattern.create("NUMBER", "[0-9]+"));
    resource = new GrokTesterResource(grokPatternService);
}
Also used : InMemoryGrokPatternService(org.graylog2.grok.InMemoryGrokPatternService) ClusterEventBus(org.graylog2.events.ClusterEventBus) Before(org.junit.Before) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Aggregations

ClusterEventBus (org.graylog2.events.ClusterEventBus)6 SuppressForbidden (org.graylog2.shared.SuppressForbidden)6 InMemoryGrokPatternService (org.graylog2.grok.InMemoryGrokPatternService)5 Before (org.junit.Before)5 EventBus (com.google.common.eventbus.EventBus)2 GrokPatternRegistry (org.graylog2.grok.GrokPatternRegistry)2 GrokPatternService (org.graylog2.grok.GrokPatternService)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ConfigurationException (org.graylog2.ConfigurationException)1 PaginatedGrokPatternService (org.graylog2.grok.PaginatedGrokPatternService)1 InputServiceImpl (org.graylog2.inputs.InputServiceImpl)1 ConverterFactory (org.graylog2.inputs.converters.ConverterFactory)1 ExtractorFactory (org.graylog2.inputs.extractors.ExtractorFactory)1 FakeHttpMessageInput (org.graylog2.inputs.random.FakeHttpMessageInput)1 RawUDPInput (org.graylog2.inputs.raw.udp.RawUDPInput)1 LocalMetricRegistry (org.graylog2.plugin.LocalMetricRegistry)1 PluginMetaData (org.graylog2.plugin.PluginMetaData)1 MessageInput (org.graylog2.plugin.inputs.MessageInput)1