From 9ef89ede2f18c76c601fd585cb9d47511f5fc3ed Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Thu, 8 Dec 2016 13:38:02 +0900 Subject: [PATCH] HDFS-11140. Directory Scanner should log startup message time correctly. Contributed by Yiqun Lin. --- .../hdfs/server/datanode/DirectoryScanner.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java index e2baf32ff2..18188dddbc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java @@ -37,6 +37,8 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; + +import org.apache.commons.lang.time.FastDateFormat; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; @@ -61,7 +63,7 @@ public class DirectoryScanner implements Runnable { private static final int MILLIS_PER_SECOND = 1000; private static final String START_MESSAGE = "Periodic Directory Tree Verification scan" - + " starting at %dms with interval of %dms"; + + " starting at %s with interval of %dms"; private static final String START_MESSAGE_WITH_THROTTLE = START_MESSAGE + " and throttle limit of %dms/s"; @@ -268,10 +270,12 @@ void start() { String logMsg; if (throttleLimitMsPerSec < MILLIS_PER_SECOND) { - logMsg = String.format(START_MESSAGE_WITH_THROTTLE, firstScanTime, - scanPeriodMsecs, throttleLimitMsPerSec); + logMsg = String.format(START_MESSAGE_WITH_THROTTLE, + FastDateFormat.getInstance().format(firstScanTime), scanPeriodMsecs, + throttleLimitMsPerSec); } else { - logMsg = String.format(START_MESSAGE, firstScanTime, scanPeriodMsecs); + logMsg = String.format(START_MESSAGE, + FastDateFormat.getInstance().format(firstScanTime), scanPeriodMsecs); } LOG.info(logMsg);