You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2022/10/17 15:22:58 UTC

[GitHub] [ratis] tisonkun commented on a diff in pull request #765: RATIS-1723. CounterStateMachine should update the latest snapshot.

tisonkun commented on code in PR #765:
URL: https://github.com/apache/ratis/pull/765#discussion_r997205342


##########
ratis-server/src/main/java/org/apache/ratis/statemachine/impl/SimpleStateMachineStorage.java:
##########
@@ -60,13 +61,12 @@ public class SimpleStateMachineStorage implements StateMachineStorage {
       Pattern.compile(SNAPSHOT_FILE_PREFIX + "\\.(\\d+)_(\\d+)");
 
   private volatile File stateMachineDir = null;
-
-  private volatile SingleFileSnapshotInfo currentSnapshot = null;
+  private final AtomicReference<SnapshotInfo> latestSnapshot = new AtomicReference<>();

Review Comment:
   If we use `AtomicReference<SingleFileSnapshotInfo>` here, we don't have to cast in the caller site if we're sure that the snapshot storage is `SimpleStateMachineStorage`.



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

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