Search in sources :

Example 1 with Index

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;
}
Also used : Receiver(com.splunk.Receiver) Index(com.splunk.Index) RuntimeCamelException(org.apache.camel.RuntimeCamelException) Socket(java.net.Socket)

Example 2 with Index

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);
    }
}
Also used : Receiver(com.splunk.Receiver) Index(com.splunk.Index)

Example 3 with Index

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);
    }
}
Also used : InputCollection(com.splunk.InputCollection) Args(com.splunk.Args) Index(com.splunk.Index) TcpInput(com.splunk.TcpInput) IOException(java.io.IOException) IndexCollection(com.splunk.IndexCollection)

Example 4 with Index

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);
}
Also used : ArrayList(java.util.ArrayList) Index(com.splunk.Index) Test(org.junit.Test)

Aggregations

Index (com.splunk.Index)4 Receiver (com.splunk.Receiver)2 Args (com.splunk.Args)1 IndexCollection (com.splunk.IndexCollection)1 InputCollection (com.splunk.InputCollection)1 TcpInput (com.splunk.TcpInput)1 IOException (java.io.IOException)1 Socket (java.net.Socket)1 ArrayList (java.util.ArrayList)1 RuntimeCamelException (org.apache.camel.RuntimeCamelException)1 Test (org.junit.Test)1