use of org.elasticsearch.common.unit.TimeValue in project crate by crate.
the class LimitedBackoffPolicyTest method testLimit.
@Test
public void testLimit() throws Exception {
int maxDelay = 1000;
LimitedExponentialBackoff policy = new LimitedExponentialBackoff(0, 1000, maxDelay);
for (TimeValue val : policy) {
assertThat(val.millis(), Matchers.lessThanOrEqualTo((long) maxDelay));
}
}
use of org.elasticsearch.common.unit.TimeValue in project crate by crate.
the class UDCService method doStart.
@Override
protected void doStart() throws ElasticsearchException {
String url = settings.get(UDCPlugin.URL_SETTING_NAME, UDCPlugin.URL_DEFAULT_SETTING);
TimeValue initialDelay = settings.getAsTime(UDCPlugin.INITIAL_DELAY_SETTING_NAME, UDCPlugin.INITIAL_DELAY_DEFAULT_SETTING);
TimeValue interval = settings.getAsTime(UDCPlugin.INTERVAL_SETTING_NAME, UDCPlugin.INTERVAL_DEFAULT_SETTING);
if (logger.isDebugEnabled()) {
logger.debug("Starting with delay {} and period {}.", initialDelay.getSeconds(), interval.getSeconds());
}
PingTask pingTask = new PingTask(clusterService, clusterIdServiceProvider.get(), extendedNodeInfo, url, settings);
timer.scheduleAtFixedRate(pingTask, initialDelay.millis(), interval.millis());
}
use of org.elasticsearch.common.unit.TimeValue in project crate by crate.
the class TableStatsService method onRefreshSettings.
@Override
public void onRefreshSettings(Settings settings) {
TimeValue newRefreshInterval = extractRefreshInterval(settings);
if (!newRefreshInterval.equals(lastRefreshInterval)) {
if (refreshScheduledTask != null) {
refreshScheduledTask.cancel();
}
refreshScheduledTask = scheduleRefresh(newRefreshInterval);
lastRefreshInterval = newRefreshInterval;
}
}
use of org.elasticsearch.common.unit.TimeValue in project elasticsearch by elastic.
the class SearchRequestTests method mutate.
private SearchRequest mutate(SearchRequest searchRequest) throws IOException {
SearchRequest mutation = copyRequest(searchRequest);
List<Runnable> mutators = new ArrayList<>();
mutators.add(() -> mutation.indices(ArrayUtils.concat(searchRequest.indices(), new String[] { randomAsciiOfLength(10) })));
mutators.add(() -> mutation.indicesOptions(randomValueOtherThan(searchRequest.indicesOptions(), () -> IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()))));
mutators.add(() -> mutation.types(ArrayUtils.concat(searchRequest.types(), new String[] { randomAsciiOfLength(10) })));
mutators.add(() -> mutation.preference(randomValueOtherThan(searchRequest.preference(), () -> randomAsciiOfLengthBetween(3, 10))));
mutators.add(() -> mutation.routing(randomValueOtherThan(searchRequest.routing(), () -> randomAsciiOfLengthBetween(3, 10))));
mutators.add(() -> mutation.requestCache((randomValueOtherThan(searchRequest.requestCache(), () -> randomBoolean()))));
mutators.add(() -> mutation.scroll(randomValueOtherThan(searchRequest.scroll(), () -> new Scroll(new TimeValue(randomNonNegativeLong() % 100000)))));
mutators.add(() -> mutation.searchType(randomValueOtherThan(searchRequest.searchType(), () -> randomFrom(SearchType.values()))));
mutators.add(() -> mutation.source(randomValueOtherThan(searchRequest.source(), this::createSearchSourceBuilder)));
randomFrom(mutators).run();
return mutation;
}
use of org.elasticsearch.common.unit.TimeValue in project elasticsearch by elastic.
the class AggregationsIntegrationIT method testScroll.
public void testScroll() {
final int size = randomIntBetween(1, 4);
SearchResponse response = client().prepareSearch("index").setSize(size).setScroll(new TimeValue(500)).addAggregation(terms("f").field("f")).get();
assertSearchResponse(response);
Aggregations aggregations = response.getAggregations();
assertNotNull(aggregations);
Terms terms = aggregations.get("f");
assertEquals(Math.min(numDocs, 3L), terms.getBucketByKey("0").getDocCount());
int total = response.getHits().getHits().length;
while (response.getHits().getHits().length > 0) {
response = client().prepareSearchScroll(response.getScrollId()).setScroll(new TimeValue(500)).execute().actionGet();
assertNull(response.getAggregations());
total += response.getHits().getHits().length;
}
clearScroll(response.getScrollId());
assertEquals(numDocs, total);
}
Aggregations