Hi William,

That's a good idea!  There is a TODO in SnapshotManager [1].  It seems that
we may simply create the tmpSnapshotFile with the fileName as below.  Not
sure if it requires other changes.

       // TODO: assumes flat layout inside SM dir

-      File tmpSnapshotFile = new File(tmpDir,

-          new File(dir.getRoot(), fileName).getName());

+      final File tmpSnapshotFile = new File(tmpDir, fileName);


Regards,
Tsz-Wo


[1]
https://github.com/apache/ratis/blob/afd33f77c5e080022ff86725f66c66ae4d9e8d06/ratis-server/src/main/java/org/apache/ratis/server/storage/SnapshotManager.java#L86


On Mon, May 30, 2022 at 1:56 AM 宋子阳 <[email protected]> wrote:

> Hi all,
>
> When follower InstallSnapshot from leader, Ratis will place all snapshot
> files in a tmp dir, and then rename it to /sm dir. If StateMachine snapshot
> contains a hierarchy of nested folders, this implementation will flatten
> the snapshot directory, which causes the hierarchy information to be lost.
>
> How should StateMachine implement takeSnapshot so that file directory
> information is maintained during InstallSnapshot? Is is possible for Ratis
> to support snapshot to have a directory hierarchy?
>
> Best wishes,
> William Song
>

Reply via email to