diff --git a/client/src/main/java/com/metamx/druid/client/CachingClusteredClient.java b/client/src/main/java/com/metamx/druid/client/CachingClusteredClient.java index a30e660be22..e2d79ce3816 100644 --- a/client/src/main/java/com/metamx/druid/client/CachingClusteredClient.java +++ b/client/src/main/java/com/metamx/druid/client/CachingClusteredClient.java @@ -124,13 +124,20 @@ public class CachingClusteredClient implements QueryRunner final boolean populateCache = Boolean.parseBoolean(query.getContextValue("populateCache", "true")) && strategy != null; final boolean isBySegment = Boolean.parseBoolean(query.getContextValue("bySegment", "false")); - final String priority = query.getContextValue("priority", Integer.toString(Queries.Priority.NORMAL.ordinal())); + final String priority = query.getContextValue("priority", Queries.Priority.NORMAL.name()); final Query prioritizedQuery = query.withOverriddenContext(ImmutableMap.of("priority", priority)); final Query rewrittenQuery; if (populateCache) { - rewrittenQuery = prioritizedQuery.withOverriddenContext(ImmutableMap.of("bySegment", "true", "intermediate", "true")); + rewrittenQuery = prioritizedQuery.withOverriddenContext( + ImmutableMap.of( + "bySegment", + "true", + "intermediate", + "true" + ) + ); } else { rewrittenQuery = prioritizedQuery.withOverriddenContext(ImmutableMap.of("intermediate", "true")); } diff --git a/client/src/main/java/com/metamx/druid/query/ChainedExecutionQueryRunner.java b/client/src/main/java/com/metamx/druid/query/ChainedExecutionQueryRunner.java index 413d533d696..e3c7962ced0 100644 --- a/client/src/main/java/com/metamx/druid/query/ChainedExecutionQueryRunner.java +++ b/client/src/main/java/com/metamx/druid/query/ChainedExecutionQueryRunner.java @@ -24,7 +24,6 @@ import com.google.common.base.Throwables; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Ordering; -import com.google.common.primitives.Ints; import com.metamx.common.guava.BaseSequence; import com.metamx.common.guava.MergeIterable; import com.metamx.common.guava.Sequence; @@ -35,7 +34,6 @@ import com.metamx.druid.Query; import java.util.Arrays; import java.util.Iterator; import java.util.List; -import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; @@ -105,12 +103,12 @@ public class ChainedExecutionQueryRunner implements QueryRunner @Override public int getPriority() { - return Ints.tryParse( + return Queries.Priority.valueOf( query.getContextValue( "priority", - Integer.toString(Queries.Priority.NORMAL.ordinal()) + Queries.Priority.NORMAL.name() ) - ); + ).ordinal(); } @Override diff --git a/client/src/main/java/com/metamx/druid/query/PriorityExecutorService.java b/client/src/main/java/com/metamx/druid/query/PriorityExecutorService.java index b2485e43e7c..44cf6bcb24f 100644 --- a/client/src/main/java/com/metamx/druid/query/PriorityExecutorService.java +++ b/client/src/main/java/com/metamx/druid/query/PriorityExecutorService.java @@ -116,9 +116,26 @@ public class PriorityExecutorService extends AbstractExecutorService } @Override - protected RunnableFuture newTaskFor(Callable tCallable) + protected RunnableFuture newTaskFor(final Callable tCallable) { - return new PrioritizedFuture((PrioritizedCallable) tCallable); + Callable theCallable = tCallable; + if (!(tCallable instanceof PrioritizedCallable)) { + theCallable = new PrioritizedCallable() + { + @Override + public int getPriority() + { + return Queries.Priority.NORMAL.ordinal(); + } + + @Override + public T call() throws Exception + { + return tCallable.call(); + } + }; + } + return new PrioritizedFuture((PrioritizedCallable) theCallable); } private static class PrioritizedFuture extends FutureTask implements Comparable