com.hazelcast.cluster

## Enum ClusterState

- java.lang.Object
- - java.lang.Enum<ClusterState>
  - - com.hazelcast.cluster.ClusterState

- All Implemented Interfaces:
    Serializable, Comparable<ClusterState>

      public enum ClusterState
      extends Enum<ClusterState>

  `ClusterState` are several possible states of the cluster where each state can allow and/or deny specific actions and/or change behavior of specific actions.

  There are 5 states:

  1. `ACTIVE`: Cluster will continue to operate without any restriction.
  2. `NO_MIGRATION`: Migrations (partition rebalancing) and backup replications are not allowed. Cluster will continue to operate without any restriction.
  3. `FROZEN`: New members are not allowed to join, partition table/assignments will be frozen. All other operations are allowed and will operate without any restriction. If some members leave the cluster while it is in `FROZEN` state, they can join back.
  4. `PASSIVE`: New members are not allowed to join. All operations, except the ones marked with `AllowedDuringPassiveState`, will be rejected immediately.
  5. `IN_TRANSITION`: Shows that `ClusterState` is in transition. This is a temporary & intermediate state, not allowed to be set explicitly.

  By default, cluster will be in `ACTIVE` state. During split-brain merge process, state of the cluster, that is going to join to the major side, will be changed to `FROZEN` automatically before merge and will be set to the state of the new cluster after merge.
  Since:
    3.6
  See Also:
    `Cluster.getClusterState()`, `Cluster.changeClusterState(ClusterState)`, `NodeState`

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `ACTIVE` In `ACTIVE` state, cluster will continue to operate without any restriction.
    `FROZEN` In `FROZEN` state of the cluster: New members are not allowed to join, except the members left during `FROZEN` or `PASSIVE` state.
    `IN_TRANSITION` Shows that ClusterState is in transition.
    `NO_MIGRATION` In `NO_MIGRATION` state of the cluster, migrations (partition rebalancing) and backup replications are not allowed.
    `PASSIVE` In `PASSIVE` state of the cluster: New members are not allowed to join, except the members left during `FROZEN` or `PASSIVE` state.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isJoinAllowed()` Returns `true`, if joining of a new member is allowed in this state.
    `boolean` | `isMigrationAllowed()` Returns `true`, if migrations and replications are allowed in this state.
    `boolean` | `isPartitionPromotionAllowed()` Returns `true`, if partition promotions are allowed in this state.
    `static ClusterState` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
    `static ClusterState[]` | `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

    - #### ACTIVE

          public static final ClusterState ACTIVE

      In `ACTIVE` state, cluster will continue to operate without any restriction. All operations are allowed. This is the default state of a cluster.

    - #### NO_MIGRATION

          public static final ClusterState NO_MIGRATION

      In `NO_MIGRATION` state of the cluster, migrations (partition rebalancing) and backup replications are not allowed.
      - When a new member joins, it will not be assigned any partitions until cluster state changes to `ACTIVE`.
      - When a member leaves, backups of primary replicas owned by that member will be promoted to primary. But missing backup replicas will not be created/replicated until cluster state changes to `ACTIVE`.
      Cluster will continue to operate without any restriction. All operations are allowed.
      Since:
        3.9

    - #### FROZEN

          public static final ClusterState FROZEN

      In `FROZEN` state of the cluster:
      - New members are not allowed to join, except the members left during `FROZEN` or `PASSIVE` state. For example, cluster has 3 nodes; A, B and C in `FROZEN` state. If member B leaves the cluster (either proper shutdown or crash), it will be allowed to re-join to the cluster. But another member D, won't be able to join.
      - Partition table/assignments will be frozen. When a member leaves the cluster, its partition assignments (as primary and backup) will remain the same, until either that member re-joins to the cluster or `ClusterState` changes back to `ACTIVE`. If that member re-joins while still in `FROZEN`, it will own all previously assigned partitions. If `ClusterState` changes to `ACTIVE` then partition re-balancing process will kick in and all unassigned partitions will be assigned to active members. It's not allowed to change `ClusterState` to `FROZEN` when there are pending migration/replication tasks in the system.
      - Nodes continue to stay in `NodeState.ACTIVE` state when cluster goes into the `FROZEN` state.
      - All other operations except migrations are allowed and will operate without any restriction.

    - #### PASSIVE

          public static final ClusterState PASSIVE

      In `PASSIVE` state of the cluster:
      - New members are not allowed to join, except the members left during `FROZEN` or `PASSIVE` state.
      - Partition table/assignments will be frozen. It's not allowed to change `ClusterState` to `PASSIVE` when there are pending migration/replication tasks in the system. If some nodes leave the cluster while cluster is in `PASSIVE` state, they will be removed from the partition table when cluster state moves back to `ACTIVE`.
      - When cluster state is moved to `PASSIVE`, nodes are moved to `NodeState.PASSIVE` too. Similarly when cluster state moves to another state from `PASSIVE`, nodes become `NodeState.ACTIVE`.
      - All operations, except the ones marked with `AllowedDuringPassiveState`, will be rejected immediately.

    - #### IN_TRANSITION

          public static final ClusterState IN_TRANSITION

      Shows that ClusterState is in transition. When a state change transaction is started, ClusterState will be shown as `IN_TRANSITION` while the transaction is in progress. After the transaction completes, cluster will be either in the new state or in the previous state, depending on transaction result.

      This is a temporary & intermediate state, not allowed to be set explicitly.

      - Similarly to the `FROZEN` state, new members are not allowed and migration/replication process will be paused.
      - If membership change occurs in the cluster, cluster state transition will fail and will be reverted back to the previous state.

  - ### Method Detail

    - #### values

          public static ClusterState[] 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 (ClusterState c : ClusterState.values())
              System.out.println(c);

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

    - #### valueOf

          public static ClusterState 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

    - #### isJoinAllowed

          public boolean isJoinAllowed()

      Returns `true`, if joining of a new member is allowed in this state.

    - #### isMigrationAllowed

          public boolean isMigrationAllowed()

      Returns `true`, if migrations and replications are allowed in this state.

    - #### isPartitionPromotionAllowed

          public boolean isPartitionPromotionAllowed()

      Returns `true`, if partition promotions are allowed in this state.

Copyright © 2019. All rights reserved.