浏览代码

HDFS-7284. Add more debug info to BlockInfoUnderConstruction#setGenerationStampAndVerifyReplicas. (Wei-Chiu Chuang via Yongjun Zhang)

Yongjun Zhang 9 年之前
父节点
当前提交
5e718de522

+ 12 - 1
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/Block.java

@@ -152,11 +152,22 @@ public class Block implements Writable, Comparable<Block> {
     generationStamp = 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
   @Override
   public String toString() {
   public String toString() {
-    return getBlockName() + "_" + getGenerationStamp();
+    return toString(this);
   }
   }
 
 
   public void appendStringTo(StringBuilder sb) {
   public void appendStringTo(StringBuilder sb) {

+ 4 - 0
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.
     HDFS-4015. Safemode should count and report orphaned blocks.
     (Anu Engineer via Arpit Agarwal)
     (Anu Engineer via Arpit Agarwal)
 
 
+    HDFS-7284. Add more debug info to
+    BlockInfoUnderConstruction#setGenerationStampAndVerifyReplicas.
+    (Wei-Chiu Chuang via Yongjun Zhang)
+
   OPTIMIZATIONS
   OPTIMIZATIONS
 
 
     HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
     HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than

+ 2 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfo.java

@@ -393,8 +393,8 @@ public abstract class BlockInfo extends Block
     List<ReplicaUnderConstruction> staleReplicas = uc.getStaleReplicas(genStamp);
     List<ReplicaUnderConstruction> staleReplicas = uc.getStaleReplicas(genStamp);
     for (ReplicaUnderConstruction r : staleReplicas) {
     for (ReplicaUnderConstruction r : staleReplicas) {
       r.getExpectedStorageLocation().removeBlock(this);
       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));
     }
     }
   }
   }