[ 
https://issues.apache.org/jira/browse/HDFS-16757?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17908609#comment-17908609
 ] 

ASF GitHub Bot commented on HDFS-16757:
---------------------------------------

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


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java:
##########
@@ -3863,5 +3864,27 @@ public void setLastDirScannerFinishTime(long time) {
   public long getPendingAsyncDeletions() {
     return asyncDiskService.countPendingDeletions();
   }
+
+  @Override
+  public void hardLinkOneBlock(ExtendedBlock srcBlock, ExtendedBlock dstBlock) 
throws IOException {

Review Comment:
   ```
   public void hardLinkOneBlock(ExtendedBlock srcBlock, ExtendedBlock dstBlock) 
throws IOException {
       ReplicaInfo srcReplicaInfo = getReplicaInfo(srcBlock);
       FsVolumeImpl v = getVolume(srcBlock);
   
       try (AutoCloseableLock lock = lockManager.writeLock(LockLevel.VOLUME, 
dstBlock.getBlockPoolId(),
           v.getStorageID())) {
         BlockPoolSlice dstBPS = v.getBlockPoolSlice(dstBlock.getBlockPoolId());
         LocalReplicaInPipeline replicaInfo = (LocalReplicaInPipeline) 
v.createTemporary(dstBlock);
         hardLinkBlockFiles(srcReplicaInfo, replicaInfo.getMetaFile(), 
replicaInfo.getBlockFile());
         File dstBlockFile = dstBPS.addFinalizedBlock(dstBlock.getLocalBlock(), 
replicaInfo);
         ReplicaInfo finalizedReplica = new 
FinalizedReplica(dstBlock.getLocalBlock(),
             v, dstBlockFile.getParentFile());
         volumeMap.add(dstBlock.getBlockPoolId(), finalizedReplica);
       }
     }
   ```
   How about using the existing method `hardLinkBlockFiles` to perform this 
logic?





> Add a new method copyBlockCrossNamespace to DataNode
> ----------------------------------------------------
>
>                 Key: HDFS-16757
>                 URL: https://issues.apache.org/jira/browse/HDFS-16757
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>            Reporter: ZanderXu
>            Assignee: liuguanghua
>            Priority: Minor
>              Labels: pull-request-available
>
> Add a new method copyBlockCrossNamespace in DataTransferProtocol at the 
> DataNode Side.
> This method will copy a source block from one namespace to a target block 
> from a different namespace. If the target DN is the same with the current DN, 
> this method will copy the block via HardLink. If the target DN is different 
> with the current DN, this method will copy the block via TransferBlock.
> This method will contains some parameters:
>  * ExtendedBlock sourceBlock
>  * Token<BlockTokenIdentifier> sourceBlockToken
>  * ExtendedBlock targetBlock
>  * Token<BlockTokenIdentifier> targetBlockToken
>  * DatanodeInfo targetDN



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to