Package org.gridgain.internal.lock
Enum Class OperationLock
- All Implemented Interfaces:
Serializable,Comparable<OperationLock>,Constable
Lock that prohibits conflicting operations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classSnapshot ofONGOING_LOCK_KEY: the decodedOperationLock(ornullif the entry is empty) together with the metastorage revision at observation time.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic CompletableFuture<OperationLock>actual(org.apache.ignite.internal.metastorage.MetaStorageManager mgr) Returns the current operation, or null if no ongoing operations.observe(org.apache.ignite.internal.metastorage.MetaStorageManager mgr) Reads the current lock together with its metastorage revision.start(org.apache.ignite.internal.metastorage.MetaStorageManager mgr) Tries to start an operation.stop(org.apache.ignite.internal.metastorage.MetaStorageManager mgr) Tries to stop an operation.stopIfHeldAt(org.apache.ignite.internal.metastorage.MetaStorageManager mgr, OperationLock.LockObservation observation) Releases this lock only if the underlying metastorage entry is still at exactly the revision carried byobservation.static OperationLockReturns the enum constant of this class with the specified name.static OperationLock[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
PITR
-
ROLLING_UPGRADE
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
start
Tries to start an operation. Allows consecutive calls of the same type.- Returns:
- A completed future on success; otherwise a failed future if conflicting operation holds the lock.
-
stop
Tries to stop an operation.- Returns:
- A completed future on success; otherwise a failed future if conflicting operation holds the lock.
-
actual
public static CompletableFuture<OperationLock> actual(org.apache.ignite.internal.metastorage.MetaStorageManager mgr) Returns the current operation, or null if no ongoing operations. -
observe
public static CompletableFuture<OperationLock.LockObservation> observe(org.apache.ignite.internal.metastorage.MetaStorageManager mgr) Reads the current lock together with its metastorage revision.Pair this with
stopIfHeldAt(MetaStorageManager, LockObservation)to perform a compare-and-release that is safe against concurrent modifications: if anyone (legitimate commit/cancel, manual operator action, or another reconciler) has touched the entry betweenobserveandstopIfHeldAt, the release is a no-op. -
stopIfHeldAt
public CompletableFuture<Boolean> stopIfHeldAt(org.apache.ignite.internal.metastorage.MetaStorageManager mgr, OperationLock.LockObservation observation) Releases this lock only if the underlying metastorage entry is still at exactly the revision carried byobservation. Used for orphan-lock reconciliation: the caller observes the lock viaobserve(org.apache.ignite.internal.metastorage.MetaStorageManager), then issues this release with the same observation. If the entry has changed in the meantime — e.g. another node already released it, an operator cleared it, or a fresh operation re-acquired the same lock type — the CAS condition fails and this is a no-op (returnsfalse).The observation's
lock()must equalthis: it is a programming error to call e.g.PITR.stopIfHeldAt(observationOfRollingUpgrade), and that mistake is caught by an assertion. As a corollary, an observation of an empty entry (lock() == null) cannot be passed here.- Returns:
- future with
trueif the lock was released;falseif the entry's revision no longer matches, in which case the caller must not assume ownership.
-