Search in sources :

Example 1 with InputServiceImpl

use of org.graylog2.inputs.InputServiceImpl 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 2 with InputServiceImpl

use of org.graylog2.inputs.InputServiceImpl in project graylog2-server by Graylog2.

the class InputServiceImplTest method setUp.

@Before
@SuppressForbidden("Executors#newSingleThreadExecutor() is okay for tests")
public void setUp() throws Exception {
    clusterEventBus = new ClusterEventBus("inputs-test", Executors.newSingleThreadExecutor());
    inputService = new InputServiceImpl(mongodb.mongoConnection(), extractorFactory, converterFactory, messageInputFactory, clusterEventBus);
}
Also used : ClusterEventBus(org.graylog2.events.ClusterEventBus) Before(org.junit.Before) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Aggregations

ClusterEventBus (org.graylog2.events.ClusterEventBus)2 SuppressForbidden (org.graylog2.shared.SuppressForbidden)2 Before (org.junit.Before)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 EventBus (com.google.common.eventbus.EventBus)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 GrokPatternRegistry (org.graylog2.grok.GrokPatternRegistry)1 GrokPatternService (org.graylog2.grok.GrokPatternService)1 InMemoryGrokPatternService (org.graylog2.grok.InMemoryGrokPatternService)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 PluginMetaData (org.graylog2.plugin.PluginMetaData)1 MessageInput (org.graylog2.plugin.inputs.MessageInput)1 InputRegistry (org.graylog2.shared.inputs.InputRegistry)1 MessageInputFactory (org.graylog2.shared.inputs.MessageInputFactory)1