use of org.apache.hop.splunk.SplunkConnection in project hop by apache.
the class SplunkInputDialog method getReturnValues.
private void getReturnValues() {
try {
IHopMetadataSerializer<SplunkConnection> serializer = metadataProvider.getSerializer(SplunkConnection.class);
SplunkConnection splunkConnection = serializer.load(variables.resolve(wConnection.getText()));
Service service = Service.connect(splunkConnection.getServiceArgs(variables));
Args args = new Args();
args.put("connection_mode", JobArgs.ExecutionMode.BLOCKING.name());
InputStream eventsStream = service.oneshotSearch(variables.resolve(wQuery.getText()), args);
Set<String> detectedKeys = new HashSet<>();
try {
ResultsReaderXml resultsReader = new ResultsReaderXml(eventsStream);
HashMap<String, String> event;
int nrScanned = 0;
while ((event = resultsReader.getNextEvent()) != null) {
for (String key : event.keySet()) {
detectedKeys.add(key);
}
nrScanned++;
if (nrScanned > 10) {
break;
}
}
} finally {
eventsStream.close();
}
for (String detectedKey : detectedKeys) {
TableItem item = new TableItem(wReturns.table, SWT.NONE);
item.setText(1, detectedKey);
item.setText(2, detectedKey);
item.setText(3, "String");
}
wReturns.removeEmptyRows();
wReturns.setRowNums();
wReturns.optWidth(true);
} catch (Exception e) {
new ErrorDialog(shell, "Error", "Error getting fields from Splunk query", e);
}
}
Aggregations