Package org.onosproject.store.service
Interface AsyncDistributedLock
-
- All Superinterfaces:
DistributedPrimitive
public interface AsyncDistributedLock 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 default DistributedLock
asLock()
default DistributedLock
asLock(long timeoutMillis)
CompletableFuture<Version>
lock()
Acquires the lock, blocking until it's available.default DistributedPrimitive.Type
primitiveType()
Returns the type of primitive.CompletableFuture<Optional<Version>>
tryLock()
Attempts to acquire the lock.CompletableFuture<Optional<Version>>
tryLock(Duration timeout)
Attempts to acquire the lock for a specified amount of time.CompletableFuture<Void>
unlock()
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:DistributedPrimitive
Returns the type of primitive.- Specified by:
primitiveType
in interfaceDistributedPrimitive
- Returns:
- primitive type
-
lock
CompletableFuture<Version> lock()
Acquires the lock, blocking until it's available.- Returns:
- future to be completed once the lock has been acquired
-
tryLock
CompletableFuture<Optional<Version>> tryLock()
Attempts to acquire the lock.- Returns:
- future to be completed with a boolean indicating whether the lock was acquired
-
tryLock
CompletableFuture<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:
- future to be completed with a boolean indicating whether the lock was acquired
-
unlock
CompletableFuture<Void> unlock()
Unlocks the lock.- Returns:
- future to be completed once the lock has been released
-
asLock
default DistributedLock asLock()
-
asLock
default DistributedLock asLock(long timeoutMillis)
-
-