public interface AsyncLock extends Resource<AsyncLock>
| Modifier and Type | Method and Description |
|---|---|
static AsyncLock |
create(String name)
Creates a new asynchronous lock with the default cluster configuration.
|
static AsyncLock |
create(String name,
ClusterConfig cluster)
Creates a new asynchronous lock.
|
static AsyncLock |
create(String name,
ClusterConfig cluster,
AsyncLockConfig config)
Creates a new asynchronous lock.
|
CompletableFuture<Boolean> |
lock()
Acquires the lock.
|
CompletableFuture<Void> |
unlock()
Releases the lock.
|
addShutdownTask, addStartupTask, cluster, namestatic AsyncLock create(String name)
The lock will be constructed with the default cluster configuration. The default cluster configuration
searches for two resources on the classpath - cluster and {cluster-defaults} - in that order. Configuration
options specified in cluster.conf will override those in {cluster-defaults.conf}.
Additionally, the lock will be constructed with an lock configuration that searches the classpath for
three configuration files - {name}, lock, lock-defaults, resource, and
resource-defaults - in that order. The first resource is a configuration resource with the same name
as the lock resource. If the resource is namespaced - e.g. `locks.my-lock.conf` - then resource
configurations will be loaded according to namespaces as well; for example, `locks.conf`.
name - The asynchronous lock name.static AsyncLock create(String name, ClusterConfig cluster)
The lock will be constructed with an lock configuration that searches the classpath for three configuration
files - {name}, lock, lock-defaults, resource, and
resource-defaults - in that order. The first resource is a configuration resource with the same name
as the lock resource. If the resource is namespaced - e.g. `locks.my-lock.conf` - then resource
configurations will be loaded according to namespaces as well; for example, `locks.conf`.
name - The asynchronous lock name.cluster - The cluster configuration.static AsyncLock create(String name, ClusterConfig cluster, AsyncLockConfig config)
name - The asynchronous lock name.cluster - The cluster configuration.config - The lock configuration.CompletableFuture<Boolean> lock()
CompletableFuture<Void> unlock()
Copyright © 2013-2015. All Rights Reserved.