From 1f9e5a1f7c641b23e97aa1cd39fdb089759359c9 Mon Sep 17 00:00:00 2001 From: Bryan Beaudreault Date: Thu, 10 Mar 2022 13:09:51 -0500 Subject: [PATCH] HBASE-26814 Addendum: Fix spotbugs warning and clarify intent (#4201) Signed-off-by: Nick Dimiduk Signed-off-by: Andrew Purtell --- .../throttle/StoreHotnessProtector.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/throttle/StoreHotnessProtector.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/throttle/StoreHotnessProtector.java index b48ac3a0a887..5a470976da79 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/throttle/StoreHotnessProtector.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/throttle/StoreHotnessProtector.java @@ -62,7 +62,6 @@ public class StoreHotnessProtector { private static final Logger LOG = LoggerFactory.getLogger(StoreHotnessProtector.class); - // We want to log just once so that users are aware of this tool private static volatile boolean loggedDisableMessage; private volatile int parallelPutToStoreThreadLimit; @@ -97,12 +96,23 @@ public void init(Configuration conf) { conf.getInt(PARALLEL_PUT_STORE_THREADS_LIMIT_MIN_COLUMN_COUNT, DEFAULT_PARALLEL_PUT_STORE_THREADS_LIMIT_MIN_COLUMN_NUM); - if (!isEnable() && !loggedDisableMessage) { - loggedDisableMessage = true; + if (!isEnable()) { + logDisabledMessageOnce(); + } + } + /** + * {@link #init(Configuration)} is called for every Store that opens on a RegionServer. + * Here we make a lightweight attempt to log this message once per RegionServer, rather than + * per-Store. The goal is just to draw attention to this feature if debugging overload due to + * heavy writes. + */ + private static void logDisabledMessageOnce() { + if (!loggedDisableMessage) { LOG.info("StoreHotnessProtector is disabled. Set {} > 0 to enable, " + "which may help mitigate load under heavy write pressure.", PARALLEL_PUT_STORE_THREADS_LIMIT); + loggedDisableMessage = true; } }