Package org.infinispan.lock.impl.manager
Class EmbeddedClusteredLockManager
- java.lang.Object
-
- org.infinispan.lock.impl.manager.EmbeddedClusteredLockManager
-
- All Implemented Interfaces:
ClusteredLockManager
@MBean(objectName="ClusteredLockManager", description="Component to manage clustered locks") public class EmbeddedClusteredLockManager extends Object implements ClusteredLockManagerThe Embedded version for the lock cluster manager- Since:
- 9.2
- Author:
- Katia Aresti, karesti@redhat.com
-
-
Field Summary
Fields Modifier and Type Field Description static StringFORCE_RELEASEstatic StringIS_DEFINEDstatic StringIS_LOCKEDstatic StringOBJECT_NAMEstatic StringREMOVE
-
Constructor Summary
Constructors Constructor Description EmbeddedClusteredLockManager(ClusteredLockManagerConfiguration config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandefineLock(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.CompletableFuture<Boolean>forceRelease(String name)Releases - or unlocks - aClusteredLockif such exists.booleanforceReleaseSync(String name)ClusteredLockget(String name)Get’s aClusteredLockby it’s name.ClusteredLockConfigurationgetConfiguration(String name)Returns the configuration of aClusteredLock, if such exists.This method throwsClusteredLockExceptionif the lock is not not defined.ScheduledExecutorServicegetScheduledExecutorService()booleanisDefined(String name)Checks if a lock is already defined.booleanisLockedSync(String name)CompletableFuture<Boolean>remove(String name)Removes aClusteredLockif such exists.booleanremoveSync(String name)voidstart()voidstop()StringtoString()
-
-
-
Field Detail
-
OBJECT_NAME
public static final String OBJECT_NAME
- See Also:
- Constant Field Values
-
FORCE_RELEASE
public static final String FORCE_RELEASE
- See Also:
- Constant Field Values
-
REMOVE
public static final String REMOVE
- See Also:
- Constant Field Values
-
IS_DEFINED
public static final String IS_DEFINED
- See Also:
- Constant Field Values
-
IS_LOCKED
public static final String IS_LOCKED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EmbeddedClusteredLockManager
public EmbeddedClusteredLockManager(ClusteredLockManagerConfiguration config)
-
-
Method Detail
-
start
public void start()
-
stop
public void stop()
-
defineLock
public boolean defineLock(String name)
Description copied from interface:ClusteredLockManagerDefines 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.- Specified by:
defineLockin interfaceClusteredLockManager- Parameters:
name- , the name of the lock- Returns:
- true if the lock was successfully defined
-
defineLock
public boolean defineLock(String name, ClusteredLockConfiguration configuration)
Description copied from interface:ClusteredLockManagerDefines 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.- Specified by:
defineLockin interfaceClusteredLockManager- Parameters:
name- , the name of the lockconfiguration- , aClusteredLockConfigurationobject with the configuration of the lock- Returns:
- true if the lock was successfully defined
-
get
public ClusteredLock get(String name)
Description copied from interface:ClusteredLockManagerGet’s aClusteredLockby it’s name. This method throwsClusteredLockExceptionif the lock is not not defined. A call ofClusteredLockManager.defineLock(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.- Specified by:
getin interfaceClusteredLockManager- Parameters:
name- , the name of the lock- Returns:
ClusteredLockinstance
-
getConfiguration
public ClusteredLockConfiguration getConfiguration(String name)
Description copied from interface:ClusteredLockManagerReturns the configuration of aClusteredLock, if such exists.This method throwsClusteredLockExceptionif the lock is not not defined. A call ofClusteredLockManager.defineLock(java.lang.String)must be done at least once in the cluster.- Specified by:
getConfigurationin interfaceClusteredLockManager- Parameters:
name- , the name of the lock- Returns:
ClusteredLockConfigurationfor this lock
-
isDefined
@ManagedOperation(description="Returns true if the lock is defined", displayName="Is Lock Defined", name="isDefined") public boolean isDefined(String name)Description copied from interface:ClusteredLockManagerChecks if a lock is already defined.- Specified by:
isDefinedin interfaceClusteredLockManager- Parameters:
name- , the lock name- Returns:
trueif this lock is defined
-
remove
public CompletableFuture<Boolean> remove(String name)
Description copied from interface:ClusteredLockManagerRemoves aClusteredLockif such exists.- Specified by:
removein interfaceClusteredLockManager- Parameters:
name- , the name of the lock- Returns:
trueif the lock is removed
-
removeSync
@ManagedOperation(description="Removes the lock from the cluster. The lock has to be recreated to access next time.", displayName="Remove Clustered Lock", name="remove") public boolean removeSync(String name)
-
forceRelease
public CompletableFuture<Boolean> forceRelease(String name)
Description copied from interface:ClusteredLockManagerReleases - 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.- Specified by:
forceReleasein interfaceClusteredLockManager- Parameters:
name- , the name of the lock- Returns:
trueif the lock has been released
-
forceReleaseSync
@ManagedOperation(description="Forces a release of the lock if such exist", displayName="Release Clustered Lock", name="forceRelease") public boolean forceReleaseSync(String name)
-
isLockedSync
@ManagedOperation(description="Returns true if the lock exists and is acquired", displayName="Is Locked", name="isLocked") public boolean isLockedSync(String name)
-
getScheduledExecutorService
public ScheduledExecutorService getScheduledExecutorService()
-
-