always pass setting name to TimeValue.parseTimeValue; make units required
This commit is contained in:
parent
dfd7122a53
commit
6a6df5f8ce
|
@ -83,7 +83,7 @@ public class ClusterHealthRequest extends MasterNodeReadOperationRequest<Cluster
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClusterHealthRequest timeout(String timeout) {
|
public ClusterHealthRequest timeout(String timeout) {
|
||||||
return this.timeout(TimeValue.parseTimeValue(timeout, null));
|
return this.timeout(TimeValue.parseTimeValue(timeout, null, "ClusterHealthRequest.timeout"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClusterHealthStatus waitForStatus() {
|
public ClusterHealthStatus waitForStatus() {
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class DeleteIndexRequest extends MasterNodeOperationRequest<DeleteIndexRe
|
||||||
* to <tt>10s</tt>.
|
* to <tt>10s</tt>.
|
||||||
*/
|
*/
|
||||||
public DeleteIndexRequest timeout(String timeout) {
|
public DeleteIndexRequest timeout(String timeout) {
|
||||||
return timeout(TimeValue.parseTimeValue(timeout, null));
|
return timeout(TimeValue.parseTimeValue(timeout, null, "DeleteIndexRequest.timeout"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -308,7 +308,7 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
|
||||||
timestamp = parser.text();
|
timestamp = parser.text();
|
||||||
} else if ("_ttl".equals(currentFieldName) || "ttl".equals(currentFieldName)) {
|
} else if ("_ttl".equals(currentFieldName) || "ttl".equals(currentFieldName)) {
|
||||||
if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
|
if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
|
||||||
ttl = TimeValue.parseTimeValue(parser.text(), null).millis();
|
ttl = TimeValue.parseTimeValue(parser.text(), null, currentFieldName).millis();
|
||||||
} else {
|
} else {
|
||||||
ttl = parser.longValue();
|
ttl = parser.longValue();
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
|
||||||
* A timeout to wait if the index operation can't be performed immediately. Defaults to <tt>1m</tt>.
|
* A timeout to wait if the index operation can't be performed immediately. Defaults to <tt>1m</tt>.
|
||||||
*/
|
*/
|
||||||
public final BulkRequest timeout(String timeout) {
|
public final BulkRequest timeout(String timeout) {
|
||||||
return timeout(TimeValue.parseTimeValue(timeout, null));
|
return timeout(TimeValue.parseTimeValue(timeout, null, "BulkRequest.timeout"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeValue timeout() {
|
public TimeValue timeout() {
|
||||||
|
|
|
@ -476,7 +476,7 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
|
||||||
* If set, will enable scrolling of the search request for the specified timeout.
|
* If set, will enable scrolling of the search request for the specified timeout.
|
||||||
*/
|
*/
|
||||||
public SearchRequest scroll(String keepAlive) {
|
public SearchRequest scroll(String keepAlive) {
|
||||||
return scroll(new Scroll(TimeValue.parseTimeValue(keepAlive, null)));
|
return scroll(new Scroll(TimeValue.parseTimeValue(keepAlive, null, "SearchRequest.Scroll.keepAlive")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class SearchScrollRequest extends ActionRequest<SearchScrollRequest> {
|
||||||
* If set, will enable scrolling of the search request for the specified timeout.
|
* If set, will enable scrolling of the search request for the specified timeout.
|
||||||
*/
|
*/
|
||||||
public SearchScrollRequest scroll(String keepAlive) {
|
public SearchScrollRequest scroll(String keepAlive) {
|
||||||
return scroll(new Scroll(TimeValue.parseTimeValue(keepAlive, null)));
|
return scroll(new Scroll(TimeValue.parseTimeValue(keepAlive, null, "SearchScrollRequest.keepAlive")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -51,7 +51,7 @@ public abstract class AdapterActionFuture<T, L> extends BaseFuture<T> implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T actionGet(String timeout) {
|
public T actionGet(String timeout) {
|
||||||
return actionGet(TimeValue.parseTimeValue(timeout, null));
|
return actionGet(TimeValue.parseTimeValue(timeout, null, "AdapterActionFuture.actionGet.timeout"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -53,7 +53,7 @@ public abstract class AcknowledgedRequest<T extends MasterNodeOperationRequest>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final T timeout(String timeout) {
|
public final T timeout(String timeout) {
|
||||||
this.timeout = TimeValue.parseTimeValue(timeout, this.timeout);
|
this.timeout = TimeValue.parseTimeValue(timeout, this.timeout, "AcknowledgedRequest.timeout");
|
||||||
return (T)this;
|
return (T)this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public abstract class MasterNodeOperationRequest<T extends MasterNodeOperationRe
|
||||||
* A timeout value in case the master has not been discovered yet or disconnected.
|
* A timeout value in case the master has not been discovered yet or disconnected.
|
||||||
*/
|
*/
|
||||||
public final T masterNodeTimeout(String timeout) {
|
public final T masterNodeTimeout(String timeout) {
|
||||||
return masterNodeTimeout(TimeValue.parseTimeValue(timeout, null));
|
return masterNodeTimeout(TimeValue.parseTimeValue(timeout, null, "MasterNodeOperationRequest.masterNodeTimeout"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final TimeValue masterNodeTimeout() {
|
public final TimeValue masterNodeTimeout() {
|
||||||
|
|
|
@ -74,7 +74,7 @@ public abstract class NodesOperationRequest<T extends NodesOperationRequest> ext
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final T timeout(String timeout) {
|
public final T timeout(String timeout) {
|
||||||
this.timeout = TimeValue.parseTimeValue(timeout, null);
|
this.timeout = TimeValue.parseTimeValue(timeout, null, "NodesOperationRequest.timeout");
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ public abstract class ShardReplicationOperationRequest<T extends ShardReplicatio
|
||||||
* A timeout to wait if the index operation can't be performed immediately. Defaults to <tt>1m</tt>.
|
* A timeout to wait if the index operation can't be performed immediately. Defaults to <tt>1m</tt>.
|
||||||
*/
|
*/
|
||||||
public final T timeout(String timeout) {
|
public final T timeout(String timeout) {
|
||||||
return timeout(TimeValue.parseTimeValue(timeout, null));
|
return timeout(TimeValue.parseTimeValue(timeout, null, "ShardReplicatoinOperationRequest.timeout"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeValue timeout() {
|
public TimeValue timeout() {
|
||||||
|
|
|
@ -97,7 +97,7 @@ public abstract class InstanceShardOperationRequest<T extends InstanceShardOpera
|
||||||
* A timeout to wait if the index operation can't be performed immediately. Defaults to <tt>1m</tt>.
|
* A timeout to wait if the index operation can't be performed immediately. Defaults to <tt>1m</tt>.
|
||||||
*/
|
*/
|
||||||
public final T timeout(String timeout) {
|
public final T timeout(String timeout) {
|
||||||
return timeout(TimeValue.parseTimeValue(timeout, null));
|
return timeout(TimeValue.parseTimeValue(timeout, null, "InstanceShardOperationRequest.timeout"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -259,7 +259,7 @@ public class UpdateHelper extends AbstractComponent {
|
||||||
if (fetchedTTL instanceof Number) {
|
if (fetchedTTL instanceof Number) {
|
||||||
ttl = ((Number) fetchedTTL).longValue();
|
ttl = ((Number) fetchedTTL).longValue();
|
||||||
} else {
|
} else {
|
||||||
ttl = TimeValue.parseTimeValue((String) fetchedTTL, null).millis();
|
ttl = TimeValue.parseTimeValue((String) fetchedTTL, null, "_ttl").millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ttl;
|
return ttl;
|
||||||
|
|
|
@ -45,7 +45,7 @@ public interface Validator {
|
||||||
@Override
|
@Override
|
||||||
public String validate(String setting, String value) {
|
public String validate(String setting, String value) {
|
||||||
try {
|
try {
|
||||||
if (TimeValue.parseTimeValue(value, null) == null) {
|
if (TimeValue.parseTimeValue(value, null, setting) == null) {
|
||||||
return "cannot parse value [" + value + "] as time";
|
return "cannot parse value [" + value + "] as time";
|
||||||
}
|
}
|
||||||
} catch (ElasticsearchParseException ex) {
|
} catch (ElasticsearchParseException ex) {
|
||||||
|
@ -59,7 +59,7 @@ public interface Validator {
|
||||||
@Override
|
@Override
|
||||||
public String validate(String setting, String value) {
|
public String validate(String setting, String value) {
|
||||||
try {
|
try {
|
||||||
TimeValue timeValue = TimeValue.parseTimeValue(value, null);
|
TimeValue timeValue = TimeValue.parseTimeValue(value, null, setting);
|
||||||
if (timeValue == null) {
|
if (timeValue == null) {
|
||||||
return "cannot parse value [" + value + "] as time";
|
return "cannot parse value [" + value + "] as time";
|
||||||
}
|
}
|
||||||
|
|
|
@ -357,12 +357,19 @@ public class ImmutableSettings implements Settings {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TimeValue getAsTime(String setting, TimeValue defaultValue) {
|
public TimeValue getAsTime(String setting, TimeValue defaultValue) {
|
||||||
return parseTimeValue(get(setting), defaultValue);
|
return parseTimeValue(get(setting), defaultValue, setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TimeValue getAsTime(String[] settings, TimeValue defaultValue) {
|
public TimeValue getAsTime(String[] settings, TimeValue defaultValue) {
|
||||||
return parseTimeValue(get(settings), defaultValue);
|
// NOTE: duplicated from get(String[]) so we can pass which setting name was actually used to parseTimeValue:
|
||||||
|
for (String setting : settings) {
|
||||||
|
String retVal = get(setting);
|
||||||
|
if (retVal != null) {
|
||||||
|
parseTimeValue(get(settings), defaultValue, setting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -152,7 +152,7 @@ public final class Fuzziness implements ToXContent {
|
||||||
if (this == AUTO) {
|
if (this == AUTO) {
|
||||||
return TimeValue.timeValueMillis(1);
|
return TimeValue.timeValueMillis(1);
|
||||||
} else {
|
} else {
|
||||||
return TimeValue.parseTimeValue(fuzziness.toString(), null);
|
return TimeValue.parseTimeValue(fuzziness.toString(), null, "fuzziness");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,9 @@ import org.joda.time.format.PeriodFormatter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TimeValue implements Serializable, Streamable {
|
public class TimeValue implements Serializable, Streamable {
|
||||||
|
|
||||||
/** How many nano-seconds in one milli-second */
|
/** How many nano-seconds in one milli-second */
|
||||||
|
@ -228,7 +226,8 @@ public class TimeValue implements Serializable, Streamable {
|
||||||
return Strings.format1Decimals(value, suffix);
|
return Strings.format1Decimals(value, suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TimeValue parseTimeValue(String sValue, TimeValue defaultValue) {
|
public static TimeValue parseTimeValue(String sValue, TimeValue defaultValue, String settingName) {
|
||||||
|
settingName = Objects.requireNonNull(settingName);
|
||||||
if (sValue == null) {
|
if (sValue == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -248,8 +247,15 @@ public class TimeValue implements Serializable, Streamable {
|
||||||
millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 24 * 60 * 60 * 1000);
|
millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 24 * 60 * 60 * 1000);
|
||||||
} else if (sValue.endsWith("w")) {
|
} else if (sValue.endsWith("w")) {
|
||||||
millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 7 * 24 * 60 * 60 * 1000);
|
millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 7 * 24 * 60 * 60 * 1000);
|
||||||
|
} else if (sValue.equals("-1")) {
|
||||||
|
// Allow this special value to be unit-less:
|
||||||
|
millis = -1;
|
||||||
|
} else if (sValue.equals("0")) {
|
||||||
|
// Allow this special value to be unit-less:
|
||||||
|
millis = 0;
|
||||||
} else {
|
} else {
|
||||||
millis = Long.parseLong(sValue);
|
// Missing units:
|
||||||
|
throw new ElasticsearchParseException("Failed to parse setting [" + settingName + "] with value [" + sValue + "] as a time value: unit is missing or unrecognized");
|
||||||
}
|
}
|
||||||
return new TimeValue(millis, TimeUnit.MILLISECONDS);
|
return new TimeValue(millis, TimeUnit.MILLISECONDS);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|
|
@ -377,7 +377,7 @@ public class XContentMapValues {
|
||||||
if (node instanceof Number) {
|
if (node instanceof Number) {
|
||||||
return TimeValue.timeValueMillis(((Number) node).longValue());
|
return TimeValue.timeValueMillis(((Number) node).longValue());
|
||||||
}
|
}
|
||||||
return TimeValue.parseTimeValue(node.toString(), null);
|
return TimeValue.parseTimeValue(node.toString(), null, "XContentMapValues.nodeTimeValue");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> nodeMapValue(Object node, String desc) {
|
public static Map<String, Object> nodeMapValue(Object node, String desc) {
|
||||||
|
|
|
@ -178,7 +178,7 @@ public class TTLFieldMapper extends LongFieldMapper implements RootMapper {
|
||||||
if (context.sourceToParse().ttl() < 0) { // no ttl has been provided externally
|
if (context.sourceToParse().ttl() < 0) { // no ttl has been provided externally
|
||||||
long ttl;
|
long ttl;
|
||||||
if (context.parser().currentToken() == XContentParser.Token.VALUE_STRING) {
|
if (context.parser().currentToken() == XContentParser.Token.VALUE_STRING) {
|
||||||
ttl = TimeValue.parseTimeValue(context.parser().text(), null).millis();
|
ttl = TimeValue.parseTimeValue(context.parser().text(), null, "ttl").millis();
|
||||||
} else {
|
} else {
|
||||||
ttl = context.parser().longValue(coerce.value());
|
ttl = context.parser().longValue(coerce.value());
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,9 +269,9 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser {
|
||||||
if (scaleString == null) {
|
if (scaleString == null) {
|
||||||
throw new ElasticsearchParseException(DecayFunctionBuilder.SCALE + " must be set for date fields.");
|
throw new ElasticsearchParseException(DecayFunctionBuilder.SCALE + " must be set for date fields.");
|
||||||
}
|
}
|
||||||
TimeValue val = TimeValue.parseTimeValue(scaleString, TimeValue.timeValueHours(24));
|
TimeValue val = TimeValue.parseTimeValue(scaleString, TimeValue.timeValueHours(24), "DecayFunctionParser.scale");
|
||||||
double scale = val.getMillis();
|
double scale = val.getMillis();
|
||||||
val = TimeValue.parseTimeValue(offsetString, TimeValue.timeValueHours(24));
|
val = TimeValue.parseTimeValue(offsetString, TimeValue.timeValueHours(24), "DecayFunctionParser.offset");
|
||||||
double offset = val.getMillis();
|
double offset = val.getMillis();
|
||||||
IndexNumericFieldData numericFieldData = parseContext.getForField(dateFieldMapper);
|
IndexNumericFieldData numericFieldData = parseContext.getForField(dateFieldMapper);
|
||||||
return new NumericFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), numericFieldData, mode);
|
return new NumericFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), numericFieldData, mode);
|
||||||
|
|
|
@ -408,7 +408,7 @@ public class PluginManager {
|
||||||
case "timeout":
|
case "timeout":
|
||||||
case "-timeout":
|
case "-timeout":
|
||||||
String timeoutValue = getCommandValue(args, ++c, "--timeout");
|
String timeoutValue = getCommandValue(args, ++c, "--timeout");
|
||||||
timeout = TimeValue.parseTimeValue(timeoutValue, DEFAULT_TIMEOUT);
|
timeout = TimeValue.parseTimeValue(timeoutValue, DEFAULT_TIMEOUT, command);
|
||||||
break;
|
break;
|
||||||
case "-l":
|
case "-l":
|
||||||
case "--list":
|
case "--list":
|
||||||
|
|
|
@ -140,7 +140,7 @@ public abstract class RestRequest extends ContextAndHeaderHolder implements ToXC
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeValue paramAsTime(String key, TimeValue defaultValue) {
|
public TimeValue paramAsTime(String key, TimeValue defaultValue) {
|
||||||
return parseTimeValue(param(key), defaultValue);
|
return parseTimeValue(param(key), defaultValue, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ByteSizeValue paramAsSize(String key, ByteSizeValue defaultValue) {
|
public ByteSizeValue paramAsSize(String key, ByteSizeValue defaultValue) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class RestNodesHotThreadsAction extends BaseRestHandler {
|
||||||
nodesHotThreadsRequest.threads(request.paramAsInt("threads", nodesHotThreadsRequest.threads()));
|
nodesHotThreadsRequest.threads(request.paramAsInt("threads", nodesHotThreadsRequest.threads()));
|
||||||
nodesHotThreadsRequest.ignoreIdleThreads(request.paramAsBoolean("ignore_idle_threads", nodesHotThreadsRequest.ignoreIdleThreads()));
|
nodesHotThreadsRequest.ignoreIdleThreads(request.paramAsBoolean("ignore_idle_threads", nodesHotThreadsRequest.ignoreIdleThreads()));
|
||||||
nodesHotThreadsRequest.type(request.param("type", nodesHotThreadsRequest.type()));
|
nodesHotThreadsRequest.type(request.param("type", nodesHotThreadsRequest.type()));
|
||||||
nodesHotThreadsRequest.interval(TimeValue.parseTimeValue(request.param("interval"), nodesHotThreadsRequest.interval()));
|
nodesHotThreadsRequest.interval(TimeValue.parseTimeValue(request.param("interval"), nodesHotThreadsRequest.interval(), "interval"));
|
||||||
nodesHotThreadsRequest.snapshots(request.paramAsInt("snapshots", nodesHotThreadsRequest.snapshots()));
|
nodesHotThreadsRequest.snapshots(request.paramAsInt("snapshots", nodesHotThreadsRequest.snapshots()));
|
||||||
client.admin().cluster().nodesHotThreads(nodesHotThreadsRequest, new RestResponseListener<NodesHotThreadsResponse>(channel) {
|
client.admin().cluster().nodesHotThreads(nodesHotThreadsRequest, new RestResponseListener<NodesHotThreadsResponse>(channel) {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class RestSearchAction extends BaseRestHandler {
|
||||||
|
|
||||||
String scroll = request.param("scroll");
|
String scroll = request.param("scroll");
|
||||||
if (scroll != null) {
|
if (scroll != null) {
|
||||||
searchRequest.scroll(new Scroll(parseTimeValue(scroll, null)));
|
searchRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
|
||||||
}
|
}
|
||||||
|
|
||||||
searchRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
|
searchRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class RestSearchScrollAction extends BaseRestHandler {
|
||||||
searchScrollRequest.scrollId(scrollId);
|
searchScrollRequest.scrollId(scrollId);
|
||||||
String scroll = request.param("scroll");
|
String scroll = request.param("scroll");
|
||||||
if (scroll != null) {
|
if (scroll != null) {
|
||||||
searchScrollRequest.scroll(new Scroll(parseTimeValue(scroll, null)));
|
searchScrollRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RestActions.hasBodyContent(request)) {
|
if (RestActions.hasBodyContent(request)) {
|
||||||
|
@ -94,7 +94,7 @@ public class RestSearchScrollAction extends BaseRestHandler {
|
||||||
} else if ("scroll_id".equals(currentFieldName) && token == XContentParser.Token.VALUE_STRING) {
|
} else if ("scroll_id".equals(currentFieldName) && token == XContentParser.Token.VALUE_STRING) {
|
||||||
searchScrollRequest.scrollId(parser.text());
|
searchScrollRequest.scrollId(parser.text());
|
||||||
} else if ("scroll".equals(currentFieldName) && token == XContentParser.Token.VALUE_STRING) {
|
} else if ("scroll".equals(currentFieldName) && token == XContentParser.Token.VALUE_STRING) {
|
||||||
searchScrollRequest.scroll(new Scroll(TimeValue.parseTimeValue(parser.text(), null)));
|
searchScrollRequest.scroll(new Scroll(TimeValue.parseTimeValue(parser.text(), null, "scroll")));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unknown parameter [" + currentFieldName + "] in request body or parameter is of the wrong type[" + token + "] ");
|
throw new IllegalArgumentException("Unknown parameter [" + currentFieldName + "] in request body or parameter is of the wrong type[" + token + "] ");
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ public class DateHistogramParser implements Aggregator.Parser {
|
||||||
tzRoundingBuilder = TimeZoneRounding.builder(dateTimeUnit);
|
tzRoundingBuilder = TimeZoneRounding.builder(dateTimeUnit);
|
||||||
} else {
|
} else {
|
||||||
// the interval is a time value?
|
// the interval is a time value?
|
||||||
tzRoundingBuilder = TimeZoneRounding.builder(TimeValue.parseTimeValue(interval, null));
|
tzRoundingBuilder = TimeZoneRounding.builder(TimeValue.parseTimeValue(interval, null, "DateHistogramParser.interval"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Rounding rounding = tzRoundingBuilder
|
Rounding rounding = tzRoundingBuilder
|
||||||
|
@ -217,9 +217,9 @@ public class DateHistogramParser implements Aggregator.Parser {
|
||||||
|
|
||||||
private long parseOffset(String offset) throws IOException {
|
private long parseOffset(String offset) throws IOException {
|
||||||
if (offset.charAt(0) == '-') {
|
if (offset.charAt(0) == '-') {
|
||||||
return -TimeValue.parseTimeValue(offset.substring(1), null).millis();
|
return -TimeValue.parseTimeValue(offset.substring(1), null, "DateHistogramParser.parseOffset").millis();
|
||||||
}
|
}
|
||||||
int beginIndex = offset.charAt(0) == '+' ? 1 : 0;
|
int beginIndex = offset.charAt(0) == '+' ? 1 : 0;
|
||||||
return TimeValue.parseTimeValue(offset.substring(beginIndex), null).millis();
|
return TimeValue.parseTimeValue(offset.substring(beginIndex), null, "DateHistogramParser.parseOffset").millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class DerivativeParser implements PipelineAggregator.Parser {
|
||||||
if (dateTimeUnit != null) {
|
if (dateTimeUnit != null) {
|
||||||
xAxisUnits = dateTimeUnit.field().getDurationField().getUnitMillis();
|
xAxisUnits = dateTimeUnit.field().getDurationField().getUnitMillis();
|
||||||
} else {
|
} else {
|
||||||
TimeValue timeValue = TimeValue.parseTimeValue(units, null);
|
TimeValue timeValue = TimeValue.parseTimeValue(units, null, "DerivativeParser.units");
|
||||||
if (timeValue != null) {
|
if (timeValue != null) {
|
||||||
xAxisUnits = timeValue.getMillis();
|
xAxisUnits = timeValue.getMillis();
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,7 +315,7 @@ public class SearchSourceBuilder extends ToXContentToBytes {
|
||||||
* An optional timeout to control how long search is allowed to take.
|
* An optional timeout to control how long search is allowed to take.
|
||||||
*/
|
*/
|
||||||
public SearchSourceBuilder timeout(String timeout) {
|
public SearchSourceBuilder timeout(String timeout) {
|
||||||
this.timeoutInMillis = TimeValue.parseTimeValue(timeout, null).millis();
|
this.timeoutInMillis = TimeValue.parseTimeValue(timeout, null, "SearchSourceBuilder.timeout").millis();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class TimeoutParseElement implements SearchParseElement {
|
||||||
if (token == XContentParser.Token.VALUE_NUMBER) {
|
if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||||
context.timeoutInMillis(parser.longValue());
|
context.timeoutInMillis(parser.longValue());
|
||||||
} else {
|
} else {
|
||||||
context.timeoutInMillis(TimeValue.parseTimeValue(parser.text(), null).millis());
|
context.timeoutInMillis(TimeValue.parseTimeValue(parser.text(), null, "timeout").millis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class FuzzinessTests extends ElasticsearchTestCase {
|
||||||
assertThat(parser.nextToken(), equalTo(XContentParser.Token.FIELD_NAME));
|
assertThat(parser.nextToken(), equalTo(XContentParser.Token.FIELD_NAME));
|
||||||
assertThat(parser.nextToken(), equalTo(XContentParser.Token.VALUE_STRING));
|
assertThat(parser.nextToken(), equalTo(XContentParser.Token.VALUE_STRING));
|
||||||
Fuzziness parse = Fuzziness.parse(parser);
|
Fuzziness parse = Fuzziness.parse(parser);
|
||||||
assertThat(parse.asTimeValue(), equalTo(TimeValue.parseTimeValue(actual, null)));
|
assertThat(parse.asTimeValue(), equalTo(TimeValue.parseTimeValue(actual, null, "fuzziness")));
|
||||||
assertThat(parser.nextToken(), equalTo(XContentParser.Token.END_OBJECT));
|
assertThat(parser.nextToken(), equalTo(XContentParser.Token.END_OBJECT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ public class FuzzinessTests extends ElasticsearchTestCase {
|
||||||
assertThat(Fuzziness.AUTO.asDouble(), equalTo(1d));
|
assertThat(Fuzziness.AUTO.asDouble(), equalTo(1d));
|
||||||
assertThat(Fuzziness.AUTO.asLong(), equalTo(1l));
|
assertThat(Fuzziness.AUTO.asLong(), equalTo(1l));
|
||||||
assertThat(Fuzziness.AUTO.asShort(), equalTo((short) 1));
|
assertThat(Fuzziness.AUTO.asShort(), equalTo((short) 1));
|
||||||
assertThat(Fuzziness.AUTO.asTimeValue(), equalTo(TimeValue.parseTimeValue("1", TimeValue.timeValueMillis(1))));
|
assertThat(Fuzziness.AUTO.asTimeValue(), equalTo(TimeValue.parseTimeValue("1", TimeValue.timeValueMillis(1), "fuzziness")));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -499,7 +499,7 @@ public class SearchScrollTests extends ElasticsearchIntegrationTest {
|
||||||
RestSearchScrollAction.buildFromContent(content, searchScrollRequest);
|
RestSearchScrollAction.buildFromContent(content, searchScrollRequest);
|
||||||
|
|
||||||
assertThat(searchScrollRequest.scrollId(), equalTo("SCROLL_ID"));
|
assertThat(searchScrollRequest.scrollId(), equalTo("SCROLL_ID"));
|
||||||
assertThat(searchScrollRequest.scroll().keepAlive(), equalTo(TimeValue.parseTimeValue("1m", null)));
|
assertThat(searchScrollRequest.scroll().keepAlive(), equalTo(TimeValue.parseTimeValue("1m", null, "scroll")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class GetStressTest {
|
||||||
|
|
||||||
final int NUMBER_OF_NODES = 2;
|
final int NUMBER_OF_NODES = 2;
|
||||||
final int NUMBER_OF_THREADS = 50;
|
final int NUMBER_OF_THREADS = 50;
|
||||||
final TimeValue TEST_TIME = TimeValue.parseTimeValue("10m", null);
|
final TimeValue TEST_TIME = TimeValue.parseTimeValue("10m", null, "TEST_TIME");
|
||||||
|
|
||||||
Node[] nodes = new Node[NUMBER_OF_NODES];
|
Node[] nodes = new Node[NUMBER_OF_NODES];
|
||||||
for (int i = 0; i < nodes.length; i++) {
|
for (int i = 0; i < nodes.length; i++) {
|
||||||
|
@ -94,4 +94,4 @@ public class GetStressTest {
|
||||||
System.out.println("test done.");
|
System.out.println("test done.");
|
||||||
done.set(true);
|
done.set(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -491,7 +491,7 @@ public abstract class AbstractSimpleTransportTests extends ElasticsearchTestCase
|
||||||
serviceA.registerRequestHandler("sayHelloTimeoutDelayedResponse", StringMessageRequest.class, ThreadPool.Names.GENERIC, new TransportRequestHandler<StringMessageRequest>() {
|
serviceA.registerRequestHandler("sayHelloTimeoutDelayedResponse", StringMessageRequest.class, ThreadPool.Names.GENERIC, new TransportRequestHandler<StringMessageRequest>() {
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(StringMessageRequest request, TransportChannel channel) {
|
public void messageReceived(StringMessageRequest request, TransportChannel channel) {
|
||||||
TimeValue sleep = TimeValue.parseTimeValue(request.message, null);
|
TimeValue sleep = TimeValue.parseTimeValue(request.message, null, "sleep");
|
||||||
try {
|
try {
|
||||||
Thread.sleep(sleep.millis());
|
Thread.sleep(sleep.millis());
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
Loading…
Reference in New Issue