hemantk-12 commented on code in PR #5035:
URL: https://github.com/apache/ozone/pull/5035#discussion_r1262016533


##########
hadoop-hdds/managed-rocksdb/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedRocksObjectUtils.java:
##########
@@ -64,4 +73,46 @@ static String formatStackTrace(StackTraceElement[] elements) 
{
     return HddsUtils.formatStackTrace(elements, 3);
   }
 
+  /**
+   * Wait for file to be deleted.
+   * @param file File to be deleted.
+   * @param maxDuration poll max duration.
+   * @param interval poll interval.
+   * @param pollDelayDuration poll delay val.
+   * @return true if deleted.
+   */
+  public static void waitForFileDelete(File file, Duration maxDuration,
+                                       Duration interval,
+                                       Duration pollDelayDuration)
+      throws IOException {
+    Instant start = Instant.now();
+    try {
+      Awaitility.with().atMost(maxDuration)
+          .pollDelay(pollDelayDuration)
+          .pollInterval(interval)
+          .await()
+          .until(() -> !file.exists());
+      LOG.info("Waited for {} milliseconds for file {} deletion.",
+          Duration.between(start, Instant.now()).toMillis(),
+          file.getAbsoluteFile());
+    } catch (ConditionTimeoutException exception) {
+      LOG.info("File: {} didn't get deleted in {} secs.",
+          file.getAbsolutePath(), maxDuration.getSeconds());
+      throw new IOException(exception);
+    }
+  }
+
+  /**
+   * Wait for file to be deleted.
+   * @param file File to be deleted.
+   * @param maxDuration poll max duration.
+   * @throws IOException in case of failure.
+   */
+  public static void waitForFileDelete(File file, Duration maxDuration)
+      throws IOException {
+    waitForFileDelete(file, maxDuration, POLL_INTERVAL_DURATION,
+        POLL_DELAY_DURATION);
+  }
+
+

Review Comment:
   Remove extra line.



##########
hadoop-hdds/managed-rocksdb/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedRocksDB.java:
##########
@@ -78,4 +86,21 @@ public static ManagedRocksDB open(
         RocksDB.open(path, columnFamilyDescriptors, columnFamilyHandles)
     );
   }
+
+  /**
+   * Delete liveMetaDataFile from rocks db.
+   * @param fileToBeDeleted File to be deleted.
+   * @throws RocksDBException In the underlying db throws an exception.
+   * @throws IOException In the case file is not deleted.
+   */
+
+  public void deleteFile(LiveFileMetaData fileToBeDeleted)
+      throws RocksDBException, IOException {
+    String sstFileName = fileToBeDeleted.fileName();
+    this.get().deleteFile(sstFileName);
+    File file = new File(fileToBeDeleted.path(), fileToBeDeleted.fileName());
+    LOG.info("Deleting file {} from db: {}", file.getAbsolutePath(),

Review Comment:
   Please remove this.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SstFilteringService.java:
##########
@@ -123,7 +133,7 @@ public BackgroundTaskResult call() throws Exception {
 
         long snapshotLimit = snapshotLimitPerTask;
 
-        while (iterator.hasNext() && snapshotLimit > 0) {
+        while (iterator.hasNext() && snapshotLimit > 0 && running.get()) {

Review Comment:
   I don't agree with it.



##########
hadoop-hdds/managed-rocksdb/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedRocksDB.java:
##########
@@ -78,4 +87,15 @@ public static ManagedRocksDB open(
         RocksDB.open(path, columnFamilyDescriptors, columnFamilyHandles)
     );
   }
+
+  public void deleteFile(LiveFileMetaData fileToBeDeleted)

Review Comment:
   Can you please amend the java doc comment that it synchronizes the 
`RocksDB#deleteFile()`? Function name says itself that it deleted dataFile from 
rocks db.



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