Enum Class OperationLock

java.lang.Object
java.lang.Enum<OperationLock>
org.gridgain.internal.lock.OperationLock
All Implemented Interfaces:
Serializable, Comparable<OperationLock>, Constable

public enum OperationLock extends Enum<OperationLock>
Lock that prohibits conflicting operations.
  • Enum Constant Details

  • Method Details

    • values

      public static OperationLock[] 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

      public static OperationLock valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • start

      public CompletableFuture<Void> start(org.apache.ignite.internal.metastorage.MetaStorageManager mgr)
      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

      public CompletableFuture<Void> stop(org.apache.ignite.internal.metastorage.MetaStorageManager mgr)
      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 between observe and stopIfHeldAt, 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 by observation. Used for orphan-lock reconciliation: the caller observes the lock via observe(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 (returns false).

      The observation's lock() must equal this: 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 true if the lock was released; false if the entry's revision no longer matches, in which case the caller must not assume ownership.