diff --git a/server/src/main/java/io/druid/client/CachePopulatingQueryRunner.java b/server/src/main/java/io/druid/client/CachePopulatingQueryRunner.java index 2a91ee2237b..581ebd474fb 100644 --- a/server/src/main/java/io/druid/client/CachePopulatingQueryRunner.java +++ b/server/src/main/java/io/druid/client/CachePopulatingQueryRunner.java @@ -68,7 +68,7 @@ public class CachePopulatingQueryRunner implements QueryRunner final CacheStrategy strategy = toolChest.getCacheStrategy(query); - final boolean populateCache = Boolean.parseBoolean(query.getContextValue("populateCache", "true")) + final boolean populateCache = Boolean.parseBoolean(query.getContextValue(CacheConfig.POPULATE_CACHE, "true")) && strategy != null && cacheConfig.isPopulateCache() // historical only populates distributed cache since the cache lookups are done at broker. diff --git a/server/src/main/java/io/druid/client/CachingClusteredClient.java b/server/src/main/java/io/druid/client/CachingClusteredClient.java index 82c6e51d498..65ac6bea415 100644 --- a/server/src/main/java/io/druid/client/CachingClusteredClient.java +++ b/server/src/main/java/io/druid/client/CachingClusteredClient.java @@ -62,6 +62,7 @@ import io.druid.timeline.partition.PartitionChunk; import org.joda.time.DateTime; import org.joda.time.Interval; +import javax.annotation.Nullable; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -124,10 +125,10 @@ public class CachingClusteredClient implements QueryRunner final List> cachedResults = Lists.newArrayList(); final Map cachePopulatorMap = Maps.newHashMap(); - final boolean useCache = Boolean.parseBoolean(query.getContextValue("useCache", "true")) + final boolean useCache = Boolean.parseBoolean(query.getContextValue(CacheConfig.USE_CACHE, "true")) && strategy != null && cacheConfig.isUseCache(); - final boolean populateCache = Boolean.parseBoolean(query.getContextValue("populateCache", "true")) + final boolean populateCache = Boolean.parseBoolean(query.getContextValue(CacheConfig.POPULATE_CACHE, "true")) && strategy != null && cacheConfig.isPopulateCache(); final boolean isBySegment = Boolean.parseBoolean(query.getContextValue("bySegment", "false")); @@ -138,7 +139,7 @@ public class CachingClusteredClient implements QueryRunner contextBuilder.put("priority", priority); if (populateCache) { - contextBuilder.put("populateCache", "false"); + contextBuilder.put(CacheConfig.POPULATE_CACHE, "false"); contextBuilder.put("bySegment", "true"); } contextBuilder.put("intermediate", "true"); diff --git a/server/src/main/java/io/druid/client/cache/CacheConfig.java b/server/src/main/java/io/druid/client/cache/CacheConfig.java index d8c80c7940d..817cdb4070a 100644 --- a/server/src/main/java/io/druid/client/cache/CacheConfig.java +++ b/server/src/main/java/io/druid/client/cache/CacheConfig.java @@ -21,17 +21,15 @@ package io.druid.client.cache; import com.fasterxml.jackson.annotation.JsonProperty; -import javax.validation.constraints.NotNull; - public class CacheConfig { + public static String USE_CACHE = "useCache"; + public static String POPULATE_CACHE = "populateCache"; @JsonProperty private boolean useCache = true; - @JsonProperty private boolean populateCache = true; - public boolean isPopulateCache() { return populateCache;