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)
java.util.concurrent.CompletableFuture<Version>
lock()
Acquires the lock, blocking until it's available.default DistributedPrimitive.Type
primitiveType()
Returns the type of primitive.java.util.concurrent.CompletableFuture<java.util.Optional<Version>>
tryLock()
Attempts to acquire the lock.java.util.concurrent.CompletableFuture<java.util.Optional<Version>>
tryLock(java.time.Duration timeout)
Attempts to acquire the lock for a specified amount of time.java.util.concurrent.CompletableFuture<java.lang.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
java.util.concurrent.CompletableFuture<Version> lock()
Acquires the lock, blocking until it's available.- Returns:
- future to be completed once the lock has been acquired
-
tryLock
java.util.concurrent.CompletableFuture<java.util.Optional<Version>> tryLock()
Attempts to acquire the lock.- Returns:
- future to be completed with a boolean indicating whether the lock was acquired
-
tryLock
java.util.concurrent.CompletableFuture<java.util.Optional<Version>> tryLock(java.time.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
java.util.concurrent.CompletableFuture<java.lang.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)
-
-