diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java index f373689566f..42bf3054935 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java @@ -83,7 +83,7 @@ public class ClusterHealthRequest extends MasterNodeReadOperationRequest10s. */ public DeleteIndexRequest timeout(String timeout) { - return timeout(TimeValue.parseTimeValue(timeout, null)); + return timeout(TimeValue.parseTimeValue(timeout, null, "DeleteIndexRequest.timeout")); } @Override diff --git a/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java index 617c3fc32bd..87671155c87 100644 --- a/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -308,7 +308,7 @@ public class BulkRequest extends ActionRequest implements Composite timestamp = parser.text(); } else if ("_ttl".equals(currentFieldName) || "ttl".equals(currentFieldName)) { if (parser.currentToken() == XContentParser.Token.VALUE_STRING) { - ttl = TimeValue.parseTimeValue(parser.text(), null).millis(); + ttl = TimeValue.parseTimeValue(parser.text(), null, currentFieldName).millis(); } else { ttl = parser.longValue(); } @@ -417,7 +417,7 @@ public class BulkRequest extends ActionRequest implements Composite * A timeout to wait if the index operation can't be performed immediately. Defaults to 1m. */ public final BulkRequest timeout(String timeout) { - return timeout(TimeValue.parseTimeValue(timeout, null)); + return timeout(TimeValue.parseTimeValue(timeout, null, "BulkRequest.timeout")); } public TimeValue timeout() { diff --git a/src/main/java/org/elasticsearch/action/search/SearchRequest.java b/src/main/java/org/elasticsearch/action/search/SearchRequest.java index 8e1da31affa..860167d4e19 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchRequest.java +++ b/src/main/java/org/elasticsearch/action/search/SearchRequest.java @@ -476,7 +476,7 @@ public class SearchRequest extends ActionRequest implements Indic * If set, will enable scrolling of the search request for the specified timeout. */ public SearchRequest scroll(String keepAlive) { - return scroll(new Scroll(TimeValue.parseTimeValue(keepAlive, null))); + return scroll(new Scroll(TimeValue.parseTimeValue(keepAlive, null, "SearchRequest.Scroll.keepAlive"))); } /** diff --git a/src/main/java/org/elasticsearch/action/search/SearchScrollRequest.java b/src/main/java/org/elasticsearch/action/search/SearchScrollRequest.java index 8f6e093856f..dd34d2c6926 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchScrollRequest.java +++ b/src/main/java/org/elasticsearch/action/search/SearchScrollRequest.java @@ -93,7 +93,7 @@ public class SearchScrollRequest extends ActionRequest { * If set, will enable scrolling of the search request for the specified timeout. */ public SearchScrollRequest scroll(String keepAlive) { - return scroll(new Scroll(TimeValue.parseTimeValue(keepAlive, null))); + return scroll(new Scroll(TimeValue.parseTimeValue(keepAlive, null, "SearchScrollRequest.keepAlive"))); } @Override diff --git a/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java b/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java index e1da5ee41f5..c41e7656c5c 100644 --- a/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java +++ b/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java @@ -51,7 +51,7 @@ public abstract class AdapterActionFuture extends BaseFuture implements @Override public T actionGet(String timeout) { - return actionGet(TimeValue.parseTimeValue(timeout, null)); + return actionGet(TimeValue.parseTimeValue(timeout, null, "AdapterActionFuture.actionGet.timeout")); } @Override diff --git a/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java b/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java index ea3a1e43bff..2ce420bcc0b 100644 --- a/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java +++ b/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java @@ -53,7 +53,7 @@ public abstract class AcknowledgedRequest */ @SuppressWarnings("unchecked") 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; } diff --git a/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java b/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java index e1e90e932ff..900ec7d5aa8 100644 --- a/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java +++ b/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java @@ -56,7 +56,7 @@ public abstract class MasterNodeOperationRequest ext @SuppressWarnings("unchecked") public final T timeout(String timeout) { - this.timeout = TimeValue.parseTimeValue(timeout, null); + this.timeout = TimeValue.parseTimeValue(timeout, null, "NodesOperationRequest.timeout"); return (T) this; } diff --git a/src/main/java/org/elasticsearch/action/support/replication/ShardReplicationOperationRequest.java b/src/main/java/org/elasticsearch/action/support/replication/ShardReplicationOperationRequest.java index 0d9730c246a..f4e2b1a6f10 100644 --- a/src/main/java/org/elasticsearch/action/support/replication/ShardReplicationOperationRequest.java +++ b/src/main/java/org/elasticsearch/action/support/replication/ShardReplicationOperationRequest.java @@ -121,7 +121,7 @@ public abstract class ShardReplicationOperationRequest1m. */ public final T timeout(String timeout) { - return timeout(TimeValue.parseTimeValue(timeout, null)); + return timeout(TimeValue.parseTimeValue(timeout, null, "ShardReplicatoinOperationRequest.timeout")); } public TimeValue timeout() { diff --git a/src/main/java/org/elasticsearch/action/support/single/instance/InstanceShardOperationRequest.java b/src/main/java/org/elasticsearch/action/support/single/instance/InstanceShardOperationRequest.java index 80de5a59b62..032bf4a07e9 100644 --- a/src/main/java/org/elasticsearch/action/support/single/instance/InstanceShardOperationRequest.java +++ b/src/main/java/org/elasticsearch/action/support/single/instance/InstanceShardOperationRequest.java @@ -97,7 +97,7 @@ public abstract class InstanceShardOperationRequest1m. */ public final T timeout(String timeout) { - return timeout(TimeValue.parseTimeValue(timeout, null)); + return timeout(TimeValue.parseTimeValue(timeout, null, "InstanceShardOperationRequest.timeout")); } @Override diff --git a/src/main/java/org/elasticsearch/action/update/UpdateHelper.java b/src/main/java/org/elasticsearch/action/update/UpdateHelper.java index ef8144fc095..c101df8135c 100644 --- a/src/main/java/org/elasticsearch/action/update/UpdateHelper.java +++ b/src/main/java/org/elasticsearch/action/update/UpdateHelper.java @@ -259,7 +259,7 @@ public class UpdateHelper extends AbstractComponent { if (fetchedTTL instanceof Number) { ttl = ((Number) fetchedTTL).longValue(); } else { - ttl = TimeValue.parseTimeValue((String) fetchedTTL, null).millis(); + ttl = TimeValue.parseTimeValue((String) fetchedTTL, null, "_ttl").millis(); } } return ttl; diff --git a/src/main/java/org/elasticsearch/cluster/settings/Validator.java b/src/main/java/org/elasticsearch/cluster/settings/Validator.java index 92c1427a160..ec3e8ea7129 100644 --- a/src/main/java/org/elasticsearch/cluster/settings/Validator.java +++ b/src/main/java/org/elasticsearch/cluster/settings/Validator.java @@ -45,7 +45,7 @@ public interface Validator { @Override public String validate(String setting, String value) { try { - if (TimeValue.parseTimeValue(value, null) == null) { + if (TimeValue.parseTimeValue(value, null, setting) == null) { return "cannot parse value [" + value + "] as time"; } } catch (ElasticsearchParseException ex) { @@ -59,7 +59,7 @@ public interface Validator { @Override public String validate(String setting, String value) { try { - TimeValue timeValue = TimeValue.parseTimeValue(value, null); + TimeValue timeValue = TimeValue.parseTimeValue(value, null, setting); if (timeValue == null) { return "cannot parse value [" + value + "] as time"; } diff --git a/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java b/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java index 8738d30e774..0a7e9e14329 100644 --- a/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java +++ b/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java @@ -357,12 +357,19 @@ public class ImmutableSettings implements Settings { @Override public TimeValue getAsTime(String setting, TimeValue defaultValue) { - return parseTimeValue(get(setting), defaultValue); + return parseTimeValue(get(setting), defaultValue, setting); } @Override 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 diff --git a/src/main/java/org/elasticsearch/common/unit/Fuzziness.java b/src/main/java/org/elasticsearch/common/unit/Fuzziness.java index a4ac1fda851..30b959d25b6 100644 --- a/src/main/java/org/elasticsearch/common/unit/Fuzziness.java +++ b/src/main/java/org/elasticsearch/common/unit/Fuzziness.java @@ -152,7 +152,7 @@ public final class Fuzziness implements ToXContent { if (this == AUTO) { return TimeValue.timeValueMillis(1); } else { - return TimeValue.parseTimeValue(fuzziness.toString(), null); + return TimeValue.parseTimeValue(fuzziness.toString(), null, "fuzziness"); } } diff --git a/src/main/java/org/elasticsearch/common/unit/TimeValue.java b/src/main/java/org/elasticsearch/common/unit/TimeValue.java index a7037b4e90c..3883e021cc1 100644 --- a/src/main/java/org/elasticsearch/common/unit/TimeValue.java +++ b/src/main/java/org/elasticsearch/common/unit/TimeValue.java @@ -31,11 +31,9 @@ import org.joda.time.format.PeriodFormatter; import java.io.IOException; import java.io.Serializable; +import java.util.Objects; import java.util.concurrent.TimeUnit; -/** - * - */ public class TimeValue implements Serializable, Streamable { /** How many nano-seconds in one milli-second */ @@ -228,7 +226,8 @@ public class TimeValue implements Serializable, Streamable { 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) { 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); } else if (sValue.endsWith("w")) { 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 { - 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); } catch (NumberFormatException e) { diff --git a/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java b/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java index 3a69f911fa0..b85e999a2f2 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java +++ b/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java @@ -377,7 +377,7 @@ public class XContentMapValues { if (node instanceof Number) { return TimeValue.timeValueMillis(((Number) node).longValue()); } - return TimeValue.parseTimeValue(node.toString(), null); + return TimeValue.parseTimeValue(node.toString(), null, "XContentMapValues.nodeTimeValue"); } public static Map nodeMapValue(Object node, String desc) { diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java index 8e817ddd903..278a7f5cd65 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java @@ -178,7 +178,7 @@ public class TTLFieldMapper extends LongFieldMapper implements RootMapper { if (context.sourceToParse().ttl() < 0) { // no ttl has been provided externally long ttl; 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 { ttl = context.parser().longValue(coerce.value()); } diff --git a/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java b/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java index 375920a7fb0..c96f2b89737 100644 --- a/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java +++ b/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java @@ -269,9 +269,9 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser { if (scaleString == null) { 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(); - val = TimeValue.parseTimeValue(offsetString, TimeValue.timeValueHours(24)); + val = TimeValue.parseTimeValue(offsetString, TimeValue.timeValueHours(24), "DecayFunctionParser.offset"); double offset = val.getMillis(); IndexNumericFieldData numericFieldData = parseContext.getForField(dateFieldMapper); return new NumericFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), numericFieldData, mode); diff --git a/src/main/java/org/elasticsearch/plugins/PluginManager.java b/src/main/java/org/elasticsearch/plugins/PluginManager.java index cee8fde738e..a48a7c4845e 100644 --- a/src/main/java/org/elasticsearch/plugins/PluginManager.java +++ b/src/main/java/org/elasticsearch/plugins/PluginManager.java @@ -408,7 +408,7 @@ public class PluginManager { case "timeout": case "-timeout": String timeoutValue = getCommandValue(args, ++c, "--timeout"); - timeout = TimeValue.parseTimeValue(timeoutValue, DEFAULT_TIMEOUT); + timeout = TimeValue.parseTimeValue(timeoutValue, DEFAULT_TIMEOUT, command); break; case "-l": case "--list": diff --git a/src/main/java/org/elasticsearch/rest/RestRequest.java b/src/main/java/org/elasticsearch/rest/RestRequest.java index 113bfabe4ff..4ccb1a6161f 100644 --- a/src/main/java/org/elasticsearch/rest/RestRequest.java +++ b/src/main/java/org/elasticsearch/rest/RestRequest.java @@ -140,7 +140,7 @@ public abstract class RestRequest extends ContextAndHeaderHolder implements ToXC } 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) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/hotthreads/RestNodesHotThreadsAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/hotthreads/RestNodesHotThreadsAction.java index 7c8a970d92c..5e374079e37 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/hotthreads/RestNodesHotThreadsAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/hotthreads/RestNodesHotThreadsAction.java @@ -56,7 +56,7 @@ public class RestNodesHotThreadsAction extends BaseRestHandler { nodesHotThreadsRequest.threads(request.paramAsInt("threads", nodesHotThreadsRequest.threads())); nodesHotThreadsRequest.ignoreIdleThreads(request.paramAsBoolean("ignore_idle_threads", nodesHotThreadsRequest.ignoreIdleThreads())); 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())); client.admin().cluster().nodesHotThreads(nodesHotThreadsRequest, new RestResponseListener(channel) { @Override diff --git a/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java b/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java index 0d06031a92e..4aa8b292bc0 100644 --- a/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java +++ b/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java @@ -113,7 +113,7 @@ public class RestSearchAction extends BaseRestHandler { String scroll = request.param("scroll"); 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"))); diff --git a/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java b/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java index c53331bb496..6fb72931804 100644 --- a/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java +++ b/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java @@ -63,7 +63,7 @@ public class RestSearchScrollAction extends BaseRestHandler { searchScrollRequest.scrollId(scrollId); String scroll = request.param("scroll"); if (scroll != null) { - searchScrollRequest.scroll(new Scroll(parseTimeValue(scroll, null))); + searchScrollRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll"))); } if (RestActions.hasBodyContent(request)) { @@ -94,7 +94,7 @@ public class RestSearchScrollAction extends BaseRestHandler { } else if ("scroll_id".equals(currentFieldName) && token == XContentParser.Token.VALUE_STRING) { searchScrollRequest.scrollId(parser.text()); } 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 { throw new IllegalArgumentException("Unknown parameter [" + currentFieldName + "] in request body or parameter is of the wrong type[" + token + "] "); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramParser.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramParser.java index aaae94dfe1a..e85bdd1a9c8 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramParser.java @@ -189,7 +189,7 @@ public class DateHistogramParser implements Aggregator.Parser { tzRoundingBuilder = TimeZoneRounding.builder(dateTimeUnit); } else { // 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 @@ -217,9 +217,9 @@ public class DateHistogramParser implements Aggregator.Parser { private long parseOffset(String offset) throws IOException { 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; - return TimeValue.parseTimeValue(offset.substring(beginIndex), null).millis(); + return TimeValue.parseTimeValue(offset.substring(beginIndex), null, "DateHistogramParser.parseOffset").millis(); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeParser.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeParser.java index 27da830c3b9..46b10162033 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeParser.java @@ -106,7 +106,7 @@ public class DerivativeParser implements PipelineAggregator.Parser { if (dateTimeUnit != null) { xAxisUnits = dateTimeUnit.field().getDurationField().getUnitMillis(); } else { - TimeValue timeValue = TimeValue.parseTimeValue(units, null); + TimeValue timeValue = TimeValue.parseTimeValue(units, null, "DerivativeParser.units"); if (timeValue != null) { xAxisUnits = timeValue.getMillis(); } diff --git a/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 57dfe4a362b..9cd3be11b1c 100644 --- a/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -315,7 +315,7 @@ public class SearchSourceBuilder extends ToXContentToBytes { * An optional timeout to control how long search is allowed to take. */ public SearchSourceBuilder timeout(String timeout) { - this.timeoutInMillis = TimeValue.parseTimeValue(timeout, null).millis(); + this.timeoutInMillis = TimeValue.parseTimeValue(timeout, null, "SearchSourceBuilder.timeout").millis(); return this; } diff --git a/src/main/java/org/elasticsearch/search/query/TimeoutParseElement.java b/src/main/java/org/elasticsearch/search/query/TimeoutParseElement.java index d5b04206c4b..d57f5362a25 100644 --- a/src/main/java/org/elasticsearch/search/query/TimeoutParseElement.java +++ b/src/main/java/org/elasticsearch/search/query/TimeoutParseElement.java @@ -34,7 +34,7 @@ public class TimeoutParseElement implements SearchParseElement { if (token == XContentParser.Token.VALUE_NUMBER) { context.timeoutInMillis(parser.longValue()); } else { - context.timeoutInMillis(TimeValue.parseTimeValue(parser.text(), null).millis()); + context.timeoutInMillis(TimeValue.parseTimeValue(parser.text(), null, "timeout").millis()); } } } diff --git a/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java b/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java index e5999c69baf..e09827d9fc8 100644 --- a/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java +++ b/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java @@ -132,7 +132,7 @@ public class FuzzinessTests extends ElasticsearchTestCase { assertThat(parser.nextToken(), equalTo(XContentParser.Token.FIELD_NAME)); assertThat(parser.nextToken(), equalTo(XContentParser.Token.VALUE_STRING)); 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)); } } @@ -159,7 +159,7 @@ public class FuzzinessTests extends ElasticsearchTestCase { assertThat(Fuzziness.AUTO.asDouble(), equalTo(1d)); assertThat(Fuzziness.AUTO.asLong(), equalTo(1l)); 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"))); } diff --git a/src/test/java/org/elasticsearch/search/scroll/SearchScrollTests.java b/src/test/java/org/elasticsearch/search/scroll/SearchScrollTests.java index 21dd1f3a1f8..538ea0516dc 100644 --- a/src/test/java/org/elasticsearch/search/scroll/SearchScrollTests.java +++ b/src/test/java/org/elasticsearch/search/scroll/SearchScrollTests.java @@ -499,7 +499,7 @@ public class SearchScrollTests extends ElasticsearchIntegrationTest { RestSearchScrollAction.buildFromContent(content, searchScrollRequest); 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 diff --git a/src/test/java/org/elasticsearch/stresstest/get/GetStressTest.java b/src/test/java/org/elasticsearch/stresstest/get/GetStressTest.java index 3e4c269a4c0..8fb23a72a9a 100644 --- a/src/test/java/org/elasticsearch/stresstest/get/GetStressTest.java +++ b/src/test/java/org/elasticsearch/stresstest/get/GetStressTest.java @@ -40,7 +40,7 @@ public class GetStressTest { final int NUMBER_OF_NODES = 2; 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]; for (int i = 0; i < nodes.length; i++) { @@ -94,4 +94,4 @@ public class GetStressTest { System.out.println("test done."); done.set(true); } -} \ No newline at end of file +} diff --git a/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java b/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java index 09bdd79c70a..85bc97d2f1a 100644 --- a/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java +++ b/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java @@ -491,7 +491,7 @@ public abstract class AbstractSimpleTransportTests extends ElasticsearchTestCase serviceA.registerRequestHandler("sayHelloTimeoutDelayedResponse", StringMessageRequest.class, ThreadPool.Names.GENERIC, new TransportRequestHandler() { @Override public void messageReceived(StringMessageRequest request, TransportChannel channel) { - TimeValue sleep = TimeValue.parseTimeValue(request.message, null); + TimeValue sleep = TimeValue.parseTimeValue(request.message, null, "sleep"); try { Thread.sleep(sleep.millis()); } catch (InterruptedException e) {