From ed56a40e46f493aed426f13152270c73a281b11d Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Tue, 31 Aug 2021 09:39:21 -0700 Subject: [PATCH] HBASE-25588 Excessive logging of "hbase.zookeeper.useMulti is deprecated. Default to true always." (#3640) Signed-off-by: Viraj Jasani Reviewed-by: Duo Zhang --- .../apache/hadoop/hbase/zookeeper/ZKUtil.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java index d124a9a961e..e3337f55687 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java @@ -1760,6 +1760,12 @@ public final class ZKUtil { } } + // Static boolean for warning about useMulti because ideally there will be one warning per + // process instance. It is fine if two threads end up racing on this for a bit. We do not + // need to use an atomic type for this, that is overkill. The goal of reducing the number of + // warnings from many to one or a few at startup is still achieved. + private static boolean useMultiWarn = true; + /** * Use ZooKeeper's multi-update functionality. * @@ -1780,14 +1786,16 @@ public final class ZKUtil { * @throws KeeperException if a ZooKeeper operation fails */ public static void multiOrSequential(ZKWatcher zkw, List ops, - boolean runSequentialOnMultiFailure) throws KeeperException { - if (zkw.getConfiguration().get("hbase.zookeeper.useMulti") != null) { - LOG.warn("hbase.zookeeper.useMulti is deprecated. Default to true always."); - } + boolean runSequentialOnMultiFailure) throws KeeperException { if (ops == null) { return; } - + if (useMultiWarn) { // Only check and warn at first use + if (zkw.getConfiguration().get("hbase.zookeeper.useMulti") != null) { + LOG.warn("hbase.zookeeper.useMulti is deprecated. Default to true always."); + } + useMultiWarn = false; + } List zkOps = new LinkedList<>(); for (ZKUtilOp op : ops) { zkOps.add(toZooKeeperOp(zkw, op));