HBASE-23619 Used built-in formatting for logger in hbase-zookeeper

Signed-off-by: stack <stack@apache.org>
This commit is contained in:
Jan Hentschel 2019-12-27 10:39:46 +01:00 committed by GitHub
parent def9ac7c45
commit e9b998012f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 42 deletions

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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

View File

@ -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) {

View File

@ -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);
}
/**

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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);

View File

@ -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;
}

View File

@ -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