You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "KeeProMise (via GitHub)" <gi...@apache.org> on 2024/09/09 09:00:34 UTC

Re: [PR] HDFS-16757. Add a new method copyBlockCrossNamespace to DataNode [hadoop]

KeeProMise commented on code in PR #6926:
URL: https://github.com/apache/hadoop/pull/6926#discussion_r1749875879


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java:
##########
@@ -4388,4 +4409,94 @@ boolean isSlownode() {
   public BlockPoolManager getBlockPoolManager() {
     return blockPoolManager;
   }
+
+  public void copyBlockCrossNamespace(ExtendedBlock sourceBlk, ExtendedBlock targetBlk,
+      DatanodeInfo targetDn) throws IOException {
+    if (!data.isValidBlock(sourceBlk)) {
+      // block does not exist or is under-construction
+      String errStr =
+          "copyBlock:(" + this.getInfoPort() + ") Can't send invalid block " + sourceBlk + " "
+              + data.getReplicaString(sourceBlk.getBlockPoolId(), sourceBlk.getBlockId());
+      LOG.info(errStr);
+      throw new IOException(errStr);
+    }
+    long onDiskLength = data.getLength(sourceBlk);
+    if (sourceBlk.getNumBytes() > onDiskLength) {
+      // Shorter on-disk len indicates corruption so report NN the corrupt block
+      String msg = "copyBlock: Can't replicate block " + sourceBlk + " because on-disk length "
+          + onDiskLength + " is shorter than provided length " + sourceBlk.getNumBytes();
+      LOG.info(msg);
+      throw new IOException(msg);
+    }
+    LOG.info(getDatanodeInfo() + " copyBlock: Starting thread to transfer: " + "block:"
+        + sourceBlk + " from " + this.getDatanodeUuid() + " to " + targetDn.getDatanodeUuid()
+        + "(" + targetDn + ")");

Review Comment:
   Hi, @LiuGuH , can use log parameterized messages ("{} xxxx", a) instead of string concatenation (a + xxx).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org