code: public static boolean isClusterRunning(String clusterName,
              int instanceCount,
              ElasticsearchClient client)
      {
          boolean result;
          try
          {
              @SuppressWarnings("unchecked")
              Map<String, Object> response = client.get("/_nodes", Map.class);
              result = clusterName.equals(response.get("cluster_name"));
              
              @SuppressWarnings("unchecked")
              Map<String, Object> nodesInfo = (Map<String, Object>)response.get("_nodes");
              result &= instanceCount == (int)(nodesInfo.get("successful"));
          }
          catch (ElasticsearchClientException e)
          {
              // failure is allowed
              result = false;
          }
          
          return result;
      }
docs: Verify that the cluster name and the number of nodes in the cluster,
  as reported by the ES node, is as expected.
  @param clusterName the ES cluster name
  @param instanceCount the number of ES nodes in the cluster
  @param client the ES client to use to connect to ES
  @return true if the cluster is running, false otherwise