You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ja...@apache.org on 2019/12/27 09:39:55 UTC

[hbase] branch master updated: HBASE-23619 Used built-in formatting for logger in hbase-zookeeper

This is an automated email from the ASF dual-hosted git repository.

janh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/master by this push:
     new e9b9980  HBASE-23619 Used built-in formatting for logger in hbase-zookeeper
e9b9980 is described below

commit e9b998012fa8dc800eda5da7e582bbd0e988aaad
Author: Jan Hentschel <ja...@apache.org>
AuthorDate: Fri Dec 27 10:39:46 2019 +0100

    HBASE-23619 Used built-in formatting for logger in hbase-zookeeper
    
    Signed-off-by: stack <st...@apache.org>
---
 .../apache/hadoop/hbase/zookeeper/DeletionListener.java   |  2 +-
 .../hadoop/hbase/zookeeper/LoadBalancerTracker.java       |  2 +-
 .../apache/hadoop/hbase/zookeeper/MetaTableLocator.java   |  6 +++---
 .../hadoop/hbase/zookeeper/MiniZooKeeperCluster.java      | 15 ++++++---------
 .../hadoop/hbase/zookeeper/RecoverableZooKeeper.java      | 12 +++++-------
 .../org/apache/hadoop/hbase/zookeeper/ZKAclReset.java     |  8 ++++----
 .../apache/hadoop/hbase/zookeeper/ZKLeaderManager.java    |  4 ++--
 .../org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java  |  4 ++--
 .../java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java    | 15 +++++++--------
 .../java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java | 10 +++++-----
 10 files changed, 36 insertions(+), 42 deletions(-)

diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/DeletionListener.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/DeletionListener.java
index ed8751b..0654c23 100644
--- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/DeletionListener.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/DeletionListener.java
@@ -94,7 +94,7 @@ public class DeletionListener extends ZKListener {
       return;
     }
     if (LOG.isDebugEnabled()) {
-      LOG.debug("Processing delete on " + pathToWatch);
+      LOG.debug("Processing delete on {}", pathToWatch);
     }
     deletedLatch.countDown();
   }
diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java
index 0e74483..f00dfa8 100644
--- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java
@@ -51,7 +51,7 @@ public class LoadBalancerTracker extends ZKNodeTracker {
       // if data in ZK is null, use default of on.
       return upData == null || parseFrom(upData).getBalancerOn();
     } catch (DeserializationException dex) {
-      LOG.error("ZK state for LoadBalancer could not be parsed " + Bytes.toStringBinary(upData));
+      LOG.error("ZK state for LoadBalancer could not be parsed {}", Bytes.toStringBinary(upData));
       // return false to be safe.
       return false;
     }
diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
index 0cebc76..10fd165 100644
--- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
@@ -234,7 +234,7 @@ public final class MetaTableLocator {
       LOG.warn("Tried to set null ServerName in hbase:meta; skipping -- ServerName required");
       return;
     }
