Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.4 70a699e30 -> ce89c2c1d
PHOENIX-5010 Don't build client guidepost cache when phoenix.stats.collection.enabled is disabled Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ce89c2c1 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ce89c2c1 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ce89c2c1 Branch: refs/heads/4.x-HBase-1.4 Commit: ce89c2c1da6e9d81570b18d7b252b0cc24afbcd8 Parents: 70a699e Author: Ankit Singhal <ankitsingha...@gmail.com> Authored: Tue Nov 13 11:36:26 2018 -0800 Committer: Ankit Singhal <ankitsingha...@gmail.com> Committed: Tue Nov 13 11:37:35 2018 -0800 ---------------------------------------------------------------------- .../org/apache/phoenix/query/GuidePostsCache.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/ce89c2c1/phoenix-core/src/main/java/org/apache/phoenix/query/GuidePostsCache.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/GuidePostsCache.java b/phoenix-core/src/main/java/org/apache/phoenix/query/GuidePostsCache.java index d27be1b..1d9fa36 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/GuidePostsCache.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/GuidePostsCache.java @@ -16,6 +16,10 @@ */ package org.apache.phoenix.query; +import static org.apache.phoenix.query.QueryServices.STATS_COLLECTION_ENABLED; +import static org.apache.phoenix.query.QueryServices.STATS_ENABLED_ATTRIB; +import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_STATS_COLLECTION_ENABLED; + import java.io.IOException; import java.util.List; import java.util.Objects; @@ -66,6 +70,8 @@ public class GuidePostsCache { final long maxTableStatsCacheSize = config.getLong( QueryServices.STATS_MAX_CACHE_SIZE, QueryServicesOptions.DEFAULT_STATS_MAX_CACHE_SIZE); + final boolean isStatsEnabled = config.getBoolean(STATS_COLLECTION_ENABLED, DEFAULT_STATS_COLLECTION_ENABLED) + && config.getBoolean(STATS_ENABLED_ATTRIB, true); cache = CacheBuilder.newBuilder() // Expire entries a given amount of time after they were written .expireAfterWrite(statsUpdateFrequency, TimeUnit.MILLISECONDS) @@ -80,7 +86,7 @@ public class GuidePostsCache { // Log removals at TRACE for debugging .removalListener(new PhoenixStatsCacheRemovalListener()) // Automatically load the cache when entries are missing - .build(new StatsLoader()); + .build(isStatsEnabled ? new StatsLoader() : new EmptyStatsLoader()); } /** @@ -129,6 +135,16 @@ public class GuidePostsCache { } /** + * Empty stats loader if stats are disabled + */ + protected class EmptyStatsLoader extends CacheLoader<GuidePostsKey, GuidePostsInfo> { + @Override + public GuidePostsInfo load(GuidePostsKey statsKey) throws Exception { + return GuidePostsInfo.NO_GUIDEPOST; + } + } + + /** * Returns the underlying cache. Try to use the provided methods instead of accessing the cache * directly. */