use of org.graylog2.plugin.inputs.MessageInput 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);
}
use of org.graylog2.plugin.inputs.MessageInput 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.plugin.inputs.MessageInput in project graylog2-server by Graylog2.
the class InputEventListenerTest method inputUpdatedStopsInputIfItIsRunning.
@Test
public void inputUpdatedStopsInputIfItIsRunning() throws Exception {
final String inputId = "input-id";
final Input input = mock(Input.class);
@SuppressWarnings("unchecked") final IOState<MessageInput> inputState = mock(IOState.class);
when(inputService.find(inputId)).thenReturn(input);
when(inputRegistry.getInputState(inputId)).thenReturn(inputState);
listener.inputUpdated(InputUpdated.create(inputId));
verify(inputRegistry, times(1)).remove(inputState);
}
use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.
the class InputEventListenerTest method inputCreatedDoesNotStartLocalInputOnAnyNode.
@Test
public void inputCreatedDoesNotStartLocalInputOnAnyNode() throws Exception {
final String inputId = "input-id";
final Input input = mock(Input.class);
when(inputService.find(inputId)).thenReturn(input);
when(nodeId.toString()).thenReturn("node-id");
when(input.getNodeId()).thenReturn("other-node-id");
when(input.isGlobal()).thenReturn(false);
final MessageInput messageInput = mock(MessageInput.class);
when(inputService.getMessageInput(input)).thenReturn(messageInput);
listener.inputCreated(InputCreated.create(inputId));
verify(inputLauncher, never()).launch(messageInput);
}
use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.
the class InputEventListenerTest method inputUpdatedDoesNotStartLocalInputOnLocalNodeIfItWasNotRunning.
@Test
public void inputUpdatedDoesNotStartLocalInputOnLocalNodeIfItWasNotRunning() throws Exception {
final String inputId = "input-id";
final Input input = mock(Input.class);
@SuppressWarnings("unchecked") final IOState<MessageInput> inputState = mock(IOState.class);
when(inputState.getState()).thenReturn(IOState.Type.STOPPED);
when(inputService.find(inputId)).thenReturn(input);
when(inputRegistry.getInputState(inputId)).thenReturn(inputState);
when(nodeId.toString()).thenReturn("node-id");
when(input.getNodeId()).thenReturn("node-id");
when(input.isGlobal()).thenReturn(false);
final MessageInput messageInput = mock(MessageInput.class);
when(inputService.getMessageInput(input)).thenReturn(messageInput);
listener.inputUpdated(InputUpdated.create(inputId));
verify(inputLauncher, never()).launch(messageInput);
}
Aggregations