Zakelly commented on code in PR #25924:
URL: https://github.com/apache/flink/pull/25924#discussion_r1917811473


##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/filemapping/FileOwnershipDecider.java:
##########
@@ -0,0 +1,70 @@
+package org.apache.flink.state.forst.fs.filemapping;
+
+import org.apache.flink.core.execution.RecoveryClaimMode;
+import org.apache.flink.core.fs.Path;
+
+public class FileOwnershipDecider {
+
+    public static final String SST_SUFFIX = ".sst";
+
+    private final RecoveryClaimMode recoveryClaimMode;
+    private final boolean isDbPathUnderCheckpointPath;
+
+    public static FileOwnershipDecider getDefault() {
+        return new FileOwnershipDecider(RecoveryClaimMode.DEFAULT, false);
+    }
+
+    public FileOwnershipDecider(
+            RecoveryClaimMode recoveryClaimMode, boolean 
isDbPathUnderCheckpointPath) {
+        this.recoveryClaimMode = recoveryClaimMode;
+        this.isDbPathUnderCheckpointPath = isDbPathUnderCheckpointPath;
+    }
+
+    public boolean isDbPathUnderCheckpointPath() {
+        return isDbPathUnderCheckpointPath;
+    }
+
+    public FileOwnership decideForNewFile(Path filePath) {
+        if (!isDbPathUnderCheckpointPath) {
+            return FileOwnership.PRIVATE_OWNED_BY_DB;
+        }
+
+        // only SST files are shareable
+        return isSstFile(filePath)
+                ? FileOwnership.SHAREABLE_OWNED_BY_DB
+                : FileOwnership.PRIVATE_OWNED_BY_DB;
+    }
+
+    public FileOwnership decideForRestoredFile(Path filePath) {
+        if (!isDbPathUnderCheckpointPath) {
+            return FileOwnership.PRIVATE_OWNED_BY_DB;
+        }
+
+        // only SST files are shareable
+        if (isSstFile(filePath)) {
+            return recoveryClaimMode == RecoveryClaimMode.CLAIM
+                    ? FileOwnership.NOT_OWNED
+                    : FileOwnership.SHAREABLE_OWNED_BY_DB;
+        } else {
+            return FileOwnership.PRIVATE_OWNED_BY_DB;
+        }
+    }

Review Comment:
   IIUC, the restored file is always `NOT_OWNED` (own by JM's shared registry).



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to