Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.3 169270daa -> 8cd7898a1


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/8cd7898a
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/8cd7898a
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/8cd7898a

Branch: refs/heads/4.x-HBase-1.3
Commit: 8cd7898a1acf1368a05a2e893253cecc53416080
Parents: 169270d
Author: Ankit Singhal <ankitsingha...@gmail.com>
Authored: Tue Nov 13 11:39:58 2018 -0800
Committer: Ankit Singhal <ankitsingha...@gmail.com>
Committed: Tue Nov 13 11:39:58 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/8cd7898a/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.
      */

Reply via email to