-    LOG.info("Setting hbase:meta (replicaId=" + replicaId + ") location in ZooKeeper as " +
+    LOG.info("Setting hbase:meta (replicaId={}) location in ZooKeeper as {}", replicaId,
       serverName);
     // Make the MetaRegionServer pb and then get its bytes and save this as
     // the znode content.
@@ -327,7 +327,7 @@ public final class MetaTableLocator {
     if (replicaId == RegionInfo.DEFAULT_REPLICA_ID) {
       LOG.info("Deleting hbase:meta region location in ZooKeeper");
     } else {
-      LOG.info("Deleting hbase:meta for " + replicaId + " region location in ZooKeeper");
+      LOG.info("Deleting hbase:meta for {} region location in ZooKeeper", replicaId);
     }
     try {
       // Just delete the node.  Don't need any watches.
@@ -365,7 +365,7 @@ public final class MetaTableLocator {
       List<String> metaReplicaNodes = zkw.getMetaReplicaNodes();
       numReplicasConfigured = metaReplicaNodes.size();
     } catch (KeeperException e) {
-      LOG.warn("Got ZK exception " + e);
+      LOG.warn("Got ZK exception {}", e);
     }
     for (int replicaId = 1; replicaId < numReplicasConfigured; replicaId++) {
       // return all replica locations for the meta
diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java
index ac00027..70b882f 100644
--- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java
@@ -280,8 +280,8 @@ public class MiniZooKeeperCluster {
     activeZKServerIndex = 0;
     started = true;
     int clientPort = clientPortList.get(activeZKServerIndex);
-    LOG.info("Started MiniZooKeeperCluster and ran successful 'stat' " +
-        "on client port=" + clientPort);
+    LOG.info("Started MiniZooKeeperCluster and ran successful 'stat' on client port={}",
+      clientPort);
     return clientPort;
   }
 
@@ -353,16 +353,14 @@ public class MiniZooKeeperCluster {
     standaloneServerFactoryList.remove(activeZKServerIndex);
     clientPortList.remove(activeZKServerIndex);
     zooKeeperServers.remove(activeZKServerIndex);
-    LOG.info("Kill the current active ZK servers in the cluster " +
-        "on client port: " + clientPort);
+    LOG.info("Kill the current active ZK servers in the cluster on client port: {}", clientPort);
 
     if (standaloneServerFactoryList.isEmpty()) {
       // there is no backup servers;
       return -1;
     }
     clientPort = clientPortList.get(activeZKServerIndex);
-    LOG.info("Activate a backup zk server in the cluster " +
-        "on client port: " + clientPort);
+    LOG.info("Activate a backup zk server in the cluster on client port: {}", clientPort);
     // return the next back zk server's port
     return clientPort;
   }
@@ -394,8 +392,7 @@ public class MiniZooKeeperCluster {
     standaloneServerFactoryList.remove(backupZKServerIndex);
     clientPortList.remove(backupZKServerIndex);
     zooKeeperServers.remove(backupZKServerIndex);
-    LOG.info("Kill one backup ZK servers in the cluster " +
-        "on client port: " + clientPort);
+    LOG.info("Kill one backup ZK servers in the cluster on client port: {}", clientPort);
   }
 
   // XXX: From o.a.zk.t.ClientBase
@@ -450,7 +447,7 @@ public class MiniZooKeeperCluster {
         }
       } catch (IOException e) {
         // ignore as this is expected
-        LOG.info("server localhost:" + port + " not up " + e);
+        LOG.info("server localhost:{} not up {}", port, e);
       }
 
       if (System.currentTimeMillis() > start + timeout) {
diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
index 8fe18b1..f89c8fd 100644
--- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
@@ -97,8 +97,8 @@ public class RecoverableZooKeeper {
       // the identifier = processID@hostName
       identifier = ManagementFactory.getRuntimeMXBean().getName();
     }
-    LOG.info("Process identifier=" + identifier +
-      " connecting to ZooKeeper ensemble=" + quorumServers);
+    LOG.info("Process identifier={} connecting to ZooKeeper ensemble={}", identifier,
+      quorumServers);
     this.identifier = identifier;
     this.id = Bytes.toBytes(identifier);
 
@@ -178,7 +178,7 @@ public class RecoverableZooKeeper {
                     "previous attempt succeeded.");
                 return;
               }
-              LOG.debug("Node " + path + " already deleted, retry=" + isRetry);
+              LOG.debug("Node {} already deleted, retry={}", path, isRetry);
               throw e;
 
             case CONNECTIONLOSS:
@@ -248,12 +248,10 @@ public class RecoverableZooKeeper {
   private void retryOrThrow(RetryCounter retryCounter, KeeperException e,
       String opName) throws KeeperException {
     if (!retryCounter.shouldRetry()) {
-      LOG.error("ZooKeeper " + opName + " failed after "
-        + retryCounter.getMaxAttempts() + " attempts");
+      LOG.error("ZooKeeper {} failed after {} attempts", opName, retryCounter.getMaxAttempts());
       throw e;
     }
-    LOG.debug("Retry, connectivity issue (JVM Pause?); quorum=" + quorumServers + "," +
-        "exception=" + e);
+    LOG.debug("Retry, connectivity issue (JVM Pause?); quorum={},exception{}=", quorumServers, e);
   }
 
   /**
diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAclReset.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAclReset.java
index 377383a..b66d5b1 100644
--- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAclReset.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAclReset.java
@@ -57,10 +57,10 @@ public class ZKAclReset extends Configured implements Tool {
 
     ZooKeeper zk = zkw.getRecoverableZooKeeper().getZooKeeper();
     if (eraseAcls) {
-      LOG.info(" - erase ACLs for " + znode);
+      LOG.info(" - erase ACLs for {}", znode);
       zk.setACL(znode, ZooDefs.Ids.OPEN_ACL_UNSAFE, -1);
     } else {
-      LOG.info(" - set ACLs for " + znode);
+      LOG.info(" - set ACLs for {}", znode);
       zk.setACL(znode, ZKUtil.createACL(zkw, znode, true), -1);
     }
   }
@@ -68,8 +68,8 @@ public class ZKAclReset extends Configured implements Tool {
   private static void resetAcls(final Configuration conf, boolean eraseAcls)
       throws Exception {
     try (ZKWatcher zkw = new ZKWatcher(conf, "ZKAclReset", null)) {
-      LOG.info((eraseAcls ? "Erase" : "Set") + " HBase ACLs for " +
-              zkw.getQuorum() + " " + zkw.getZNodePaths().baseZNode);
+      LOG.info((eraseAcls ? "Erase" : "Set") + " HBase ACLs for {} {}", zkw.getQuorum(),
+        zkw.getZNodePaths().baseZNode);
       resetAcls(zkw, zkw.getZNodePaths().baseZNode, eraseAcls);
     }
   }
diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKLeaderManager.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKLeaderManager.java
index fa26c0c..8460a3a 100644
--- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKLeaderManager.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKLeaderManager.java
@@ -88,7 +88,7 @@ public class ZKLeaderManager extends ZKListener {
     try {
       synchronized(lock) {
         if (ZKUtil.watchAndCheckExists(watcher, leaderZNode)) {
-          LOG.info("Found new leader for znode: "+leaderZNode);
+          LOG.info("Found new leader for znode: {}", leaderZNode);
           leaderExists.set(true);
         } else {
           LOG.info("Leader change, but no new leader found");
@@ -127,7 +127,7 @@ public class ZKLeaderManager extends ZKListener {
           ZKUtil.deleteNode(watcher, leaderZNode);
           leaderExists.set(false);
         } else {
-          LOG.info("Found existing leader with ID: "+Bytes.toStringBinary(nodeId));
+          LOG.info("Found existing leader with ID: {}", Bytes.toStringBinary(nodeId));
           leaderExists.set(true);
         }
       } catch (KeeperException ke) {
diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java
index 5806e5b..a41b4a0 100644
--- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java
@@ -81,7 +81,7 @@ public abstract class ZKNodeTracker extends ZKListener {
           this.data = data;
         } else {
           // It existed but now does not, try again to ensure a watch is set
-          LOG.debug("Try starting again because there is no data from " + node);
+          LOG.debug("Try starting again because there is no data from {}", node);
           start();
         }
       }
@@ -147,7 +147,7 @@ public abstract class ZKNodeTracker extends ZKListener {
 
         // It did not exists, and now it does.
         if (nodeExistsChecked){
-          LOG.debug("Node " + node + " now exists, resetting a watcher");
+          LOG.debug("Node {} now exists, resetting a watcher", node);
           try {
             // This does not create a watch if the node does not exists
             this.data = ZKUtil.getDataAndWatch(watcher, node);
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 878f3ca..5f2185e 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
@@ -130,7 +130,7 @@ public final class ZKUtil {
     int timeout = conf.getInt(HConstants.ZK_SESSION_TIMEOUT,
         HConstants.DEFAULT_ZK_SESSION_TIMEOUT);
     if (LOG.isTraceEnabled()) {
-      LOG.trace(identifier + " opening connection to ZooKeeper ensemble=" + ensemble);
+      LOG.trace("{} opening connection to ZooKeeper ensemble={}", identifier, ensemble);
     }
     int retry = conf.getInt("zookeeper.recovery.retry", 3);
     int retryIntervalMillis =
@@ -218,7 +218,7 @@ public final class ZKUtil {
     // No keytab specified, no auth
     String keytabFilename = conf.get(keytabFileKey);
     if (keytabFilename == null) {
-      LOG.warn("no keytab specified for: " + keytabFileKey);
+      LOG.warn("no keytab specified for: {}", keytabFileKey);
       return;
     }
 
@@ -288,9 +288,8 @@ public final class ZKUtil {
       this.useTicketCache = useTicketCache;
       this.keytabFile = keytabFile;
       this.principal = principal;
-      LOG.info("JaasConfiguration loginContextName=" + loginContextName +
-               " principal=" + principal + " useTicketCache=" + useTicketCache +
-               " keytabFile=" + keytabFile);
+      LOG.info("JaasConfiguration loginContextName={} principal={} useTicketCache={} keytabFile={}",
+        loginContextName, principal, useTicketCache, keytabFile);
     }
 
     @Override
@@ -919,8 +918,8 @@ public final class ZKUtil {
           }
         }
         if (!groups.isEmpty()) {
-          LOG.warn("Znode ACL setting for group " + groups
-              + " is skipped, ZooKeeper doesn't support this feature presently.");
+          LOG.warn("Znode ACL setting for group {} is skipped, ZooKeeper doesn't support this " +
+            "feature presently.", groups);
         }
       }
       // Certain znodes are accessed directly by the client,
@@ -2093,7 +2092,7 @@ public final class ZKUtil {
         for (int attempt = 0; attempt < maxNumAttempts; ++attempt) {
           try {
             if (zk.exists(parentZNode, false) != null) {
-              LOG.info("Parent znode exists: " + parentZNode);
+              LOG.info("Parent znode exists: {}", parentZNode);
               keeperEx = null;
               break;
             }
diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java
index e5ef089..e0b34e4 100644
--- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java
@@ -169,7 +169,7 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
         try {
           this.recoverableZooKeeper.close();
         } catch (InterruptedException ie) {
-          LOG.debug("Encountered InterruptedException when closing " + this.recoverableZooKeeper);
+          LOG.debug("Encountered InterruptedException when closing {}", this.recoverableZooKeeper);
           Thread.currentThread().interrupt();
         }
         throw zce;
@@ -235,7 +235,7 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
       setZnodeAclsRecursive(ZNodePaths.joinZNode(znode, child));
     }
     List<ACL> acls = ZKUtil.createACL(this, znode, true);
-    LOG.info("Setting ACLs for znode:" + znode + " , acl:" + acls);
+    LOG.info("Setting ACLs for znode:{} , acl:{}", znode, acls);
     recoverableZooKeeper.setAcl(znode, acls, -1);
   }
 
@@ -304,13 +304,13 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
           }
         } else {
           if (LOG.isDebugEnabled()) {
-            LOG.debug("Unexpected shortname in SASL ACL: " + id);
+            LOG.debug("Unexpected shortname in SASL ACL: {}", id);
           }
           return false;
         }
       } else {
         if (LOG.isDebugEnabled()) {
-          LOG.debug("unexpected ACL id '" + id + "'");
+          LOG.debug("unexpected ACL id '{}'", id);
         }
         return false;
       }
@@ -539,7 +539,7 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
         this.identifier = this.prefix + "-0x" +
           Long.toHexString(this.recoverableZooKeeper.getSessionId());
         // Update our identifier.  Otherwise ignore.
-        LOG.debug(this.identifier + " connected");
+        LOG.debug("{} connected", this.identifier);
         break;
 
       // Abort the server if Disconnected or Expired