Package org.onosproject.store.service
Interface DistributedLock
-
- All Superinterfaces:
DistributedPrimitive
- All Known Implementing Classes:
DefaultDistributedLock
public interface DistributedLock extends DistributedPrimitive
Asynchronous lock primitive.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.onosproject.store.service.DistributedPrimitive
DistributedPrimitive.Status, DistributedPrimitive.Type
-
-
Field Summary
-
Fields inherited from interface org.onosproject.store.service.DistributedPrimitive
DEFAULT_OPERATION_TIMEOUT_MILLIS
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Versionlock()Acquires the lock, blocking until it's available.default DistributedPrimitive.TypeprimitiveType()Returns the type of primitive.Optional<Version>tryLock()Attempts to acquire the lock.Optional<Version>tryLock(Duration timeout)Attempts to acquire the lock for a specified amount of time.voidunlock()Unlocks the lock.-
Methods inherited from interface org.onosproject.store.service.DistributedPrimitive
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
-
-
-
-
Method Detail
-
primitiveType
default DistributedPrimitive.Type primitiveType()
Description copied from interface:DistributedPrimitiveReturns the type of primitive.- Specified by:
primitiveTypein interfaceDistributedPrimitive- Returns:
- primitive type
-
lock
Version lock()
Acquires the lock, blocking until it's available.- Returns:
- the acquired lock version
-
tryLock
Optional<Version> tryLock()
Attempts to acquire the lock.- Returns:
- indicates whether the lock was acquired
-
tryLock
Optional<Version> tryLock(Duration timeout)
Attempts to acquire the lock for a specified amount of time.- Parameters:
timeout- the timeout after which to give up attempting to acquire the lock- Returns:
- indicates whether the lock was acquired
-
unlock
void unlock()
Unlocks the lock.
-
-