Date fromDate = RestUtil.getValidFromDate(from);
Date toDate = RestUtil.getValidToDate(to);
List<Exception> errors = new ArrayList<Exception>();
Flusher flusher = new Flusher(SplunkIndexedLayerFactory.create());
List<String> indexes;
if (index == null)
indexes = ArchivedIndexesListerFactory.create().listIndexes();
else
indexes = asList(index);
for (String i : indexes) {
try {
flusher.flush(i, fromDate, toDate);
} catch (Exception e) {
errors.add(e);
}
}
JSONObject json = JsonUtils.writeKeyValueAsJson(
JsonObjectNames.BUCKET_COLLECTION, flusher.getFlushedBuckets(),
JsonObjectNames.FAILED_BUCKET_COLLECTION, errors);
List<JSONObject> jsons = RequestOnSearchPeers.createPost(
ENDPOINT_BUCKET_FLUSH, index, from, to).execute().jsons;
jsons.add(json);