Class PaxosState
- java.lang.Object
-
- org.apache.cassandra.service.paxos.PaxosState
-
- All Implemented Interfaces:
java.lang.AutoCloseable,PaxosOperationLock
public class PaxosState extends java.lang.Object implements PaxosOperationLock
We save to memory the result of each operation before persisting to disk, however each operation that performs the update does not return a result to the coordinator until the result is fully persisted.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPaxosState.Keystatic classPaxosState.MaybePromisestatic classPaxosState.Snapshotstatic classPaxosState.UnsafeSnapshot
-
Field Summary
Fields Modifier and Type Field Description static java.util.concurrent.ConcurrentHashMap<PaxosState.Key,PaxosState>ACTIVEstatic java.util.Map<PaxosState.Key,PaxosState.Snapshot>RECENT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BallotacceptIfLatest(Commit.Proposal proposal)Record an acceptance of the proposal if there is no newer promise; otherwise inform the caller of the newer ballotstatic PaxosBallotTrackerballotTracker()voidclose()voidcommit(Commit.Agreed commit)static voidcommitDirect(Commit commit)PaxosState.SnapshotcurrentSnapshot()static PaxosStateget(DecoratedKey partitionKey, TableMetadata table)static PaxosStateget(Commit commit)static booleangetDisableCoordinatorLocking()static voidinitializeTrackers()static PrepareResponselegacyPrepare(Commit toPrepare)static java.lang.BooleanlegacyPropose(Commit proposal)static PaxosOperationLocklock(DecoratedKey partitionKey, TableMetadata metadata, long deadline, ConsistencyLevel consistencyForConsensus, boolean isWrite)static voidmaybeRebuildUncommittedState()PaxosState.MaybePromisepromiseIfNewer(Ballot ballot, boolean isWrite)Record the requested ballot as promised if it is newer than our current promise; otherwise do nothing.static voidsetDisableCoordinatorLocking(boolean disable)static voidstartAutoRepairs()static PaxosUncommittedTrackeruncommittedTracker()static PaxosState.SnapshotunsafeGetIfPresent(DecoratedKey partitionKey, TableMetadata metadata)static voidunsafeReset()voidupdateStateUnsafe(java.util.function.Function<PaxosState.Snapshot,PaxosState.Snapshot> f)
-
-
-
Field Detail
-
ACTIVE
public static final java.util.concurrent.ConcurrentHashMap<PaxosState.Key,PaxosState> ACTIVE
-
RECENT
public static final java.util.Map<PaxosState.Key,PaxosState.Snapshot> RECENT
-
-
Method Detail
-
setDisableCoordinatorLocking
public static void setDisableCoordinatorLocking(boolean disable)
-
getDisableCoordinatorLocking
public static boolean getDisableCoordinatorLocking()
-
uncommittedTracker
public static PaxosUncommittedTracker uncommittedTracker()
-
ballotTracker
public static PaxosBallotTracker ballotTracker()
-
initializeTrackers
public static void initializeTrackers()
-
maybeRebuildUncommittedState
public static void maybeRebuildUncommittedState() throws java.io.IOException- Throws:
java.io.IOException
-
startAutoRepairs
public static void startAutoRepairs()
-
get
public static PaxosState get(Commit commit)
-
get
public static PaxosState get(DecoratedKey partitionKey, TableMetadata table)
-
lock
public static PaxosOperationLock lock(DecoratedKey partitionKey, TableMetadata metadata, long deadline, ConsistencyLevel consistencyForConsensus, boolean isWrite) throws RequestTimeoutException
- Throws:
RequestTimeoutException
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacePaxosOperationLock
-
currentSnapshot
public PaxosState.Snapshot currentSnapshot()
-
updateStateUnsafe
public void updateStateUnsafe(java.util.function.Function<PaxosState.Snapshot,PaxosState.Snapshot> f)
-
promiseIfNewer
public PaxosState.MaybePromise promiseIfNewer(Ballot ballot, boolean isWrite)
Record the requested ballot as promised if it is newer than our current promise; otherwise do nothing.- Returns:
- a PromiseResult containing the before and after state for this operation
-
acceptIfLatest
public Ballot acceptIfLatest(Commit.Proposal proposal)
Record an acceptance of the proposal if there is no newer promise; otherwise inform the caller of the newer ballot
-
commit
public void commit(Commit.Agreed commit)
-
commitDirect
public static void commitDirect(Commit commit)
-
legacyPrepare
public static PrepareResponse legacyPrepare(Commit toPrepare)
-
legacyPropose
public static java.lang.Boolean legacyPropose(Commit proposal)
-
unsafeReset
public static void unsafeReset()
-
unsafeGetIfPresent
public static PaxosState.Snapshot unsafeGetIfPresent(DecoratedKey partitionKey, TableMetadata metadata)
-
-