T - the type of ManagedClusterLock that this registry trackspublic abstract class LockRegistry<T extends ManagedClusterLock> extends Object
ManagedClusterLockService implementations.
The lock registry maintains a unique mapping of lock names to corresponding ClusterLock objects on
behalf of a ManagedClusterLockService. Lock services that use this registry to manage this mapping
should implement ManagedClusterLockService.getAllKnownClusterLocks(),
ManagedClusterLockService.getAllKnownClusterLocks(), and ClusterLockService.getLockForName(String) by
delegating them to the lock registry.
createLock(String)| Constructor and Description |
|---|
LockRegistry() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
createLock(String lockName)
Creates a new cluster lock with the given name.
|
Collection<T> |
getAllKnownClusterLocks()
A delegate implementation for
ManagedClusterLockService.getAllKnownClusterLocks() that will return
all registered ManagedClusterLock instances that have previously been returned by calls to
getLockForName(String). |
ClusterLock |
getLockForName(String lockName)
A delegate implementation for
ClusterLockService.getLockForName(String) that will ensure that
the same lock instance is returned on every call. |
Collection<ClusterLockStatus> |
getStatusesOfAllHeldClusterLocks()
A delegate implementation for
ManagedClusterLockService.getStatusesOfAllHeldClusterLocks() that will
return ClusterLockStatus for every lock being held. |
public Collection<T> getAllKnownClusterLocks()
ManagedClusterLockService.getAllKnownClusterLocks() that will return
all registered ManagedClusterLock instances that have previously been returned by calls to
getLockForName(String).public Collection<ClusterLockStatus> getStatusesOfAllHeldClusterLocks()
ManagedClusterLockService.getStatusesOfAllHeldClusterLocks() that will
return ClusterLockStatus for every lock being held.public ClusterLock getLockForName(@Nonnull String lockName)
ClusterLockService.getLockForName(String) that will ensure that
the same lock instance is returned on every call.lockName - the name of the locklockName has not previously been requested; otherwise, the same lock instance
that was previously returned for itprotected abstract T createLock(String lockName)
WARNING: This method may be called by multiple threads at once. The implementation
of getLockForName(String) will ensure that only one of the created lock instances is ever
returned, but this factory method must create lock objects for which creating an extra lock of the same name
causes no problems so long as the extra lock is never actually used. If this in not possible, then the
cluster lock service should implement ClusterLockService.getLockForName(String) and
ManagedClusterLockService.getAllKnownClusterLocks() directly instead of using this lock registry.
lockName - the name of the lock to createCopyright © 2019 Atlassian. All rights reserved.