ReplicatedEnvironment.State (Oracle - Berkeley DB Java Edition API)
Date: 2014-12-16

com.sleepycat.je.rep

## Enum ReplicatedEnvironment.State

- java.lang.Object
- - java.lang.Enum<ReplicatedEnvironment.State>
  - - com.sleepycat.je.rep.ReplicatedEnvironment.State

- All Implemented Interfaces:
    Serializable, Comparable<ReplicatedEnvironment.State>
  Enclosing class:
    ReplicatedEnvironment

      public static enum ReplicatedEnvironment.State
      extends Enum<ReplicatedEnvironment.State>

  The replication node state determines the operations that the application can perform against its replicated environment. The method `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 Summary

    Enum Constants
    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.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isActive()`
    `boolean` | `isDetached()`
    `boolean` | `isMaster()`
    `boolean` | `isReplica()`
    `boolean` | `isUnknown()`
    `static ReplicatedEnvironment.State` | `valueOf(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.

    - ### Methods inherited from class java.lang.Enum

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### DETACHED

          public static final ReplicatedEnvironment.State DETACHED

      The node is not associated with the group. Its handle has been closed. No operations can be performed on the environment when it is in this state.

    - #### UNKNOWN

          public static final ReplicatedEnvironment.State UNKNOWN

      The node is not currently in contact with the master, but is actively trying to establish contact with, or decide upon, a master. While in this state the node is restricted to performing just read operations on its environment. In a functioning group, this state is transitory.

    - #### MASTER

          public static final ReplicatedEnvironment.State MASTER

      The node is the unique master of the group and can both read and write to its environment. When the node transitions to the state, the application running on the node must make provisions to start processing application level write requests in addition to read requests.

    - #### REPLICA

          public static final ReplicatedEnvironment.State REPLICA

      The node is a replica that is being updated by the master. It is restricted to reading its environment. When the node transitions to this state, the application running on the node must make provisions to ensure that it does not write to the environment. It must arrange for all write requests to be routed to the master.

  - ### Method Detail

    - #### values

          public static ReplicatedEnvironment.State[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (ReplicatedEnvironment.State c : ReplicatedEnvironment.State.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static ReplicatedEnvironment.State valueOf(String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `IllegalArgumentException` - if this enum type has no constant with the specified name
        `NullPointerException` - if the argument is null

    - #### isMaster

          public final boolean isMaster()

      Returns:
        true if the node is a Master when in this state

    - #### isReplica

          public final boolean isReplica()

      Returns:
        true if the node is a Replica when in this state

    - #### isDetached

          public final boolean isDetached()

      Returns:
        true if the node is disconnected from the replication group when in this state.

    - #### isUnknown

          public final boolean isUnknown()

      Returns:
        true if the node's state is unknown, and it is attempting to transition to Master or Replica.

    - #### isActive

          public final boolean isActive()

      Returns:
        true if the node is currently participating in the group as a Replica or a Master

Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved.