slfan1989 commented on code in PR #4903:
URL: https://github.com/apache/hadoop/pull/4903#discussion_r973714519


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetAsyncDiskService.java:
##########
@@ -359,6 +371,89 @@ public void run() {
         IOUtils.cleanupWithLogger(null, this.volumeRef);
       }
     }
+
+    private boolean removeReplicaFromMem() {
+      try (AutoCloseableLock lock = 
fsdatasetImpl.acquireDatasetLockManager().writeLock(
+          DataNodeLockManager.LockLevel.BLOCK_POOl, block.getBlockPoolId())) {
+        final ReplicaInfo info = fsdatasetImpl.volumeMap
+            .get(block.getBlockPoolId(), block.getLocalBlock());
+        if (info == null) {
+          ReplicaInfo infoByBlockId =
+              fsdatasetImpl.volumeMap.get(block.getBlockPoolId(),
+                  block.getLocalBlock().getBlockId());
+          if (infoByBlockId == null) {
+            // It is okay if the block is not found -- it
+            // may be deleted earlier.
+            LOG.info("Failed to delete replica " + block.getLocalBlock()
+                + ": ReplicaInfo not found in removeReplicaFromMem.");
+          } else {
+            LOG.error("Failed to delete replica " + block.getLocalBlock()
+                + ": GenerationStamp not matched, existing replica is "
+                + Block.toString(infoByBlockId) + " in removeReplicaFromMem.");
+          }
+          return false;
+        }
+
+        FsVolumeImpl v = (FsVolumeImpl)info.getVolume();
+        if (v == null) {
+          LOG.error("Failed to delete replica " + block.getLocalBlock()
+              +  ". No volume for this replica " + info + " in 
removeReplicaFromMem.");

Review Comment:
   Should we use {}



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to