You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sz...@apache.org on 2021/04/26 09:19:13 UTC
[ratis] branch master updated: RATIS-1369. When there is no
snapshot, the return snapshotIndex should be -1, not 0. (#473)
This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 00f0c85 RATIS-1369. When there is no snapshot, the return snapshotIndex should be -1, not 0. (#473)
00f0c85 is described below
commit 00f0c8586cbf70e292ece73768db93f3b7888885
Author: Glen Geng <gl...@apache.org>
AuthorDate: Mon Apr 26 17:19:05 2021 +0800
RATIS-1369. When there is no snapshot, the return snapshotIndex should be -1, not 0. (#473)
---
.../src/main/java/org/apache/ratis/server/impl/ServerState.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
index 728f7e9..322feb5 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
@@ -431,7 +431,7 @@ class ServerState implements Closeable {
long getLatestInstalledSnapshotIndex() {
final TermIndex ti = latestInstalledSnapshot.get();
- return ti != null? ti.getIndex(): 0L;
+ return ti != null? ti.getIndex(): RaftLog.INVALID_LOG_INDEX;
}
/**
@@ -440,7 +440,7 @@ class ServerState implements Closeable {
*/
long getSnapshotIndex() {
final SnapshotInfo s = getLatestSnapshot();
- final long latestSnapshotIndex = s != null ? s.getIndex() : 0;
+ final long latestSnapshotIndex = s != null ? s.getIndex() : RaftLog.INVALID_LOG_INDEX;
return Math.max(latestSnapshotIndex, getLatestInstalledSnapshotIndex());
}