Exemplo n.º 1
0
  public List<List<Map<String, Object>>> targetShards(Resource resource) throws IOException {
    List<List<Map<String, Object>>> shardsJson = null;

    if (indexReadMissingAsEmpty) {
      Response res = execute(GET, resource.targetShards(), false);
      if (res.status() == HttpStatus.NOT_FOUND) {
        shardsJson = Collections.emptyList();
      } else {
        shardsJson = parseContent(res.body(), "shards");
      }
    } else {
      shardsJson = get(resource.targetShards(), "shards");
    }

    return shardsJson;
  }
Exemplo n.º 2
0
  public void bulk(Resource resource, TrackingBytesArray data) throws IOException {
    Retry retry = retryPolicy.init();
    int httpStatus = 0;

    do {
      Response response = execute(PUT, resource.bulk(), data);
      httpStatus =
          (retryFailedEntries(response.body(), data)
              ? HttpStatus.SERVICE_UNAVAILABLE
              : HttpStatus.OK);
    } while (data.length() > 0 && retry.retry(httpStatus));
  }
Exemplo n.º 3
0
 public void refresh(Resource resource) throws IOException {
   execute(POST, resource.refresh());
 }