public InputStream scroll(String scrollId) { // NB: dynamically get the stats since the transport can change long start = network.transportStats().netTotalTime; try { BytesArray body; if (internalVersion.onOrAfter(EsMajorVersion.V_2_X)) { body = new BytesArray("{\"scroll_id\":\"" + scrollId + "\"}"); } else { body = new BytesArray(scrollId); } // use post instead of get to avoid some weird encoding issues (caused by the long URL) InputStream is = execute(POST, "_search/scroll?scroll=" + scrollKeepAlive.toString(), body).body(); stats.scrollTotal++; return is; } finally { stats.scrollTotalTime += network.transportStats().netTotalTime - start; } }
/** * Executes a single bulk operation against the provided resource, using the passed data as the request body. * This method will retry bulk requests if the entire bulk request fails, but will not retry singular * document failures. * * @param resource target of the bulk request. * @param data bulk request body. This body will be cleared of entries on any successful bulk request. * @return a BulkActionResponse object that will detail if there were failing documents that should be retried. */ public BulkActionResponse bulk(Resource resource, TrackingBytesArray data) { // NB: dynamically get the stats since the transport can change long start = network.transportStats().netTotalTime; Response response = execute(PUT, resource.bulk(), data); long spent = network.transportStats().netTotalTime - start; stats.bulkTotal++; stats.docsSent += data.entries(); stats.bulkTotalTime += spent; // bytes will be counted by the transport layer return new BulkActionResponse(parseBulkActionResponse(response), response.status(), spent); }
public InputStream scroll(String scrollId) { // NB: dynamically get the stats since the transport can change long start = network.transportStats().netTotalTime; try { // use post instead of get to avoid some weird encoding issues (caused by the long URL) InputStream is = execute(POST, "_search/scroll?scroll=" + scrollKeepAlive.toString(), new BytesArray(scrollId)).body(); stats.scrollTotal++; return is; } finally { stats.scrollTotalTime += network.transportStats().netTotalTime - start; } }
public InputStream scroll(String scrollId) { // NB: dynamically get the stats since the transport can change long start = network.transportStats().netTotalTime; try { BytesArray body; if (internalVersion.onOrAfter(EsMajorVersion.V_2_X)) { body = new BytesArray("{\"scroll_id\":\"" + scrollId + "\"}"); } else { body = new BytesArray(scrollId); } // use post instead of get to avoid some weird encoding issues (caused by the long URL) InputStream is = execute(POST, "_search/scroll?scroll=" + scrollKeepAlive.toString(), body).body(); stats.scrollTotal++; return is; } finally { stats.scrollTotalTime += network.transportStats().netTotalTime - start; } }
public InputStream scroll(String scrollId) { // NB: dynamically get the stats since the transport can change long start = network.transportStats().netTotalTime; try { BytesArray body; if (internalVersion.onOrAfter(EsMajorVersion.V_2_X)) { body = new BytesArray("{\"scroll_id\":\"" + scrollId + "\"}"); } else { body = new BytesArray(scrollId); } // use post instead of get to avoid some weird encoding issues (caused by the long URL) InputStream is = execute(POST, "_search/scroll?scroll=" + scrollKeepAlive.toString(), body).body(); stats.scrollTotal++; return is; } finally { stats.scrollTotalTime += network.transportStats().netTotalTime - start; } }
public InputStream scroll(String scrollId) { // NB: dynamically get the stats since the transport can change long start = network.transportStats().netTotalTime; try { BytesArray body; if (internalVersion.onOrAfter(EsMajorVersion.V_2_X)) { body = new BytesArray("{\"scroll_id\":\"" + scrollId + "\"}"); } else { body = new BytesArray(scrollId); } // use post instead of get to avoid some weird encoding issues (caused by the long URL) InputStream is = execute(POST, "_search/scroll?scroll=" + scrollKeepAlive.toString(), body).body(); stats.scrollTotal++; return is; } finally { stats.scrollTotalTime += network.transportStats().netTotalTime - start; } }
/** * Executes a single bulk operation against the provided resource, using the passed data as the request body. * This method will retry bulk requests if the entire bulk request fails, but will not retry singular * document failures. * * @param resource target of the bulk request. * @param data bulk request body. This body will be cleared of entries on any successful bulk request. * @return a BulkActionResponse object that will detail if there were failing documents that should be retried. */ public BulkActionResponse bulk(Resource resource, TrackingBytesArray data) { // NB: dynamically get the stats since the transport can change long start = network.transportStats().netTotalTime; Response response = execute(PUT, resource.bulk(), data); long spent = network.transportStats().netTotalTime - start; stats.bulkTotal++; stats.docsSent += data.entries(); stats.bulkTotalTime += spent; // bytes will be counted by the transport layer return new BulkActionResponse(parseBulkActionResponse(response), response.status(), spent); }
/** * Executes a single bulk operation against the provided resource, using the passed data as the request body. * This method will retry bulk requests if the entire bulk request fails, but will not retry singular * document failures. * * @param resource target of the bulk request. * @param data bulk request body. This body will be cleared of entries on any successful bulk request. * @return a BulkActionResponse object that will detail if there were failing documents that should be retried. */ public BulkActionResponse bulk(Resource resource, TrackingBytesArray data) { // NB: dynamically get the stats since the transport can change long start = network.transportStats().netTotalTime; Response response = execute(PUT, resource.bulk(), data); long spent = network.transportStats().netTotalTime - start; stats.bulkTotal++; stats.docsSent += data.entries(); stats.bulkTotalTime += spent; // bytes will be counted by the transport layer return new BulkActionResponse(parseBulkActionResponse(response), response.status(), spent); }
/** * Executes a single bulk operation against the provided resource, using the passed data as the request body. * This method will retry bulk requests if the entire bulk request fails, but will not retry singular * document failures. * * @param resource target of the bulk request. * @param data bulk request body. This body will be cleared of entries on any successful bulk request. * @return a BulkActionResponse object that will detail if there were failing documents that should be retried. */ public BulkActionResponse bulk(Resource resource, TrackingBytesArray data) { // NB: dynamically get the stats since the transport can change long start = network.transportStats().netTotalTime; Response response = execute(PUT, resource.bulk(), data); long spent = network.transportStats().netTotalTime - start; stats.bulkTotal++; stats.docsSent += data.entries(); stats.bulkTotalTime += spent; // bytes will be counted by the transport layer return new BulkActionResponse(parseBulkActionResponse(response), response.status(), spent); }
public BitSet bulk(Resource resource, TrackingBytesArray data) { Retry retry = retryPolicy.init(); int httpStatus = 0; boolean isRetry = false; do { // NB: dynamically get the stats since the transport can change long start = network.transportStats().netTotalTime; Response response = execute(PUT, resource.bulk(), data); long spent = network.transportStats().netTotalTime - start; stats.bulkTotal++; stats.docsSent += data.entries(); stats.bulkTotalTime += spent; // bytes will be counted by the transport layer if (isRetry) { stats.docsRetried += data.entries(); stats.bytesRetried += data.length(); stats.bulkRetries++; stats.bulkRetriesTotalTime += spent; } isRetry = true; httpStatus = (retryFailedEntries(response, data) ? HttpStatus.SERVICE_UNAVAILABLE : HttpStatus.OK); } while (data.length() > 0 && retry.retry(httpStatus)); return data.leftoversPosition(); }