public static enum Resource.State extends Enum<Resource.State>
The resource state is indicative of the resource's ability to communicate with the cluster within the
context of the underlying Session. In some cases, resource state changes may be indicative of a
loss of guarantees. Users of the resource should watch the state
of a resource to determine when guarantees are lost and react to changes in the resource's ability to communicate
with the cluster.
resource.onStateChange(state -> {
switch (state) {
case OPEN:
// The resource is healthy
break;
case SUSPENDED:
// The resource is unhealthy and operations may be unsafe
break;
case CLOSED:
// The resource has been closed and pending operations have failed
break;
}
});
So long as the resource is in the CONNECTED state, all guarantees with respect to reads and writes will
be maintained, and a loss of the CONNECTED state may indicate a loss of linearizability. See the specific
states for more info.
Reference resource documentation for implications of the various states on specific resources.
| Enum Constant and Description |
|---|
CLOSED
Indicates that the resource is closed.
|
CONNECTED
Indicates that the resource is connected and operating normally.
|
SUSPENDED
Indicates that the resource is suspended and its session may or may not be expired.
|
| Modifier and Type | Method and Description |
|---|---|
static Resource.State |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Resource.State[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Resource.State CONNECTED
The CONNECTED state indicates that the resource is healthy and operating normally. Operations submitted
and completed while the resource is in this state are guaranteed to adhere to the configured consistency level.
public static final Resource.State SUSPENDED
The SUSPENDED state is indicative of an inability to communicate with the cluster within the context of
the underlying client's Session. Operations performed on resources in this state should be considered
unsafe. An operation performed on a CONNECTED resource that transitions to the SUSPENDED state
prior to the operation's completion may be committed multiple times in the event that the underlying session
is ultimately expired, thus breaking linearizability. Additionally, state machines
may see the session expire while the resource is in this state.
A resource that is in the SUSPENDED state may transition back to CONNECTED once its underlying
session is recovered. However, operations not yet completed prior to the resource's recovery may lose linearizability
guarantees. If an operation is submitted while a resource is in the CONNECTED state and the resource loses
and recovers its session, the operation may be applied to the resource's state more than once. Operations completed
across sessions are guaranteed to be performed at-least-once only.
public static final Resource.State CLOSED
A resource may transition to this state as a result of an expired session or an explicit close
by the user or a closure of the resource's underlying client.
public static Resource.State[] values()
for (Resource.State c : Resource.State.values()) System.out.println(c);
public static Resource.State valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullCopyright © 2013–2016. All rights reserved.