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, the node usually establishes
MASTER
or REPLICA
state before returning from
the constructor. However, these states are actually preceeded by the
UNKNOWN
state, which may be visible if the application has
configured a suitable ReplicationConfig.ENV_UNKNOWN_STATE_TIMEOUT
.
As the various remote nodes in the group become unavailable and
elections are held, the local node may change between
MASTER
and REPLICA
states, always with a
(usually brief) transition through UNKNOWN
state.
When the last handle to the environment is closed, the node transitions
to the DETACHED
state.
The state transitions visible to the application can be summarized by the regular expression:
[ MASTER | REPLICA | UNKNOWN ]+ DETACHED
with the caveat that redundant "transitions" (MASTER
to
MASTER
, REPLICA
to REPLICA
, etc.)
never occur.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 the master, but is actively
trying to establish contact with, or 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) 2002, 2017 Oracle and/or its affiliates. All rights reserved.