kgeisz commented on code in PR #8845:
URL: https://github.com/apache/hbase/pull/8845#discussion_r4556782444


##########
hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/HBackupFileSystem.java:
##########
@@ -93,6 +94,46 @@ public static Path getBackupPath(String backupRootDir, 
String backupId) {
     return new Path(backupRootDir + Path.SEPARATOR + backupId);
   }
 
+  /**
+   * Write a completion marker file to signal a backup has completed 
successfully. This is a
+   * best-effort operation: if the write fails, the backup itself is still 
considered complete (the
+   * system table is the source of truth). The marker file is intended for 
external consumers (e.g.,
+   * another cluster) that cannot access the originating cluster's 
BackupSystemTable. Absence of the
+   * marker should not be interpreted as backup failure; consumers should fall 
back to checking for
+   * a valid BackupManifest.
+   * @param conf          configuration
+   * @param backupRootDir backup root directory
+   * @param backupId      backup id
+   */
+  public static void writeBackupCompleteMarker(Configuration conf, String 
backupRootDir,
+    String backupId) {
+    Path backupDir = getBackupPath(backupRootDir, backupId);
+    Path markerPath = new Path(backupDir, BACKUP_COMPLETE_FILE_NAME);
+    try {
+      FileSystem fs = markerPath.getFileSystem(conf);
+      fs.create(markerPath, true).close();
+      LOG.info("Backup completion marker file written to: {}", markerPath);
+    } catch (IOException e) {
+      LOG.warn("Failed to write {} marker file to backup directory: {}", 
BACKUP_COMPLETE_FILE_NAME,
+        backupDir, e);
+    }
+  }
+
+  /**
+   * Check whether a backup completion marker file exists for the given backup.
+   * @param conf          configuration
+   * @param backupRootDir backup root directory
+   * @param backupId      backup id
+   * @return true if the marker file exists
+   * @throws IOException if the file system cannot be accessed
+   */
+  public static boolean isBackupComplete(Configuration conf, String 
backupRootDir, String backupId)
+    throws IOException {
+    Path markerPath = new Path(getBackupPath(backupRootDir, backupId), 
BACKUP_COMPLETE_FILE_NAME);
+    FileSystem fs = markerPath.getFileSystem(conf);
+    return fs.exists(markerPath);
+  }

Review Comment:
   We will need this method in PR https://github.com/apache/hbase/pull/8835. It 
will be needed by 
[CustomBackupLocationPitrRestoreHandler.getBackupMetadata()](https://github.com/apache/hbase/pull/8835/changes#diff-1cfb4ede81b76f7eb6e3338b4a89912501e4df0b529ada4bc9397605f1cd5cecL51)



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

Reply via email to