Class ClusterStateCreationUtils
java.lang.Object
org.elasticsearch.action.support.replication.ClusterStateCreationUtils
Helper methods for generating cluster states
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClusterState
Creates cluster state with the given indices, each index containing #(numberOfPrimaries) started primary shards and no replicas.static ClusterState
state
(String index, boolean activePrimaryLocal, ShardRoutingState primaryState, ShardRoutingState... replicaStates) Creates cluster state with and index that has one shard and #(replicaStates) replicasstatic ClusterState
Creates cluster state with an index that has #(numberOfPrimaries) primary shards in the started state and no replicas.static ClusterState
state
(DiscoveryNode localNode, DiscoveryNode masterNode, DiscoveryNode... allNodes) Creates a cluster state where local node and master node can be specifiedstatic ClusterState
state
(DiscoveryNode localNode, DiscoveryNode masterNode, DiscoveryNode healthNode, DiscoveryNode... allNodes) Creates a cluster state where local node, master and health node can be specifiedstatic ClusterState
stateWithActivePrimary
(String index, boolean activePrimaryLocal, int numberOfReplicas) Creates cluster state with and index that has one shard and as many replicas as numberOfReplicas.static ClusterState
stateWithActivePrimary
(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 ClusterState
stateWithAssignedPrimariesAndOneReplica
(String index, int numberOfShards) Creates cluster state with several shards and one replica and all shards STARTED.static ClusterState
stateWithAssignedPrimariesAndReplicas
(String[] indices, int numberOfShards, int numberOfReplicas) Creates cluster state with several indexes, shards and replicas and all shards STARTED.static ClusterState
Creates a cluster state with no index
-
Constructor Details
-
ClusterStateCreationUtils
public ClusterStateCreationUtils()
-
-
Method Details
-
state
public static ClusterState state(String index, boolean activePrimaryLocal, ShardRoutingState primaryState, ShardRoutingState... replicaStates) Creates cluster state with and index that has one shard and #(replicaStates) replicas- Parameters:
index
- name of the indexactivePrimaryLocal
- if active primary should coincide with the local node in the cluster stateprimaryState
- state of primaryreplicaStates
- states of the replicas. length of this array determines also the number of replicas
-
state
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
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 ClusterState stateWithAssignedPrimariesAndOneReplica(String index, int numberOfShards) Creates cluster state with several shards and one replica and all shards STARTED. -
stateWithAssignedPrimariesAndReplicas
public static ClusterState stateWithAssignedPrimariesAndReplicas(String[] indices, int numberOfShards, int numberOfReplicas) Creates cluster state with several indexes, shards and replicas and all shards STARTED. -
stateWithActivePrimary
public static ClusterState stateWithActivePrimary(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 indexactivePrimaryLocal
- if active primary should coincide with the local node in the cluster statenumberOfReplicas
- number of replicas
-
stateWithActivePrimary
public static ClusterState stateWithActivePrimary(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 indexactivePrimaryLocal
- if active primary should coincide with the local node in the cluster stateassignedReplicas
- number of replicas that should have INITIALIZING, STARTED or RELOCATING stateunassignedReplicas
- number of replicas that should be unassigned
-
stateWithNoShard
Creates a cluster state with no index -
state
public static ClusterState state(DiscoveryNode localNode, DiscoveryNode masterNode, DiscoveryNode... allNodes) Creates a cluster state where local node and master node can be specified- Parameters:
localNode
- node in allNodes that is the local nodemasterNode
- node in allNodes that is the master node. Can be null if no master existsallNodes
- all nodes in the cluster- Returns:
- cluster state
-
state
public static ClusterState state(DiscoveryNode localNode, DiscoveryNode masterNode, DiscoveryNode healthNode, DiscoveryNode... allNodes) Creates a cluster state where local node, master and health node can be specified- Parameters:
localNode
- node in allNodes that is the local nodemasterNode
- node in allNodes that is the master node. Can be null if no master existshealthNode
- node in allNodes that is the health node. Can be null if no health node existsallNodes
- all nodes in the cluster- Returns:
- cluster state
-