From issues-return-4077-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Thu Jan 17 21:37:47 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 26266180663 for ; Thu, 17 Jan 2019 21:37:46 +0100 (CET) Received: (qmail 80979 invoked by uid 500); 17 Jan 2019 20:37:46 -0000 Mailing-List: contact issues-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list issues@phoenix.apache.org Received: (qmail 80970 invoked by uid 99); 17 Jan 2019 20:37:46 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jan 2019 20:37:46 +0000 From: GitBox To: issues@phoenix.apache.org Subject: [GitHub] BinShi-SecularBird commented on a change in pull request #425: PHOENIX-5069 Use asynchronous refresh to provide non-blocking Phoenix Stats Client Cache Message-ID: <154775746575.13561.1221232025903150433.gitbox@gitbox.apache.org> Date: Thu, 17 Jan 2019 20:37:45 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 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: users@infra.apache.org With regards, Apache Git Services