@Override public <T> CloseableIterator<T> stream(CriteriaQuery query, Class<T> clazz) { final long scrollTimeInMillis = TimeValue.timeValueMinutes(1).millis(); return doStream(scrollTimeInMillis, (ScrolledPage<T>) startScroll(scrollTimeInMillis, query, clazz), clazz, resultsMapper); }
Params putParam(String key, TimeValue value) { if (value != null) { return putParam(key, value.getStringRep()); } return this; }
public SearchScrollRequestBuilder prepareSearchScroll(String scrollId) { return client.prepareSearchScroll(scrollId) .setScroll(new TimeValue(scrollTimeout.toMillis())); }
@Override public boolean hasNext() { if (hits.isEmpty()) { SearchScrollRequestBuilder esRequest = esClient.prepareSearchScroll(scrollId) .setScroll(TimeValue.timeValueMinutes(SCROLL_TIME_IN_MINUTES)); Collections.addAll(hits, esRequest.get().getHits().getHits()); } return !hits.isEmpty(); }
/** * Build the {@link BulkProcessor}. * * <p>Note: this is exposed for testing purposes. */ @VisibleForTesting protected BulkProcessor buildBulkProcessor(BulkProcessor.Listener listener) { checkNotNull(listener); BulkProcessor.Builder bulkProcessorBuilder = callBridge.createBulkProcessorBuilder(client, listener); // This makes flush() blocking bulkProcessorBuilder.setConcurrentRequests(0); if (bulkProcessorFlushMaxActions != null) { bulkProcessorBuilder.setBulkActions(bulkProcessorFlushMaxActions); } if (bulkProcessorFlushMaxSizeMb != null) { bulkProcessorBuilder.setBulkSize(new ByteSizeValue(bulkProcessorFlushMaxSizeMb, ByteSizeUnit.MB)); } if (bulkProcessorFlushIntervalMillis != null) { bulkProcessorBuilder.setFlushInterval(TimeValue.timeValueMillis(bulkProcessorFlushIntervalMillis)); } // if backoff retrying is disabled, bulkProcessorFlushBackoffPolicy will be null callBridge.configureBulkProcessorBackoff(bulkProcessorBuilder, bulkProcessorFlushBackoffPolicy); return bulkProcessorBuilder.build(); }
public static SearchResponse scrollOneTimeWithHits(Client client, SearchRequestBuilder requestBuilder, Select originalSelect, int resultSize) { SearchResponse responseWithHits;SearchRequestBuilder scrollRequest = requestBuilder .setScroll(new TimeValue(60000)) .setSize(resultSize); boolean ordered = originalSelect.isOrderdSelect(); if(!ordered) scrollRequest.addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC); responseWithHits = scrollRequest.get(); //on ordered select - not using SCAN , elastic returns hits on first scroll //es5.0 elastic always return docs on scan // if(!ordered) { // responseWithHits = client.prepareSearchScroll(responseWithHits.getScrollId()).setScroll(new TimeValue(600000)).get(); // } return responseWithHits; }
private void waitForIndexYellow(String index) { Client nativeClient = esClient.nativeClient(); ClusterHealthAction.INSTANCE.newRequestBuilder(nativeClient).setIndices(index).setWaitForYellowStatus().get(TimeValue.timeValueMinutes(10)); }
@Override public <T> CloseableIterator<T> stream(SearchQuery query, final Class<T> clazz, final SearchResultMapper mapper) { final long scrollTimeInMillis = TimeValue.timeValueMinutes(1).millis(); return doStream(scrollTimeInMillis, (ScrolledPage<T>) startScroll(scrollTimeInMillis, query, clazz, mapper), clazz, mapper); }
@Override public void configureBulkProcessorBackoff( BulkProcessor.Builder builder, @Nullable ElasticsearchSinkBase.BulkFlushBackoffPolicy flushBackoffPolicy) { BackoffPolicy backoffPolicy; if (flushBackoffPolicy != null) { switch (flushBackoffPolicy.getBackoffType()) { case CONSTANT: backoffPolicy = BackoffPolicy.constantBackoff( new TimeValue(flushBackoffPolicy.getDelayMillis()), flushBackoffPolicy.getMaxRetryCount()); break; case EXPONENTIAL: default: backoffPolicy = BackoffPolicy.exponentialBackoff( new TimeValue(flushBackoffPolicy.getDelayMillis()), flushBackoffPolicy.getMaxRetryCount()); } } else { backoffPolicy = BackoffPolicy.noBackoff(); } builder.setBackoffPolicy(backoffPolicy); }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { try { es.client().prepareClearCache().get(TimeValue.timeValueMinutes(1)); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
@Override public void configureBulkProcessorBackoff( BulkProcessor.Builder builder, @Nullable ElasticsearchSinkBase.BulkFlushBackoffPolicy flushBackoffPolicy) { BackoffPolicy backoffPolicy; if (flushBackoffPolicy != null) { switch (flushBackoffPolicy.getBackoffType()) { case CONSTANT: backoffPolicy = BackoffPolicy.constantBackoff( new TimeValue(flushBackoffPolicy.getDelayMillis()), flushBackoffPolicy.getMaxRetryCount()); break; case EXPONENTIAL: default: backoffPolicy = BackoffPolicy.exponentialBackoff( new TimeValue(flushBackoffPolicy.getDelayMillis()), flushBackoffPolicy.getMaxRetryCount()); } } else { backoffPolicy = BackoffPolicy.noBackoff(); } builder.setBackoffPolicy(backoffPolicy); } }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { try { es.client().prepareIndex(FakeIndexDefinition.INDEX_TYPE_FAKE).get(TimeValue.timeValueMinutes(1)); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
@Override public void configureBulkProcessorBackoff( BulkProcessor.Builder builder, @Nullable ElasticsearchSinkBase.BulkFlushBackoffPolicy flushBackoffPolicy) { BackoffPolicy backoffPolicy; if (flushBackoffPolicy != null) { switch (flushBackoffPolicy.getBackoffType()) { case CONSTANT: backoffPolicy = BackoffPolicy.constantBackoff( new TimeValue(flushBackoffPolicy.getDelayMillis()), flushBackoffPolicy.getMaxRetryCount()); break; case EXPONENTIAL: default: backoffPolicy = BackoffPolicy.exponentialBackoff( new TimeValue(flushBackoffPolicy.getDelayMillis()), flushBackoffPolicy.getMaxRetryCount()); } } else { backoffPolicy = BackoffPolicy.noBackoff(); } builder.setBackoffPolicy(backoffPolicy); } }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { try { es.client().prepareState().get(TimeValue.timeValueMinutes(1)); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
protected SearchResponse scrollOneTimeWithMax(Client client,TableInJoinRequestBuilder tableRequest) { SearchResponse responseWithHits;SearchRequestBuilder scrollRequest = tableRequest.getRequestBuilder() .setScroll(new TimeValue(60000)) .setSize(MAX_RESULTS_ON_ONE_FETCH); boolean ordered = tableRequest.getOriginalSelect().isOrderdSelect(); if(!ordered) scrollRequest.addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC); responseWithHits = scrollRequest.get(); //on ordered select - not using SCAN , elastic returns hits on first scroll //es5.0 elastic always return docs on scan // if(!ordered) // responseWithHits = client.prepareSearchScroll(responseWithHits.getScrollId()).setScroll(new TimeValue(600000)).get(); return responseWithHits; }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { try { es.client().prepareSearchScroll("scrollId").get(TimeValue.timeValueMinutes(1)); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { try { es.client().prepareRefresh(FakeIndexDefinition.INDEX).get(TimeValue.timeValueMinutes(1)); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { try { es.client().preparePutMapping().get(TimeValue.timeValueMinutes(1)); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { try { es.client().prepareDelete("fakes", "fake", "the_id").get(TimeValue.timeValueMinutes(1)); fail(); } catch (UnsupportedOperationException e) { assertThat(e).hasMessage("Not yet implemented"); } }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Not yet implemented"); es.client().prepareNodesStats(FakeIndexDefinition.INDEX).get(TimeValue.timeValueMinutes(1)); }