mirror of https://github.com/apache/druid.git
Merge pull request #1414 from metamx/timeout2TIMEOUT
Replace "timeout" with QueryContextKeys.TIMEOUT
This commit is contained in:
commit
92d7316ed8
|
@ -153,7 +153,7 @@ public class ChainedExecutionQueryRunner<T> implements QueryRunner<T>
|
||||||
queryWatcher.registerQuery(query, futures);
|
queryWatcher.registerQuery(query, futures);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Number timeout = query.getContextValue("timeout", (Number) null);
|
final Number timeout = query.getContextValue(QueryContextKeys.TIMEOUT, (Number) null);
|
||||||
return new MergeIterable<>(
|
return new MergeIterable<>(
|
||||||
ordering.nullsFirst(),
|
ordering.nullsFirst(),
|
||||||
timeout == null ?
|
timeout == null ?
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class GroupByParallelQueryRunner<T> implements QueryRunner<T>
|
||||||
// Let the runners complete
|
// Let the runners complete
|
||||||
try {
|
try {
|
||||||
queryWatcher.registerQuery(query, futures);
|
queryWatcher.registerQuery(query, futures);
|
||||||
final Number timeout = query.getContextValue("timeout", (Number) null);
|
final Number timeout = query.getContextValue(QueryContextKeys.TIMEOUT, (Number) null);
|
||||||
if (timeout == null) {
|
if (timeout == null) {
|
||||||
futures.get();
|
futures.get();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -37,6 +37,7 @@ import io.druid.query.AbstractPrioritizedCallable;
|
||||||
import io.druid.query.ConcatQueryRunner;
|
import io.druid.query.ConcatQueryRunner;
|
||||||
import io.druid.query.GroupByParallelQueryRunner;
|
import io.druid.query.GroupByParallelQueryRunner;
|
||||||
import io.druid.query.Query;
|
import io.druid.query.Query;
|
||||||
|
import io.druid.query.QueryContextKeys;
|
||||||
import io.druid.query.QueryInterruptedException;
|
import io.druid.query.QueryInterruptedException;
|
||||||
import io.druid.query.QueryRunner;
|
import io.druid.query.QueryRunner;
|
||||||
import io.druid.query.QueryRunnerFactory;
|
import io.druid.query.QueryRunnerFactory;
|
||||||
|
@ -143,7 +144,7 @@ public class GroupByQueryRunnerFactory implements QueryRunnerFactory<Row, GroupB
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
queryWatcher.registerQuery(query, future);
|
queryWatcher.registerQuery(query, future);
|
||||||
final Number timeout = query.getContextValue("timeout", (Number) null);
|
final Number timeout = query.getContextValue(QueryContextKeys.TIMEOUT, (Number) null);
|
||||||
if (timeout == null) {
|
if (timeout == null) {
|
||||||
future.get();
|
future.get();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import com.metamx.common.logger.Logger;
|
||||||
import io.druid.query.AbstractPrioritizedCallable;
|
import io.druid.query.AbstractPrioritizedCallable;
|
||||||
import io.druid.query.ConcatQueryRunner;
|
import io.druid.query.ConcatQueryRunner;
|
||||||
import io.druid.query.Query;
|
import io.druid.query.Query;
|
||||||
|
import io.druid.query.QueryContextKeys;
|
||||||
import io.druid.query.QueryInterruptedException;
|
import io.druid.query.QueryInterruptedException;
|
||||||
import io.druid.query.QueryRunner;
|
import io.druid.query.QueryRunner;
|
||||||
import io.druid.query.QueryRunnerFactory;
|
import io.druid.query.QueryRunnerFactory;
|
||||||
|
@ -155,7 +156,7 @@ public class SegmentMetadataQueryRunnerFactory implements QueryRunnerFactory<Seg
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
queryWatcher.registerQuery(query, future);
|
queryWatcher.registerQuery(query, future);
|
||||||
final Number timeout = query.getContextValue("timeout", (Number) null);
|
final Number timeout = query.getContextValue(QueryContextKeys.TIMEOUT, (Number) null);
|
||||||
return timeout == null ? future.get() : future.get(timeout.longValue(), TimeUnit.MILLISECONDS);
|
return timeout == null ? future.get() : future.get(timeout.longValue(), TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
catch (InterruptedException e) {
|
catch (InterruptedException e) {
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class AsyncQueryRunnerTest
|
||||||
QueryRunnerTestHelper.NOOP_QUERYWATCHER);
|
QueryRunnerTestHelper.NOOP_QUERYWATCHER);
|
||||||
|
|
||||||
Sequence lazy = asyncRunner.run(
|
Sequence lazy = asyncRunner.run(
|
||||||
query.withOverriddenContext(ImmutableMap.<String,Object>of("timeout", 1)),
|
query.withOverriddenContext(ImmutableMap.<String,Object>of(QueryContextKeys.TIMEOUT, 1)),
|
||||||
Collections.EMPTY_MAP);
|
Collections.EMPTY_MAP);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -253,7 +253,7 @@ public class ChainedExecutionQueryRunnerTest
|
||||||
.dataSource("test")
|
.dataSource("test")
|
||||||
.intervals("2014/2015")
|
.intervals("2014/2015")
|
||||||
.aggregators(Lists.<AggregatorFactory>newArrayList(new CountAggregatorFactory("count")))
|
.aggregators(Lists.<AggregatorFactory>newArrayList(new CountAggregatorFactory("count")))
|
||||||
.context(ImmutableMap.<String, Object>of("timeout", 100, "queryId", "test"))
|
.context(ImmutableMap.<String, Object>of(QueryContextKeys.TIMEOUT, 100, "queryId", "test"))
|
||||||
.build(),
|
.build(),
|
||||||
context
|
context
|
||||||
);
|
);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import com.metamx.emitter.service.ServiceEmitter;
|
||||||
import io.druid.guice.annotations.Json;
|
import io.druid.guice.annotations.Json;
|
||||||
import io.druid.guice.annotations.Smile;
|
import io.druid.guice.annotations.Smile;
|
||||||
import io.druid.query.Query;
|
import io.druid.query.Query;
|
||||||
|
import io.druid.query.QueryContextKeys;
|
||||||
import io.druid.query.QueryInterruptedException;
|
import io.druid.query.QueryInterruptedException;
|
||||||
import io.druid.query.DruidMetrics;
|
import io.druid.query.DruidMetrics;
|
||||||
import io.druid.query.QuerySegmentWalker;
|
import io.druid.query.QuerySegmentWalker;
|
||||||
|
@ -136,10 +137,10 @@ public class QueryResource
|
||||||
queryId = UUID.randomUUID().toString();
|
queryId = UUID.randomUUID().toString();
|
||||||
query = query.withId(queryId);
|
query = query.withId(queryId);
|
||||||
}
|
}
|
||||||
if (query.getContextValue("timeout") == null) {
|
if (query.getContextValue(QueryContextKeys.TIMEOUT) == null) {
|
||||||
query = query.withOverriddenContext(
|
query = query.withOverriddenContext(
|
||||||
ImmutableMap.of(
|
ImmutableMap.of(
|
||||||
"timeout",
|
QueryContextKeys.TIMEOUT,
|
||||||
config.getMaxIdleTime().toStandardDuration().getMillis()
|
config.getMaxIdleTime().toStandardDuration().getMillis()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue