From 5e718de522328d1112ad38063596c204aa43f539 Mon Sep 17 00:00:00 2001 From: Yongjun Zhang Date: Mon, 26 Oct 2015 13:16:11 -0700 Subject: [PATCH] HDFS-7284. Add more debug info to BlockInfoUnderConstruction#setGenerationStampAndVerifyReplicas. (Wei-Chiu Chuang via Yongjun Zhang) --- .../java/org/apache/hadoop/hdfs/protocol/Block.java | 13 ++++++++++++- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 4 ++++ .../hdfs/server/blockmanagement/BlockInfo.java | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java index 710897e6be..2b139b2827 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java @@ -152,11 +152,22 @@ public void setGenerationStamp(long stamp) { generationStamp = stamp; } + /** + * A helper method to output the string representation of the Block portion of + * a derived class' instance. + * + * @param b the target object + * @return the string representation of the block + */ + public static String toString(final Block b) { + return b.getBlockName() + "_" + b.getGenerationStamp(); + } + /** */ @Override public String toString() { - return getBlockName() + "_" + getGenerationStamp(); + return toString(this); } public void appendStringTo(StringBuilder sb) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 7ce5a09685..c748d295f3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1569,6 +1569,10 @@ Release 2.8.0 - UNRELEASED HDFS-4015. Safemode should count and report orphaned blocks. (Anu Engineer via Arpit Agarwal) + HDFS-7284. Add more debug info to + BlockInfoUnderConstruction#setGenerationStampAndVerifyReplicas. + (Wei-Chiu Chuang via Yongjun Zhang) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfo.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfo.java index 92a1135810..e15b5eeff4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfo.java @@ -393,8 +393,8 @@ public void setGenerationStampAndVerifyReplicas(long genStamp) { List staleReplicas = uc.getStaleReplicas(genStamp); for (ReplicaUnderConstruction r : staleReplicas) { r.getExpectedStorageLocation().removeBlock(this); - NameNode.blockStateChangeLog.debug("BLOCK* Removing stale replica " - + "from location: {}", r.getExpectedStorageLocation()); + NameNode.blockStateChangeLog.debug("BLOCK* Removing stale replica {}" + + " of {}", r, Block.toString(r)); } }