From 69489ff2d18a26be9c56d632672079e134f1cd99 Mon Sep 17 00:00:00 2001 From: Giovanni Matteo Fumarola Date: Mon, 3 Dec 2018 12:55:52 -0800 Subject: [PATCH] HDFS-14119. Improve GreedyPlanner Parameter Logging. Contributed by Beluga Behr. --- .../diskbalancer/planner/GreedyPlanner.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/planner/GreedyPlanner.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/planner/GreedyPlanner.java index 568c1e62dc..3f9734537a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/planner/GreedyPlanner.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/planner/GreedyPlanner.java @@ -64,7 +64,7 @@ public GreedyPlanner(double threshold, DiskBalancerDataNode node) { */ @Override public NodePlan plan(DiskBalancerDataNode node) throws Exception { - long startTime = Time.monotonicNow(); + final long startTime = Time.monotonicNow(); NodePlan plan = new NodePlan(node.getDataNodeName(), node.getDataNodePort()); LOG.info("Starting plan for Node : {}:{}", @@ -75,12 +75,10 @@ public NodePlan plan(DiskBalancerDataNode node) throws Exception { } } - long endTime = Time.monotonicNow(); - String message = String - .format("Compute Plan for Node : %s:%d took %d ms ", - node.getDataNodeName(), node.getDataNodePort(), - endTime - startTime); - LOG.info(message); + final long endTime = Time.monotonicNow(); + LOG.info("Compute Plan for Node : {}:{} took {} ms", + node.getDataNodeName(), node.getDataNodePort(), endTime - startTime); + return plan; } @@ -117,21 +115,19 @@ public void balanceVolumeSet(DiskBalancerDataNode node, applyStep(nextStep, currentSet, lowVolume, highVolume); if (nextStep != null) { - LOG.debug("Step : {} ", nextStep.toString()); + LOG.debug("Step : {} ", nextStep); plan.addStep(nextStep); } } - String message = String - .format("Disk Volume set %s Type : %s plan completed.", - currentSet.getSetID(), - currentSet.getVolumes().get(0).getStorageType()); + LOG.info("Disk Volume set {} - Type : {} plan completed.", + currentSet.getSetID(), + currentSet.getVolumes().get(0).getStorageType()); plan.setNodeName(node.getDataNodeName()); plan.setNodeUUID(node.getDataNodeUUID()); plan.setTimeStamp(Time.now()); plan.setPort(node.getDataNodePort()); - LOG.info(message); } /** @@ -207,7 +203,7 @@ private Step computeMove(DiskBalancerVolumeSet currentSet, // Create a new step nextStep = new MoveStep(highVolume, currentSet.getIdealUsed(), lowVolume, bytesToMove, currentSet.getSetID()); - LOG.debug(nextStep.toString()); + LOG.debug("Next Step: {}", nextStep); } return nextStep; }