Package org.infinispan.lock.api
Interface ClusteredLockManager
public interface ClusteredLockManager
Provides the API to define, create and remove ClusteredLocks.
- Since:
- 9.2
- Author:
- Katia Aresti, karesti@redhat.com
-
Method Summary
Modifier and TypeMethodDescriptionbooleandefineLock(String name) Defines a lock with the specific name and the defaultClusteredLockConfiguration.booleandefineLock(String name, ClusteredLockConfiguration configuration) Defines a lock with the specific name andClusteredLockConfiguration.forceRelease(String name) Releases - or unlocks - aClusteredLockif such exists.Get’s aClusteredLockby it’s name.getConfiguration(String name) Returns the configuration of aClusteredLock, if such exists.This method throwsClusteredLockExceptionif the lock is not not defined.booleanChecks if a lock is already defined.Removes aClusteredLockif such exists.
-
Method Details
-
defineLock
Defines a lock with the specific name and the defaultClusteredLockConfiguration. It does not overwrite existing configurations. Returns true if successfully defined or false if the lock is already defined or any other failure.- Parameters:
name- , the name of the lock- Returns:
- true if the lock was successfully defined
-
defineLock
Defines a lock with the specific name andClusteredLockConfiguration. It does not overwrite existing configurations. Returns true if successfully defined or false if the lock is already defined or any other failure.- Parameters:
name- , the name of the lockconfiguration- , aClusteredLockConfigurationobject with the configuration of the lock- Returns:
- true if the lock was successfully defined
-
get
Get’s aClusteredLockby it’s name. This method throwsClusteredLockExceptionif the lock is not not defined. A call ofdefineLock(java.lang.String)must be done at least once in the cluster. This method will return the same lock object depending on theOwnershipLevel. If theOwnershipLevelisOwnershipLevel.NODE, it wll return the same instance perClusteredLockManagerIf theOwnershipLevelisOwnershipLevel.INSTANCE, it wll return a new instance per call.- Parameters:
name- , the name of the lock- Returns:
ClusteredLockinstance
-
getConfiguration
Returns the configuration of aClusteredLock, if such exists.This method throwsClusteredLockExceptionif the lock is not not defined. A call ofdefineLock(java.lang.String)must be done at least once in the cluster.- Parameters:
name- , the name of the lock- Returns:
ClusteredLockConfigurationfor this lock
-
isDefined
Checks if a lock is already defined.- Parameters:
name- , the lock name- Returns:
trueif this lock is defined
-
remove
Removes aClusteredLockif such exists.- Parameters:
name- , the name of the lock- Returns:
trueif the lock is removed
-
forceRelease
Releases - or unlocks - aClusteredLockif such exists. This method is used when we just want to force the release the lock no matter who is holding it at a given time. Calling this method may cause concurrency issues and has to be used in exceptional situations.- Parameters:
name- , the name of the lock- Returns:
trueif the lock has been released
-