BinShi-SecularBird commented on a change in pull request #425: PHOENIX-5069 Use 
asynchronous refresh to provide non-blocking Phoenix Stats Client Cache
URL: https://github.com/apache/phoenix/pull/425#discussion_r248831680
 
 

 ##########
 File path: 
phoenix-core/src/main/java/org/apache/phoenix/query/GuidePostsCache.java
 ##########
 @@ -59,22 +59,43 @@
 
     private final ConnectionQueryServices queryServices;
     private final LoadingCache<GuidePostsKey, GuidePostsInfo> cache;
+    private ExecutorService executor = null;
 
     public GuidePostsCache(ConnectionQueryServices queryServices, 
Configuration config) {
         this.queryServices = Objects.requireNonNull(queryServices);
+
         // Number of millis to expire cache values after write
         final long statsUpdateFrequency = config.getLong(
                 QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB,
                 QueryServicesOptions.DEFAULT_STATS_UPDATE_FREQ_MS);
-        // Maximum number of entries (tables) to store in the cache at one time
+
+        // Maximum total weight (size in bytes) of stats entries
         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);
+
+        PhoenixStatsCacheLoader cacheLoader;
+
+        if (isStatsEnabled) {
+            // The size of the thread pool used for refreshing cached table 
stats
+            final int statsCacheThreadPoolSize = config.getInt(
+                    QueryServices.STATS_CACHE_THREAD_POOL_SIZE,
+                    QueryServicesOptions.DEFAULT_STATS_CACHE_THREAD_POOL_SIZE);
+
+            executor = Executors.newFixedThreadPool(statsCacheThreadPoolSize);
 
 Review comment:
   You're right. I'll move it to PhoenixStatsCacheLoader class. Previously, I 
wanted to trigger automatic refresh by GuidePostsCache instead of using its 
built in refresh mechanism in which automatic refreshes are performed when the 
first stale request for an entry occurs. Since I'm doing it in that way, It's 
better to move it to PhoenixStatsCacheLoader for better encapsulation and 
isolation.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to