Class ClusterStateCreationUtils

java.lang.Object
org.elasticsearch.action.support.replication.ClusterStateCreationUtils

public class ClusterStateCreationUtils
extends java.lang.Object
Helper methods for generating cluster states
  • Constructor Summary

    Constructors
    Constructor Description
    ClusterStateCreationUtils()  
  • Method Summary

    Modifier and Type Method Description
    static org.elasticsearch.cluster.ClusterState state​(int numberOfNodes, java.lang.String[] indices, int numberOfPrimaries)
    Creates cluster state with the given indices, each index containing #(numberOfPrimaries) started primary shards and no replicas.
    static org.elasticsearch.cluster.ClusterState state​(java.lang.String index, boolean activePrimaryLocal, org.elasticsearch.cluster.routing.ShardRoutingState primaryState, org.elasticsearch.cluster.routing.ShardRoutingState... replicaStates)
    Creates cluster state with and index that has one shard and #(replicaStates) replicas
    static org.elasticsearch.cluster.ClusterState state​(java.lang.String index, int numberOfNodes, int numberOfPrimaries)
    Creates cluster state with an index that has #(numberOfPrimaries) primary shards in the started state and no replicas.
    static org.elasticsearch.cluster.ClusterState state​(org.elasticsearch.cluster.node.DiscoveryNode localNode, org.elasticsearch.cluster.node.DiscoveryNode masterNode, org.elasticsearch.cluster.node.DiscoveryNode... allNodes)
    Creates a cluster state where local node and master node can be specified
    static org.elasticsearch.cluster.ClusterState stateWithActivePrimary​(java.lang.String index, boolean activePrimaryLocal, int numberOfReplicas)
    Creates cluster state with and index that has one shard and as many replicas as numberOfReplicas.
    static org.elasticsearch.cluster.ClusterState stateWithActivePrimary​(java.lang.String index, boolean activePrimaryLocal, int assignedReplicas, int unassignedReplicas)
    Creates cluster state with and index that has one shard and as many replicas as numberOfReplicas.
    static org.elasticsearch.cluster.ClusterState stateWithAssignedPrimariesAndOneReplica​(java.lang.String index, int numberOfShards)
    Creates cluster state with several shards and one replica and all shards STARTED.
    static org.elasticsearch.cluster.ClusterState stateWithAssignedPrimariesAndReplicas​(java.lang.String[] indices, int numberOfShards, int numberOfReplicas)
    Creates cluster state with several indexes, shards and replicas and all shards STARTED.
    static org.elasticsearch.cluster.ClusterState stateWithNoShard()
    Creates a cluster state with no index

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ClusterStateCreationUtils

      public ClusterStateCreationUtils()
  • Method Details

    • state

      public static org.elasticsearch.cluster.ClusterState state​(java.lang.String index, boolean activePrimaryLocal, org.elasticsearch.cluster.routing.ShardRoutingState primaryState, org.elasticsearch.cluster.routing.ShardRoutingState... replicaStates)
      Creates cluster state with and index that has one shard and #(replicaStates) replicas
      Parameters:
      index - name of the index
      activePrimaryLocal - if active primary should coincide with the local node in the cluster state
      primaryState - state of primary
      replicaStates - states of the replicas. length of this array determines also the number of replicas
    • state

      public static org.elasticsearch.cluster.ClusterState state​(java.lang.String index, int numberOfNodes, int numberOfPrimaries)
      Creates cluster state with an index that has #(numberOfPrimaries) primary shards in the started state and no replicas. The cluster state contains #(numberOfNodes) nodes and assigns primaries to those nodes.
    • state

      public static org.elasticsearch.cluster.ClusterState state​(int numberOfNodes, java.lang.String[] indices, int numberOfPrimaries)
      Creates cluster state with the given indices, each index containing #(numberOfPrimaries) started primary shards and no replicas. The cluster state contains #(numberOfNodes) nodes and assigns primaries to those nodes.
    • stateWithAssignedPrimariesAndOneReplica

      public static org.elasticsearch.cluster.ClusterState stateWithAssignedPrimariesAndOneReplica​(java.lang.String index, int numberOfShards)
      Creates cluster state with several shards and one replica and all shards STARTED.
    • stateWithAssignedPrimariesAndReplicas

      public static org.elasticsearch.cluster.ClusterState stateWithAssignedPrimariesAndReplicas​(java.lang.String[] indices, int numberOfShards, int numberOfReplicas)
      Creates cluster state with several indexes, shards and replicas and all shards STARTED.
    • stateWithActivePrimary

      public static org.elasticsearch.cluster.ClusterState stateWithActivePrimary​(java.lang.String index, boolean activePrimaryLocal, int numberOfReplicas)
      Creates cluster state with and index that has one shard and as many replicas as numberOfReplicas. Primary will be STARTED in cluster state but replicas will be one of UNASSIGNED, INITIALIZING, STARTED or RELOCATING.
      Parameters:
      index - name of the index
      activePrimaryLocal - if active primary should coincide with the local node in the cluster state
      numberOfReplicas - number of replicas
    • stateWithActivePrimary

      public static org.elasticsearch.cluster.ClusterState stateWithActivePrimary​(java.lang.String index, boolean activePrimaryLocal, int assignedReplicas, int unassignedReplicas)
      Creates cluster state with and index that has one shard and as many replicas as numberOfReplicas. Primary will be STARTED in cluster state. Some (unassignedReplicas) will be UNASSIGNED and some (assignedReplicas) will be one of INITIALIZING, STARTED or RELOCATING.
      Parameters:
      index - name of the index
      activePrimaryLocal - if active primary should coincide with the local node in the cluster state
      assignedReplicas - number of replicas that should have INITIALIZING, STARTED or RELOCATING state
      unassignedReplicas - number of replicas that should be unassigned
    • stateWithNoShard

      public static org.elasticsearch.cluster.ClusterState stateWithNoShard()
      Creates a cluster state with no index
    • state

      public static org.elasticsearch.cluster.ClusterState state​(org.elasticsearch.cluster.node.DiscoveryNode localNode, org.elasticsearch.cluster.node.DiscoveryNode masterNode, org.elasticsearch.cluster.node.DiscoveryNode... allNodes)
      Creates a cluster state where local node and master node can be specified
      Parameters:
      localNode - node in allNodes that is the local node
      masterNode - node in allNodes that is the master node. Can be null if no master exists
      allNodes - all nodes in the cluster
      Returns:
      cluster state