T - resource typepublic interface ResourceManager<T extends ResourceManager<T>>
Resources remotely.| Modifier and Type | Method and Description |
|---|---|
ThreadContext |
context()
Returns the Atomix thread context.
|
CompletableFuture<Boolean> |
exists(String key)
Checks whether a resource exists with the given key.
|
<T extends io.atomix.resource.Resource> |
getResource(String key,
Class<? super T> type)
Gets or creates the given resource and acquires a singleton reference to it.
|
<T extends io.atomix.resource.Resource> |
getResource(String key,
Class<? super T> type,
io.atomix.resource.Resource.Config config)
Gets or creates the given resource and acquires a singleton reference to it.
|
<T extends io.atomix.resource.Resource> |
getResource(String key,
Class<? super T> type,
io.atomix.resource.Resource.Config config,
io.atomix.resource.Resource.Options options)
Gets or creates the given resource and acquires a singleton reference to it.
|
<T extends io.atomix.resource.Resource> |
getResource(String key,
Class<? super T> type,
io.atomix.resource.Resource.Options options)
Gets or creates the given resource and acquires a singleton reference to it.
|
<T extends io.atomix.resource.Resource> |
getResource(String key,
io.atomix.resource.ResourceType type)
Gets or creates the given resource and acquires a singleton reference to it.
|
<T extends io.atomix.resource.Resource> |
getResource(String key,
io.atomix.resource.ResourceType type,
io.atomix.resource.Resource.Config config)
Gets or creates the given resource and acquires a singleton reference to it.
|
<T extends io.atomix.resource.Resource> |
getResource(String key,
io.atomix.resource.ResourceType type,
io.atomix.resource.Resource.Config config,
io.atomix.resource.Resource.Options options)
Gets or creates the given resource and acquires a singleton reference to it.
|
<T extends io.atomix.resource.Resource> |
getResource(String key,
io.atomix.resource.ResourceType type,
io.atomix.resource.Resource.Options options)
Gets or creates the given resource and acquires a singleton reference to it.
|
CompletableFuture<Set<String>> |
keys()
Returns keys of all existing resources.
|
<T extends io.atomix.resource.Resource> |
keys(Class<? super T> type)
Returns the keys of existing resources belonging to a resource type.
|
CompletableFuture<Set<String>> |
keys(io.atomix.resource.ResourceType type)
Returns the keys of existing resources belonging to a resource type.
|
Serializer |
serializer()
Returns the resource manager serializer.
|
io.atomix.resource.ResourceType |
type(Class<? extends io.atomix.resource.Resource<?>> type)
Returns the resource type for the given resource class.
|
ThreadContext context()
This context is representative of the thread on which asynchronous callbacks will be executed for this
Atomix instance. Atomix guarantees that all CompletableFutures supplied by this instance will
be executed via the returned context. Users can use the context to access the thread-local
Serializer.
Serializer serializer()
The serializer applies to all resources controlled by this instance. Serializable types registered
on the serializer will be reflected at the Transport layer.
Types registered on the client must also be registered on the server for deserialization.
io.atomix.resource.ResourceType type(Class<? extends io.atomix.resource.Resource<?>> type)
type - The resource class.IllegalArgumentException - if type is unregisteredCompletableFuture<Boolean> exists(String key)
If no resource with the given key exists in the cluster, the returned CompletableFuture will
be completed false. Note, however, that users should not significantly rely upon the existence or
non-existence of a resource due to race conditions. While a resource may not exist when the returned future is
completed, it may be created by another node shortly thereafter.
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
if (!atomix.exists("lock").get()) {
DistributedLock lock = atomix.getResource("lock", DistributedLock.class).get();
}
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.exists("lock").thenAccept(exists -> {
if (!exists) {
atomix.<DistributedLock>getResource("lock", DistributedLock.class).thenAccept(lock -> {
...
});
}
});
key - The key to check.NullPointerException - if key is nullCompletableFuture<Set<String>> keys()
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
Collection<String> resourceKeys = atomix.keys().get();
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.<Collection<String>>keys().thenAccept(resourceKeys -> {
...
});
<T extends io.atomix.resource.Resource> CompletableFuture<Set<String>> keys(Class<? super T> type)
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
Set<String> resourceKeys = atomix.keys(DistributedLock.class).get();
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.<Set<String>>keys().thenAccept(resourceKeys -> {
...
});
T - The resource type.type - The resource type by which to filter resources.NullPointerException - if type is nullCompletableFuture<Set<String>> keys(io.atomix.resource.ResourceType type)
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
Set<String> resourceKeys = atomix.keys(DistributedLock.class).get();
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.<Set<String>>keys().thenAccept(resourceKeys -> {
...
});
type - The resource type by which to filter resources.<T extends io.atomix.resource.Resource> CompletableFuture<T> getResource(String key, Class<? super T> type)
If a resource at the given key already exists, the resource will be validated to verify that its type matches the given type. If no resource yet exists, a new resource will be created in the cluster. Once the session for the resource has been opened, a resource instance will be returned.
The returned Resource instance will be a singleton reference to an global instance for this node.
That is, multiple calls to this method for the same resource will result in the same Resource
instance being returned.
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
DistributedLock lock = atomix.getResource("lock", DistributedLock.class).get();
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.<DistributedLock>getResource("lock", DistributedLock.class).thenAccept(lock -> {
...
});
T - The resource type.key - The key at which to get the resource.type - The expected resource type.NullPointerException - if key or type are nullIllegalArgumentException - if type is inconsistent with a previously created type<T extends io.atomix.resource.Resource> CompletableFuture<T> getResource(String key, Class<? super T> type, io.atomix.resource.Resource.Config config)
If a resource at the given key already exists, the resource will be validated to verify that its type matches the given type. If no resource yet exists, a new resource will be created in the cluster. Once the session for the resource has been opened, a resource instance will be returned.
The returned Resource instance will be a singleton reference to an global instance for this node.
That is, multiple calls to this method for the same resource will result in the same Resource
instance being returned.
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
DistributedLock lock = atomix.getResource("lock", DistributedLock.class).get();
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.<DistributedLock>getResource("lock", DistributedLock.class).thenAccept(lock -> {
...
});
T - The resource type.key - The key at which to get the resource.type - The expected resource type.config - The cluster-wide resource configuration.NullPointerException - if key or type are nullIllegalArgumentException - if type is inconsistent with a previously created type<T extends io.atomix.resource.Resource> CompletableFuture<T> getResource(String key, Class<? super T> type, io.atomix.resource.Resource.Options options)
If a resource at the given key already exists, the resource will be validated to verify that its type matches the given type. If no resource yet exists, a new resource will be created in the cluster. Once the session for the resource has been opened, a resource instance will be returned.
The returned Resource instance will be a singleton reference to an global instance for this node.
That is, multiple calls to this method for the same resource will result in the same Resource
instance being returned.
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
DistributedLock lock = atomix.getResource("lock", DistributedLock.class).get();
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.<DistributedLock>getResource("lock", DistributedLock.class).thenAccept(lock -> {
...
});
T - The resource type.key - The key at which to get the resource.type - The expected resource type.options - The local resource options.NullPointerException - if key or type are nullIllegalArgumentException - if type is inconsistent with a previously created type<T extends io.atomix.resource.Resource> CompletableFuture<T> getResource(String key, Class<? super T> type, io.atomix.resource.Resource.Config config, io.atomix.resource.Resource.Options options)
If a resource at the given key already exists, the resource will be validated to verify that its type matches the given type. If no resource yet exists, a new resource will be created in the cluster. Once the session for the resource has been opened, a resource instance will be returned.
The returned Resource instance will be a singleton reference to an global instance for this node.
That is, multiple calls to this method for the same resource will result in the same Resource
instance being returned.
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
DistributedLock lock = atomix.getResource("lock", DistributedLock.class).get();
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.<DistributedLock>getResource("lock", DistributedLock.class).thenAccept(lock -> {
...
});
T - The resource type.key - The key at which to get the resource.type - The expected resource type.config - The cluster-wide resource configuration.options - The local resource options.NullPointerException - if key or type are nullIllegalArgumentException - if type is inconsistent with a previously created type<T extends io.atomix.resource.Resource> CompletableFuture<T> getResource(String key, io.atomix.resource.ResourceType type)
If a resource at the given key already exists, the resource will be validated to verify that its type matches the given type. If no resource yet exists, a new resource will be created in the cluster. Once the session for the resource has been opened, a resource instance will be returned.
The returned Resource instance will be a singleton reference to an global instance for this node.
That is, multiple calls to this method for the same resource will result in the same Resource
instance being returned.
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
DistributedLock lock = atomix.getResource("lock", DistributedLock.class).get();
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.<DistributedLock>getResource("lock", DistributedLock.class).thenAccept(lock -> {
...
});
T - The resource type.key - The key at which to get the resource.type - The expected resource type.NullPointerException - if key or type are nullIllegalArgumentException - if type is inconsistent with a previously created type<T extends io.atomix.resource.Resource> CompletableFuture<T> getResource(String key, io.atomix.resource.ResourceType type, io.atomix.resource.Resource.Config config)
If a resource at the given key already exists, the resource will be validated to verify that its type matches the given type. If no resource yet exists, a new resource will be created in the cluster. Once the session for the resource has been opened, a resource instance will be returned.
The returned Resource instance will be a singleton reference to an global instance for this node.
That is, multiple calls to this method for the same resource will result in the same Resource
instance being returned.
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
DistributedLock lock = atomix.getResource("lock", DistributedLock.class).get();
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.<DistributedLock>getResource("lock", DistributedLock.class).thenAccept(lock -> {
...
});
T - The resource type.key - The key at which to get the resource.type - The expected resource type.config - The cluster-wide resource configuration.NullPointerException - if key or type are nullIllegalArgumentException - if type is inconsistent with a previously created type<T extends io.atomix.resource.Resource> CompletableFuture<T> getResource(String key, io.atomix.resource.ResourceType type, io.atomix.resource.Resource.Options options)
If a resource at the given key already exists, the resource will be validated to verify that its type matches the given type. If no resource yet exists, a new resource will be created in the cluster. Once the session for the resource has been opened, a resource instance will be returned.
The returned Resource instance will be a singleton reference to an global instance for this node.
That is, multiple calls to this method for the same resource will result in the same Resource
instance being returned.
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
DistributedLock lock = atomix.getResource("lock", DistributedLock.class).get();
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.<DistributedLock>getResource("lock", DistributedLock.class).thenAccept(lock -> {
...
});
T - The resource type.key - The key at which to get the resource.type - The expected resource type.options - The local resource options.NullPointerException - if key or type are nullIllegalArgumentException - if type is inconsistent with a previously created type<T extends io.atomix.resource.Resource> CompletableFuture<T> getResource(String key, io.atomix.resource.ResourceType type, io.atomix.resource.Resource.Config config, io.atomix.resource.Resource.Options options)
If a resource at the given key already exists, the resource will be validated to verify that its type matches the given type. If no resource yet exists, a new resource will be created in the cluster. Once the session for the resource has been opened, a resource instance will be returned.
The returned Resource instance will be a singleton reference to an global instance for this node.
That is, multiple calls to this method for the same resource will result in the same Resource
instance being returned.
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.get() method:
DistributedLock lock = atomix.getResource("lock", DistributedLock.class).get();
Alternatively, to execute the operation asynchronous and be notified once the result is received in a different
thread, use one of the many completable future callbacks:
atomix.<DistributedLock>getResource("lock", DistributedLock.class).thenAccept(lock -> {
...
});
T - The resource type.key - The key at which to get the resource.type - The expected resource type.config - The cluster-wide resource configuration.options - The local resource options.NullPointerException - if key or type are nullIllegalArgumentException - if type is inconsistent with a previously created typeCopyright © 2013–2016. All rights reserved.