use of com.splunk.Index in project camel by apache.
the class StreamDataWriter method createSocket.
@Override
protected Socket createSocket(Service service) throws IOException {
Index indexObject = null;
Receiver receiver = null;
Socket socket = null;
if (index != null) {
indexObject = service.getIndexes().get(index);
if (indexObject == null) {
throw new RuntimeCamelException(String.format("cannot find index [%s]", index));
}
socket = indexObject.attach(args);
} else {
receiver = service.getReceiver();
socket = receiver.attach(args);
}
socket.setTcpNoDelay(true);
LOG.trace(String.format("created a socket on %s", socket.getRemoteSocketAddress()));
return socket;
}
use of com.splunk.Index in project camel by apache.
the class SubmitDataWriter method doWrite.
@Override
protected void doWrite(String event) throws IOException {
Index index = getIndex();
if (index != null) {
index.submit(args, event);
} else {
Receiver receiver = endpoint.getService().getReceiver();
receiver.submit(args, event);
}
}
use of com.splunk.Index in project camel by apache.
the class MockConnectionSettings method mockSplunkWriterApi.
private void mockSplunkWriterApi() {
try {
Index index = mock(Index.class);
IndexCollection indexColl = mock(IndexCollection.class);
when(service.getIndexes()).thenReturn(indexColl);
InputCollection inputCollection = mock(InputCollection.class);
when(service.getInputs()).thenReturn(inputCollection);
TcpInput input = mock(TcpInput.class);
when(input.attach()).thenReturn(socket);
when(inputCollection.get(anyString())).thenReturn(input);
when(indexColl.get(anyString())).thenReturn(index);
when(index.attach(isA(Args.class))).thenReturn(socket);
when(socket.getOutputStream()).thenReturn(System.out);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of com.splunk.Index in project drill by apache.
the class SplunkConnectionTest method testGetIndexes.
@Test
public void testGetIndexes() {
SplunkConnection sc = new SplunkConnection(SPLUNK_STORAGE_PLUGIN_CONFIG);
EntityCollection<Index> indexes = sc.getIndexes();
assertEquals(9, indexes.size());
List<String> expectedIndexNames = new ArrayList<>();
expectedIndexNames.add("_audit");
expectedIndexNames.add("_internal");
expectedIndexNames.add("_introspection");
expectedIndexNames.add("_telemetry");
expectedIndexNames.add("_thefishbucket");
expectedIndexNames.add("history");
expectedIndexNames.add("main");
expectedIndexNames.add("splunklogger");
expectedIndexNames.add("summary");
List<String> indexNames = new ArrayList<>();
for (Index index : indexes.values()) {
indexNames.add(index.getName());
}
assertEquals(indexNames, expectedIndexNames);
}
Aggregations