Class ClusterStateCreationUtils
java.lang.Object
org.elasticsearch.action.support.replication.ClusterStateCreationUtils
Helper methods for generating cluster states
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.elasticsearch.cluster.ClusterState
Creates cluster state with the given indices, each index containing #(numberOfPrimaries) started primary shards and no replicas.static org.elasticsearch.cluster.ClusterState
state
(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) replicasstatic org.elasticsearch.cluster.ClusterState
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 specifiedstatic org.elasticsearch.cluster.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 org.elasticsearch.cluster.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 org.elasticsearch.cluster.ClusterState
stateWithAssignedPrimariesAndOneReplica
(String index, int numberOfShards) Creates cluster state with several shards and one replica and all shards STARTED.static org.elasticsearch.cluster.ClusterState
stateWithAssignedPrimariesAndReplicas
(String[] indices, int numberOfShards, int numberOfReplicas) Creates cluster state with several indexes, shards and replicas and all shards STARTED.static org.elasticsearch.cluster.ClusterState
Creates a cluster state with no index
-
Constructor Details
-
ClusterStateCreationUtils
public ClusterStateCreationUtils()
-
-
Method Details
-
state
public static org.elasticsearch.cluster.ClusterState state(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 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
public static org.elasticsearch.cluster.ClusterState state(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, 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(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(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(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 org.elasticsearch.cluster.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
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 nodemasterNode
- node in allNodes that is the master node. Can be null if no master existsallNodes
- all nodes in the cluster- Returns:
- cluster state
-