From 8e1730243b9b9387589ef4603b82e7373a8baec7 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Tue, 12 Jun 2012 05:01:50 +0000 Subject: [PATCH] HDFS-3520. Add transfer rate logging to TransferFsImage. Contributed by Eli Collins git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1349118 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../hadoop/hdfs/server/namenode/TransferFsImage.java | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 7d3cb7dc440..75d31f83b73 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -68,6 +68,8 @@ Release 2.0.1-alpha - UNRELEASED HDFS-3052. Change INodeFile and INodeFileUnderConstruction to package private. (szetszwo) + HDFS-3520. Add transfer rate logging to TransferFsImage. (eli) + OPTIMIZATIONS HDFS-2982. Startup performance suffers when there are many edit log diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java index 97088c5f433..492cf28fbe7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/TransferFsImage.java @@ -32,11 +32,11 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.hdfs.protocol.HdfsConstants; +import org.apache.hadoop.hdfs.server.common.Util; import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeDirType; import org.apache.hadoop.hdfs.server.protocol.RemoteEditLog; import org.apache.hadoop.hdfs.util.DataTransferThrottler; import org.apache.hadoop.io.MD5Hash; -import org.apache.hadoop.security.UserGroupInformation; import com.google.common.collect.Lists; @@ -207,6 +207,7 @@ public class TransferFsImage { // // open connection to remote server // + long startTime = Util.monotonicNow(); URL url = new URL(str); HttpURLConnection connection = (HttpURLConnection) @@ -312,6 +313,11 @@ public class TransferFsImage { advertisedSize); } } + double xferSec = Math.max( + ((float)(Util.monotonicNow() - startTime)) / 1000.0, 0.001); + long xferKb = received / 1024; + LOG.info(String.format("Transfer took %.2fs at %.2f KB/s", + xferSec, xferKb / xferSec)); if (digester != null) { MD5Hash computedDigest = new MD5Hash(digester.digest());