try {
List<ApplicationReport> esApps = client.listEsClustersAlive();
for (ApplicationReport report : esApps) {
System.out.println(String.format("Stopping Elasticsearch-YARN Cluster with id %s", report.getApplicationId()));
}
List<ApplicationReport> apps = client.killEsApps();
for (ApplicationReport report : apps) {
System.out.println(String.format("Stopped Elasticsearch-YARN cluster with id %s", report.getApplicationId()));
}
} finally {
client.close();