- Changed how isDone() behaves with respect to job creation. Previously if a job
was not ready on the server, calling job.isDone() would cause an exception.
Now, calling isDone() will return false under the two following conditions:
- The job has not yet been scheduled. 2) The job has been scheduled but the results are not ready. In addition, isDone() implicitly invokes job.refresh() so the caller does not need to. This simplifies the code waiting for a job result to this: (with a 500 millisecond polling interval)
while (!job.isDone()) {
sleep(500);
}
- Added isReady() method to the Job class. This method detects whether or not the job is ready to return data (i.e. be queried). It also implicitly invokes job.refresh(). This allows for jobs with previews but that have not necessarily completed to be accessed: (with a 500 millisecond polling interval)
while (!job.isReady()) {
sleep(500);
}
- All Job class accessors will call refresh once before accessing the object.
-
Fixed ordering of collections when using pagination. Previously the order could be random. Now it maintains the order of the entities returned by the server.
-
Fixed XML streaming reader to properly work with paginated result sets.
-
Large collections can cause a default JVM to run out of memory: The Atom parsing uses the streaming XML parser as opposed to a DOM parser.
-
Fixed Index class getSync() method to return an integer instead of a boolean.
-
Added Index class get method getEnableOnlineBucketRepair().
-
Added Index class get method getMaxBloomBackfillBucketAge().
StormServiceclassReceiverclassUploadclass- New setter methods for all classes
- New getter methods for various classes
-
Added support for a default index, allowing optional parameters for streaming connections. The
Indexclass now uses the newReceiverclass. -
Added a paginate feature for Splunk return data. This feature allows for
countandoffsetmethods to page through Splunk meta data instead of retrieving all the data at once:
ConfCollection confs;
Args args = new Args();
args.put("count", 30);
args.put("offset", 0);
confs = service.getConfs(args);
// ... operate on the first 30 elements
offset = offset + 30;
args.put("offset", offset)
confs = service.getConfs(args);
// ... operate on the next 30 elements
-
Added a namespacing feature as optional arguments (
app,owner,sharing) to the collection'screateandgetmethods. For more information about namespaces, see "Overview of the Splunk Java SDK" on the Developer Portal.The following example shows how to use the optional namespace to restrict creating and selecting saved searches to the namespace "owner = magilicuddy, app = oneMeanApp":
String searchName = "My scoped search";
String search = "index=main * | head 10";
args args = new Args();
args.put("owner", "magilicuddy");
args.put("app", "oneMeanApp");
// ... other creation arguments also get set into the args map
savedSearches.create(searchName, search, args);
This example shows how to returns all saved searches within the same scoped namespace:
args args = new Args();
args.put("owner", "magilicuddy");
args.put("app", "oneMeanApp");
SavedSearchCollection
mySavedSearches = service.getSavedSearches(args);
-
Added an XML, JSON, and CSV streaming results reader. This feature allows you to retrieve event data using an incremental streaming mechanism. Return data is in key-value pairs. The XML form uses built-in JDK XML parsing support. The JSON and CSV form requires third-party JSON and CSV tokenizers, which are included as ancillary .jar files in the SDK. The JSON and CSV streaming results reader, which requires the external tokenizers, are contained in a separate Splunk .jar file named
splunk-external.jar.The following example uses the built-in XML streaming reader:
Job job = service.getJobs().create(query, queryArgs);
...
HashMap<String, String> map;
stream = job.getResults(outputArgs);
ResultsReader resultsReader = new ResultsReaderXml(stream);
while ((map = resultsReader.getNextEvent()) != null) {
for (String key: map.keySet())
System.out.println(key + " --> " + map.get(key));
}
- Added support for Splunk Storm. Instead of connecting to
Service, you connect to the newStormServiceclass using similar arguments. Then, get aReceiverobject and log events.StormServicerequires theindexkey andsourcetypeparameters when sending events:
// the storm token provided by Splunk
Args loginArgs = new Args("StormToken",
"p-n8SwuWEqPlyOXdDU4PjxavFdAn1CnJea9LirgTvzmIhMEBys6w7UJUCtxp_7g7Q9XopR5dW0w=");
Storm service = StormService.connect(loginArgs);
// get the receiver object
Receiver receiver = service.getReceiver();
// index and source type are required for storm event submission
Args logArgs = new Args();
logArgs.put("index", "0e8a2df0834211e1a6fe123139335741");
logArgs.put("sourcetype", "yoursourcetype");
// log an event.
receiver.log("This is a test event from the SDK", logArgs);
- Added a
geneventsexample to generate events and push into Splunk using various methods. - Added a second time format when parsing time. A second time format is required
to accommodate the
data/input/oneshotendpoint that does not return a standard time format and does not allow a time-format specifier. - Added a streaming reader to search examples. The main search example
searchshows how to use all three result readers. There are build modifications in build.xml to include the ancillary .jar files for JSON and CSV. - Added an
Inputexample to display Splunk inputs and their attributes. - Added an alias
logforsubmitto theReceiverclass. - Updated eclipse .classpath file, accounting for new additions.
- Fixed argument processing in the tail example.
- Fixed timing window during search job creation; added
JOB_NOT_READYexception. - Fixed
Indexcleaning to require a timeout value; addedTIMEOUTexception. - Fixed
LicensePooltype to use string quota instead of integer. This change allows forMAXand<number>[M|G|T]. - Fixed
actionwhen trying to updateSettings. - Fixed user creation to force lowercase usernames.
- Fixed the missing get methods for
ServiceInfo. - Fixed a number of getter methods.
Initial Java SDK release.