You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/02/05 15:18:37 UTC

[GitHub] [flink] tillrohrmann commented on a change in pull request #18237: [FLINK-25817] Use working directory to persist local state

tillrohrmann commented on a change in pull request #18237:
URL: https://github.com/apache/flink/pull/18237#discussion_r800067576



##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/state/TaskLocalStateStoreImpl.java
##########
@@ -176,14 +186,52 @@ public void storeLocalState(
         }
     }
 
+    /**
+     * Writes a task state snapshot file that contains the serialized content of the local state.
+     *
+     * @param checkpointId identifying the checkpoint
+     * @param localState task state snapshot that will be persisted
+     */
+    private void persistLocalStateMetadata(long checkpointId, TaskStateSnapshot localState) {
+        final File taskStateSnapshotFile = getTaskStateSnapshotFile(checkpointId);
+        try (ObjectOutputStream oos =
+                new ObjectOutputStream(new FileOutputStream(taskStateSnapshotFile))) {
+            oos.writeObject(localState);
+
+            LOG.debug(
+                    "Successfully written local task state snapshot file {} for checkpoint {}.",
+                    taskStateSnapshotFile,
+                    checkpointId);
+        } catch (IOException e) {
+            ExceptionUtils.rethrow(e, "Could not write the local task state snapshot file.");
+        }
+    }
+
+    @VisibleForTesting
+    @Nonnull
+    File getTaskStateSnapshotFile(long checkpointId) {
+        final File checkpointDirectory =
+                localRecoveryConfig
+                        .getLocalStateDirectoryProvider()
+                        .subtaskSpecificCheckpointDirectory(checkpointId);

Review comment:
       Will fix it.




-- 
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-unsubscribe@flink.apache.org

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