private static Node createNode() { try { Path tempDir = Files.createTempDirectory("EsTester"); tempDir.toFile().deleteOnExit(); Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), tempDir) .put("node.name", "EsTester") .put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), Integer.MAX_VALUE) .put("logger.level", "INFO") .put("action.auto_create_index", false) // Default the watermarks to absurdly low to prevent the tests // from failing on nodes without enough disk space .put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "1b") .put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), "1b") // always reduce this - it can make tests really slow .put(RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_STATE_SYNC_SETTING.getKey(), TimeValue.timeValueMillis(20)) .put(NetworkModule.TRANSPORT_TYPE_KEY, "local") .put(NetworkModule.HTTP_ENABLED.getKey(), false) .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "single-node") .build(); Node node = new Node(settings); return node.start(); } catch (Exception e) { throw new IllegalStateException("Fail to start embedded Elasticsearch", e); } } }
public <T> Page<T> continueScroll(@Nullable String scrollId, long scrollTimeInMillis, Class<T> clazz) { SearchScrollRequest request = new SearchScrollRequest(scrollId); request.scroll(TimeValue.timeValueMillis(scrollTimeInMillis)); SearchResponse response; try { response = client.searchScroll(request); } catch (IOException e) { throw new ElasticsearchException("Error for search request with scroll: " + request.toString(), e); } return resultsMapper.mapResults(response, clazz, Pageable.unpaged()); }
public <T> Page<T> continueScroll(@Nullable String scrollId, long scrollTimeInMillis, Class<T> clazz, SearchResultMapper mapper) { SearchScrollRequest request = new SearchScrollRequest(scrollId); request.scroll(TimeValue.timeValueMillis(scrollTimeInMillis)); SearchResponse response; try { response = client.searchScroll(request); } catch (IOException e) { throw new ElasticsearchException("Error for search request with scroll: " + request.toString(), e); } return mapper.mapResults(response, clazz, Pageable.unpaged()); }
/** * 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(); }
.setBackoffPolicy( BackoffPolicy.exponentialBackoff( TimeValue.timeValueMillis(100), 3)) .build();
.setTimeout(TimeValue.timeValueMillis(queryTimeout));
private SearchRequest prepareScroll(Query query, long scrollTimeInMillis) { SearchRequest request = new SearchRequest(toArray(query.getIndices())); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); request.types(toArray(query.getTypes())); request.scroll(TimeValue.timeValueMillis(scrollTimeInMillis)); if (query.getPageable().isPaged()) { searchSourceBuilder.size(query.getPageable().getPageSize()); } if (!isEmpty(query.getFields())) { searchSourceBuilder.fetchSource(toArray(query.getFields()), null); } request.source(searchSourceBuilder); return request; }
/** * Creates an new exponential backoff policy with a default configuration of 50 ms initial wait period and 8 retries taking * roughly 5.1 seconds in total. * * @return A backoff policy with an exponential increase in wait time for retries. The returned instance is thread safe but each * iterator created from it should only be used by a single thread. */ public static BackoffPolicy exponentialBackoff() { return exponentialBackoff(TimeValue.timeValueMillis(50), 8); }
public static TimeValue nodeTimeValue(Object node) { if (node instanceof Number) { return TimeValue.timeValueMillis(((Number) node).longValue()); } return TimeValue.parseTimeValue(node.toString(), null, XContentMapValues.class.getSimpleName() + ".nodeTimeValue"); }
@Override public TimeValue next() { if (!hasNext()) { throw new NoSuchElementException("Only up to " + numberOfElements + " elements"); } int result = start + 10 * ((int) Math.exp(0.8d * (currentlyConsumed)) - 1); currentlyConsumed++; return TimeValue.timeValueMillis(result); } }
public MaxAgeCondition(StreamInput in) throws IOException { super(NAME); this.value = TimeValue.timeValueMillis(in.readLong()); }
public Builder withTimeout(long timeout) { return withTimeout(TimeValue.timeValueMillis(timeout)); }
/** * Get the interval as a {@link TimeValue}. Should only be called if * {@link #getIntervalAsDateTimeUnit()} returned {@code null}. */ private TimeValue getIntervalAsTimeValue() { if (dateHistogramInterval != null) { return TimeValue.parseTimeValue(dateHistogramInterval.toString(), null, getClass().getSimpleName() + ".interval"); } else { return TimeValue.timeValueMillis(interval); } }
private void contextScrollKeepAlive(SearchContext context, long keepAlive) throws IOException { if (keepAlive > maxKeepAlive) { throw new QueryPhaseExecutionException(context, "Keep alive for scroll (" + TimeValue.timeValueMillis(keepAlive) + ") is too large. " + "It must be less than (" + TimeValue.timeValueMillis(maxKeepAlive) + "). " + "This limit can be set by changing the [" + MAX_KEEPALIVE_SETTING.getKey() + "] cluster level setting."); } context.keepAlive(keepAlive); }
@Override public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { final long timeoutInMillis = Math.max(0, endTimeMS - TimeValue.nsecToMSec(System.nanoTime())); final TimeValue newTimeout = TimeValue.timeValueMillis(timeoutInMillis); request.timeout(newTimeout); executeHealth(request, listener); }
@Override public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { final long timeoutInMillis = Math.max(0, endTimeMS - TimeValue.nsecToMSec(System.nanoTime())); final TimeValue newTimeout = TimeValue.timeValueMillis(timeoutInMillis); request.timeout(newTimeout); executeHealth(request, listener); }
public static Setting<TimeValue> positiveTimeSetting( final String key, final Setting<TimeValue> fallbackSetting, final TimeValue minValue, final Property... properties) { return timeSetting(key, fallbackSetting, minValue, properties); }
private UnicastPingResponse handlePingRequest(final UnicastPingRequest request) { assert clusterName.equals(request.pingResponse.clusterName()) : "got a ping request from a different cluster. expected " + clusterName + " got " + request.pingResponse.clusterName(); temporalResponses.add(request.pingResponse); // add to any ongoing pinging activePingingRounds.values().forEach(p -> p.addPingResponseToCollection(request.pingResponse)); threadPool.schedule(TimeValue.timeValueMillis(request.timeout.millis() * 2), ThreadPool.Names.SAME, () -> temporalResponses.remove(request.pingResponse)); List<PingResponse> pingResponses = CollectionUtils.iterableAsArrayList(temporalResponses); pingResponses.add(createPingResponse(contextProvider.clusterState())); return new UnicastPingResponse(request.id, pingResponses.toArray(new PingResponse[pingResponses.size()])); }
public IngestService(ClusterService clusterService, ThreadPool threadPool, Environment env, ScriptService scriptService, AnalysisRegistry analysisRegistry, List<IngestPlugin> ingestPlugins) { this.clusterService = clusterService; this.scriptService = scriptService; this.processorFactories = processorFactories( ingestPlugins, new Processor.Parameters( env, scriptService, analysisRegistry, threadPool.getThreadContext(), threadPool::relativeTimeInMillis, (delay, command) -> threadPool.schedule( TimeValue.timeValueMillis(delay), ThreadPool.Names.GENERIC, command ), this ) ); this.threadPool = threadPool; }
private Rounding createRounding() { Rounding.Builder tzRoundingBuilder; if (dateHistogramInterval != null) { DateTimeUnit dateTimeUnit = DATE_FIELD_UNITS.get(dateHistogramInterval.toString()); if (dateTimeUnit != null) { tzRoundingBuilder = Rounding.builder(dateTimeUnit); } else { // the interval is a time value? tzRoundingBuilder = Rounding.builder( TimeValue.parseTimeValue(dateHistogramInterval.toString(), null, getClass().getSimpleName() + ".interval")); } } else { // the interval is an integer time value in millis? tzRoundingBuilder = Rounding.builder(TimeValue.timeValueMillis(interval)); } if (timeZone() != null) { tzRoundingBuilder.timeZone(timeZone()); } Rounding rounding = tzRoundingBuilder.build(); return rounding; }