public abstract class AbstractResource<T extends Resource<T>> extends Object implements Resource<T>
Resource.Config, Resource.Options, Resource.State| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
close()
Closes the resource.
|
Resource.Config |
config()
Returns the resource configuration.
|
ThreadContext |
context()
Returns the resource thread context.
|
CompletableFuture<Void> |
delete()
Deletes the resource state.
|
boolean |
equals(Object object) |
int |
hashCode() |
boolean |
isClosed() |
boolean |
isOpen() |
Listener<Resource.State> |
onStateChange(Consumer<Resource.State> callback)
Registers a resource state change listener.
|
CompletableFuture<T> |
open()
Opens the resource.
|
Resource.Options |
options()
Returns the resource options.
|
Serializer |
serializer()
Returns the resource serializer.
|
Resource.State |
state()
Returns the current resource state.
|
String |
toString() |
ResourceType |
type()
Returns the resource type.
|
public ResourceType type()
Resourcepublic Serializer serializer()
Resourceserializer in interface Resource<T extends Resource<T>>public Resource.Config config()
Resourcepublic Resource.Options options()
Resourcepublic Resource.State state()
Resource
The resource's Resource.State is indicative of the resource's ability to communicate with the cluster at any given
time. Users of the resource should use the state to determine when guarantees may be lost. See the Resource.State
documentation for information on the specific states, and see resource implementation documentation for the
implications of different states on resource consistency.
public Listener<Resource.State> onStateChange(Consumer<Resource.State> callback)
ResourceonStateChange in interface Resource<T extends Resource<T>>callback - The callback to call when the resource state changes.public ThreadContext context()
Resourcepublic CompletableFuture<T> open()
Resource
Once the resource is opened, the resource will be transitioned to the Resource.State.CONNECTED state
and the returned CompletableFuture will be completed.
public CompletableFuture<Void> close()
Resource
Once the resource is closed, the resource will be transitioned to the Resource.State.CLOSED state and
the returned CompletableFuture will be completed. Thereafter, attempts to operate on the resource
will fail.
public boolean isClosed()
public CompletableFuture<Void> delete()
ResourceCopyright © 2013–2016. All rights reserved.