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 ClusterStateCreates cluster state with the given indices, each index containing #(numberOfPrimaries) started primary shards and no replicas.static ClusterStatestate(String index, boolean activePrimaryLocal, ShardRoutingState primaryState, List<org.elasticsearch.core.Tuple<ShardRoutingState, ShardRouting.Role>> replicaStates) Creates cluster state with and index that has one shard and #(replicaStates) replicas with given rolesstatic ClusterStatestate(String index, boolean activePrimaryLocal, ShardRoutingState primaryState, ShardRouting.Role primaryRole, List<org.elasticsearch.core.Tuple<ShardRoutingState, ShardRouting.Role>> replicaStates) Creates cluster state with and index that has one shard and #(replicaStates) replicas with given rolesstatic ClusterStatestate(String index, boolean activePrimaryLocal, ShardRoutingState primaryState, ShardRoutingState... replicaStates) Creates cluster state with and index that has one shard and #(replicaStates) replicasstatic ClusterStateCreates cluster state with an index that has #(numberOfPrimaries) primary shards in the started state and no replicas.static ClusterStatestate(DiscoveryNode localNode, DiscoveryNode masterNode, DiscoveryNode... allNodes) Creates a cluster state where local node and master node can be specifiedstatic ClusterStatestate(DiscoveryNode localNode, DiscoveryNode masterNode, DiscoveryNode[] allNodes, TransportVersion transportVersion) Creates a cluster state where local node and master node can be specifiedstatic ClusterStatestate(DiscoveryNode localNode, DiscoveryNode masterNode, DiscoveryNode healthNode, DiscoveryNode... allNodes) Creates a cluster state where local node, master and health node can be specifiedstatic ClusterStatestate(DiscoveryNode localNode, DiscoveryNode masterNode, DiscoveryNode healthNode, DiscoveryNode[] allNodes, TransportVersion transportVersion) Creates a cluster state where local node, master and health node can be specifiedstatic ClusterStatestateWithActivePrimary(String index, boolean activePrimaryLocal, int numberOfReplicas) Creates cluster state with and index that has one shard and as many replicas as numberOfReplicas.static ClusterStatestateWithActivePrimary(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 ClusterStatestateWithAssignedPrimariesAndOneReplica(String index, int numberOfShards) Creates cluster state with several shards and one replica and all shards STARTED.static ClusterStatestateWithAssignedPrimariesAndReplicas(String[] indices, int numberOfShards, int numberOfReplicas) Creates cluster state with several indexes, shards and replicas and all shards STARTED.static ClusterStatestateWithAssignedPrimariesAndReplicas(String[] indices, int numberOfShards, List<ShardRouting.Role> replicaRoles) Creates cluster state with several indexes, shards and replicas (with given roles) and all shards STARTED.static ClusterStatestateWithAssignedPrimariesAndReplicasWithState(String[] indices, int numberOfShards, List<org.elasticsearch.core.Tuple<ShardRoutingState, ShardRouting.Role>> replicaRoleAndStates) Creates cluster state with several indexes, shards and replicas (with given roles and state) and all primary shards STARTED.static ClusterStatestateWithAssignedPrimariesAndReplicasWithState(String[] indices, int numberOfShards, ShardRouting.Role primaryRole, List<org.elasticsearch.core.Tuple<ShardRoutingState, ShardRouting.Role>> replicasStateAndRoles) Creates cluster state with several indexes, shards and replicas (with given roles and state) and all primary shards STARTED.static ClusterStateCreates 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
public static ClusterState state(String index, boolean activePrimaryLocal, ShardRoutingState primaryState, List<org.elasticsearch.core.Tuple<ShardRoutingState, ShardRouting.Role>> replicaStates) Creates cluster state with and index that has one shard and #(replicaStates) replicas with given roles- Parameters:
index- name of the indexactivePrimaryLocal- if active primary should coincide with the local node in the cluster stateprimaryState- state of primaryreplicaStates- states and roles of the replicas. length of this collection determines also the number of replicas
-
state
public static ClusterState state(String index, boolean activePrimaryLocal, ShardRoutingState primaryState, ShardRouting.Role primaryRole, List<org.elasticsearch.core.Tuple<ShardRoutingState, ShardRouting.Role>> replicaStates) Creates cluster state with and index that has one shard and #(replicaStates) replicas with given roles- Parameters:
index- name of the indexactivePrimaryLocal- if active primary should coincide with the local node in the cluster stateprimaryState- state of primaryprimaryRole- role of primaryreplicaStates- states and roles of the replicas. length of this collection 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. -
stateWithAssignedPrimariesAndReplicas
public static ClusterState stateWithAssignedPrimariesAndReplicas(String[] indices, int numberOfShards, List<ShardRouting.Role> replicaRoles) Creates cluster state with several indexes, shards and replicas (with given roles) and all shards STARTED. -
stateWithAssignedPrimariesAndReplicasWithState
public static ClusterState stateWithAssignedPrimariesAndReplicasWithState(String[] indices, int numberOfShards, List<org.elasticsearch.core.Tuple<ShardRoutingState, ShardRouting.Role>> replicaRoleAndStates) Creates cluster state with several indexes, shards and replicas (with given roles and state) and all primary shards STARTED. -
stateWithAssignedPrimariesAndReplicasWithState
public static ClusterState stateWithAssignedPrimariesAndReplicasWithState(String[] indices, int numberOfShards, ShardRouting.Role primaryRole, List<org.elasticsearch.core.Tuple<ShardRoutingState, ShardRouting.Role>> replicasStateAndRoles) Creates cluster state with several indexes, shards and replicas (with given roles and state) and all primary 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[] allNodes, TransportVersion transportVersion) 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 clustertransportVersion- the transport version used by 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
-
state
public static ClusterState state(DiscoveryNode localNode, DiscoveryNode masterNode, DiscoveryNode healthNode, DiscoveryNode[] allNodes, TransportVersion transportVersion) 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 clustertransportVersion- the transport version used by the cluster- Returns:
- cluster state
-