All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.mongock.driver.api.lock.LockManager Maven / Gradle / Ivy

The newest version!
package io.mongock.driver.api.lock;

import java.io.Closeable;


public interface LockManager extends Closeable {

  /**
   * @return lock's key
   */
  String getDefaultKey();

  /**
   * 

Tries to acquire the default lock regardless who is the current owner.

*

If the lock is already acquired by the current LockChecker or is expired, will be updated

*

In case the lock is acquired by another LockChecker, it will wait until the current lock is expired * and will try to acquire it again. This will be repeated as many times as (maxTries - 1)

* * @throws LockCheckException if the lock cannot be acquired */ void acquireLockDefault() throws LockCheckException; /** *

Tries to refresh the default lock when the current LockChecker has the lock or , when the lock * is expired, is the last owner

*

Notice that it does not try to acquire when is acquired by another LockChecker

* * @throws LockCheckException if, in case of needed, the lock cannot be refreshed */ void ensureLockDefault() throws LockCheckException; /** *

Release the default lock when is acquired by the current LockChecker.

*

When the lock is not acquired by the current LockChecker, it won't make any change. * Does not throw any exception neither.

*

Idempotent operation.

*/ void releaseLockDefault(); /** * @return if the lockManager has been told to release the lock. It may still hold it. */ boolean isReleaseStarted(); /** * @return lock try frequency */ long getLockTryFrequency(); /** * @return Lock's owner */ String getOwner(); /** * @return if lock is held */ boolean isLockHeld(); @Override void close(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy