public static enum ReplicatedEnvironment.State extends java.lang.Enum<ReplicatedEnvironment.State>
ReplicatedEnvironment.getState()
returns the current state.
When the first handle to a ReplicatedEnvironment
is instantiated
and the node is bought up, it always starts out in the
DETACHED
state and then transitions to the
MASTER
or REPLICA
state before returning from
the constructor.
When nodes in the group become unavailable and elections are held, the
node may transition between MASTER
and REPLICA
states.
When the last handle to the environment is closed, the node transitions
back to the DETACHED
state.
The state transitions for a node can be summarized by the regular expression:
DETACHED [ MASTER | REPLICA | UNKNOWN ]+ DETACHED
, with
the following caveats:
MASTER
state never follows a MASTER
state,
since that would represent a redundant transition.
UNKNOWN
state never follows an
UNKNOWN
state, since that would be redundant transition.
REPLICA
state can follow a REPLICA
state, as
long as this node is not the MASTER
.
The initial DETACHED
state is internal to the JE HA
implementation and is not visible to the application.
Enum Constant and Description |
---|
DETACHED
The node is not associated with the group.
|
MASTER
The node is the unique master of the group and can both read and
write to its environment.
|
REPLICA
The node is a replica that is being updated by the master.
|
UNKNOWN
The node is not currently in contact with its group, but is actively
trying to establish contact and decide upon a master.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isActive() |
boolean |
isDetached() |
boolean |
isMaster() |
boolean |
isReplica() |
boolean |
isUnknown() |
static ReplicatedEnvironment.State |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static ReplicatedEnvironment.State[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ReplicatedEnvironment.State DETACHED
public static final ReplicatedEnvironment.State UNKNOWN
public static final ReplicatedEnvironment.State MASTER
public static final ReplicatedEnvironment.State REPLICA
public static ReplicatedEnvironment.State[] values()
for (ReplicatedEnvironment.State c : ReplicatedEnvironment.State.values()) System.out.println(c);
public static ReplicatedEnvironment.State valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic final boolean isMaster()
public final boolean isReplica()
public final boolean isDetached()
public final boolean isUnknown()
public final boolean isActive()
Copyright (c) 2004-2012 Oracle. All rights reserved.