Interface TermInfoStore
- All Known Implementing Classes:
PropertiesTermInfoStore
@NonNullByDefault
public interface TermInfoStore
Storage for
TermInfo. Provides access to current term and updates to it both transient, via
setTerm(TermInfo) and persistent, via storeAndSetTerm(TermInfo).-
Method Summary
Modifier and TypeMethodDescriptionReturnsTermInfofor current term.@Nullable TermInfoAttempt to load the last persistedTermInfo, if available.voidThis method updates the in-memory election term state.voidstoreAndSetTerm(TermInfo newTerm) This method updates the in-memory election term state and persists it so it can be recovered on next restart.
-
Method Details
-
currentTerm
TermInfo currentTerm()ReturnsTermInfofor current term. Freshly-initialized instances returnTermInfo.INITIAL.- Returns:
TermInfofor current term
-
setTerm
This method updates the in-memory election term state. This method should be called when recovering election state from persistent storage.- Parameters:
newTerm- newTermInfo
-
storeAndSetTerm
This method updates the in-memory election term state and persists it so it can be recovered on next restart. This method should be called when starting a new election or when a Raft RPC message is received with a higher term.- Parameters:
newTerm- newTermInfo- Throws:
IOException- if an I/O error occurs
-
loadAndSetTerm
Attempt to load the last persistedTermInfo, if available. If successful,currentTerm()is updated.- Returns:
- the persisted
TermInfo, ornullof none is available - Throws:
IOException- if an I/O error occurs
-