use of org.graylog2.indexer.cluster.Node in project graylog2-server by Graylog2.
the class ClusterEventPeriodicalTest method publishClusterEventHandlesAutoValueCorrectly.
@Test
public void publishClusterEventHandlesAutoValueCorrectly() throws Exception {
@SuppressWarnings("deprecation") DBCollection collection = mongoConnection.getDatabase().getCollection(ClusterEventPeriodical.COLLECTION_NAME);
DebugEvent event = DebugEvent.create("Node ID", "Test");
assertThat(collection.count()).isEqualTo(0L);
clusterEventPeriodical.publishClusterEvent(event);
verify(clusterEventBus, never()).post(any());
assertThat(collection.count()).isEqualTo(1L);
DBObject dbObject = collection.findOne();
assertThat((String) dbObject.get("producer")).isEqualTo(nodeId.toString());
assertThat((String) dbObject.get("event_class")).isEqualTo(DebugEvent.class.getCanonicalName());
}
use of org.graylog2.indexer.cluster.Node 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.indexer.cluster.Node 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);
}
use of org.graylog2.indexer.cluster.Node in project graylog2-server by Graylog2.
the class InputEventListenerTest method inputUpdatedDoesNotStartLocalInputOnOtherNode.
@Test
public void inputUpdatedDoesNotStartLocalInputOnOtherNode() 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.RUNNING);
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.inputUpdated(InputUpdated.create(inputId));
verify(inputLauncher, never()).launch(messageInput);
}
use of org.graylog2.indexer.cluster.Node in project graylog2-server by Graylog2.
the class RawMessageTest method minimalEncodeDecode.
@Test
public void minimalEncodeDecode() throws IOException {
final RawMessage rawMessage = new RawMessage("testmessage".getBytes(StandardCharsets.UTF_8));
final File tempFile = File.createTempFile("node", "test");
rawMessage.addSourceNode("inputid", new NodeId(tempFile.getAbsolutePath()));
rawMessage.setCodecName("raw");
rawMessage.setCodecConfig(Configuration.EMPTY_CONFIGURATION);
final byte[] encoded = rawMessage.encode();
final RawMessage decodedMsg = RawMessage.decode(encoded, 1);
assertNotNull(decodedMsg);
assertArrayEquals("testmessage".getBytes(StandardCharsets.UTF_8), decodedMsg.getPayload());
assertEquals("raw", decodedMsg.getCodecName());
}
Aggregations