jojochuang commented on code in PR #6810:
URL: https://github.com/apache/ozone/pull/6810#discussion_r1639202837


##########
hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java:
##########
@@ -156,21 +157,55 @@ public boolean recoverLease(Path f) throws IOException {
       throw e;
     }
 
-    // finalize the final block and get block length
-    List<OmKeyLocationInfo> locationInfoList = 
leaseKeyInfo.getKeyInfo().getLatestVersionLocations().getLocationList();
-    if (!locationInfoList.isEmpty()) {
-      OmKeyLocationInfo block = locationInfoList.get(locationInfoList.size() - 
1);
+    OmKeyLocationInfoGroup keyLatestVersionLocations = 
leaseKeyInfo.getKeyInfo().getLatestVersionLocations();
+    List<OmKeyLocationInfo> keyLocationInfoList = 
keyLatestVersionLocations.getLocationList();
+    OmKeyLocationInfoGroup openKeyLatestVersionLocations = 
leaseKeyInfo.getOpenKeyInfo().getLatestVersionLocations();
+    List<OmKeyLocationInfo> openKeyLocationInfoList = 
openKeyLatestVersionLocations.getLocationList();
+
+    int openKeyLocationSize = openKeyLocationInfoList.size();
+    int keyLocationSize = keyLocationInfoList.size();
+    OmKeyLocationInfo openKeyFinalBlock = null;
+    OmKeyLocationInfo openKeyPenultimateBlock = null;
+    OmKeyLocationInfo keyFinalBlock;
+
+    if (keyLocationSize > 0) {
+      // Block info from fileTable
+      keyFinalBlock = keyLocationInfoList.get(keyLocationSize - 1);
+      // Block info from openFileTable
+      if (openKeyLocationSize > 1) {
+        openKeyFinalBlock = openKeyLocationInfoList.get(openKeyLocationSize - 
1);
+        openKeyPenultimateBlock = 
openKeyLocationInfoList.get(openKeyLocationSize - 2);
+      } else if (openKeyLocationSize > 0) {
+        openKeyFinalBlock = openKeyLocationInfoList.get(0);
+      }
+      // Finalize the final block and get block length
       try {
-        block.setLength(getAdapter().finalizeBlock(block));
+        // CASE 1: When openFileTable has more block than fileTable

Review Comment:
   does the test case cover all three cases?



-- 
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