cleanup DiscoveryNodes#Builder construction
have a better method name, and only allow to create a copy of the builder based on existing nodes when constructing the builder
This commit is contained in:
parent
e551ec282f
commit
6be85cece4
|
@ -42,11 +42,11 @@ import static com.google.common.collect.Maps.newHashMap;
|
|||
|
||||
/**
|
||||
* This class holds all {@link DiscoveryNode} in the cluster and provides convinience methods to
|
||||
* access, modify merge / diff discovery nodes.
|
||||
* access, modify merge / diff discovery nodes.
|
||||
*/
|
||||
public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
||||
|
||||
public static final DiscoveryNodes EMPTY_NODES = newNodesBuilder().build();
|
||||
public static final DiscoveryNodes EMPTY_NODES = builder().build();
|
||||
|
||||
private final ImmutableMap<String, DiscoveryNode> nodes;
|
||||
|
||||
|
@ -91,7 +91,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the number of known nodes
|
||||
* Get the number of known nodes
|
||||
*
|
||||
* @return number of nodes
|
||||
*/
|
||||
public int size() {
|
||||
|
@ -99,7 +100,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the number of known nodes
|
||||
* Get the number of known nodes
|
||||
*
|
||||
* @return number of nodes
|
||||
*/
|
||||
public int getSize() {
|
||||
|
@ -107,7 +109,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a {@link Map} of the discovered nodes arranged by their ids
|
||||
* Get a {@link Map} of the discovered nodes arranged by their ids
|
||||
*
|
||||
* @return {@link Map} of the discovered nodes arranged by their ids
|
||||
*/
|
||||
public ImmutableMap<String, DiscoveryNode> nodes() {
|
||||
|
@ -115,7 +118,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a {@link Map} of the discovered nodes arranged by their ids
|
||||
* Get a {@link Map} of the discovered nodes arranged by their ids
|
||||
*
|
||||
* @return {@link Map} of the discovered nodes arranged by their ids
|
||||
*/
|
||||
public ImmutableMap<String, DiscoveryNode> getNodes() {
|
||||
|
@ -123,7 +127,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a {@link Map} of the discovered data nodes arranged by their ids
|
||||
* Get a {@link Map} of the discovered data nodes arranged by their ids
|
||||
*
|
||||
* @return {@link Map} of the discovered data nodes arranged by their ids
|
||||
*/
|
||||
public ImmutableMap<String, DiscoveryNode> dataNodes() {
|
||||
|
@ -131,7 +136,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a {@link Map} of the discovered data nodes arranged by their ids
|
||||
* Get a {@link Map} of the discovered data nodes arranged by their ids
|
||||
*
|
||||
* @return {@link Map} of the discovered data nodes arranged by their ids
|
||||
*/
|
||||
public ImmutableMap<String, DiscoveryNode> getDataNodes() {
|
||||
|
@ -139,7 +145,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a {@link Map} of the discovered master nodes arranged by their ids
|
||||
* Get a {@link Map} of the discovered master nodes arranged by their ids
|
||||
*
|
||||
* @return {@link Map} of the discovered master nodes arranged by their ids
|
||||
*/
|
||||
public ImmutableMap<String, DiscoveryNode> masterNodes() {
|
||||
|
@ -147,7 +154,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a {@link Map} of the discovered master nodes arranged by their ids
|
||||
* Get a {@link Map} of the discovered master nodes arranged by their ids
|
||||
*
|
||||
* @return {@link Map} of the discovered master nodes arranged by their ids
|
||||
*/
|
||||
public ImmutableMap<String, DiscoveryNode> getMasterNodes() {
|
||||
|
@ -155,7 +163,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a {@link Map} of the discovered master and data nodes arranged by their ids
|
||||
* Get a {@link Map} of the discovered master and data nodes arranged by their ids
|
||||
*
|
||||
* @return {@link Map} of the discovered master and data nodes arranged by their ids
|
||||
*/
|
||||
public ImmutableMap<String, DiscoveryNode> masterAndDataNodes() {
|
||||
|
@ -164,7 +173,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
|
||||
/**
|
||||
* Get a node by its id
|
||||
* @param nodeId id of the wanted node
|
||||
*
|
||||
* @param nodeId id of the wanted node
|
||||
* @return wanted node if it exists. Otherwise <code>null</code>
|
||||
*/
|
||||
public DiscoveryNode get(String nodeId) {
|
||||
|
@ -173,6 +183,7 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
|
||||
/**
|
||||
* Determine if a given node exists
|
||||
*
|
||||
* @param nodeId id of the node which existence should be verified
|
||||
* @return <code>true</code> if the node exists. Otherwise <code>false</code>
|
||||
*/
|
||||
|
@ -181,7 +192,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the id of the master node
|
||||
* Get the id of the master node
|
||||
*
|
||||
* @return id of the master
|
||||
*/
|
||||
public String masterNodeId() {
|
||||
|
@ -189,7 +201,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the id of the master node
|
||||
* Get the id of the master node
|
||||
*
|
||||
* @return id of the master
|
||||
*/
|
||||
public String getMasterNodeId() {
|
||||
|
@ -197,7 +210,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the id of the local node
|
||||
* Get the id of the local node
|
||||
*
|
||||
* @return id of the local node
|
||||
*/
|
||||
public String localNodeId() {
|
||||
|
@ -205,7 +219,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the id of the local node
|
||||
* Get the id of the local node
|
||||
*
|
||||
* @return id of the local node
|
||||
*/
|
||||
public String getLocalNodeId() {
|
||||
|
@ -213,7 +228,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the local node
|
||||
* Get the local node
|
||||
*
|
||||
* @return local node
|
||||
*/
|
||||
public DiscoveryNode localNode() {
|
||||
|
@ -221,7 +237,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the local node
|
||||
* Get the local node
|
||||
*
|
||||
* @return local node
|
||||
*/
|
||||
public DiscoveryNode getLocalNode() {
|
||||
|
@ -229,7 +246,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the master node
|
||||
* Get the master node
|
||||
*
|
||||
* @return master node
|
||||
*/
|
||||
public DiscoveryNode masterNode() {
|
||||
|
@ -237,7 +255,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the master node
|
||||
* Get the master node
|
||||
*
|
||||
* @return master node
|
||||
*/
|
||||
public DiscoveryNode getMasterNode() {
|
||||
|
@ -245,7 +264,8 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a node by its address
|
||||
* Get a node by its address
|
||||
*
|
||||
* @param address {@link TransportAddress} of the wanted node
|
||||
* @return node identified by the given address or <code>null</code> if no such node exists
|
||||
*/
|
||||
|
@ -264,9 +284,11 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
|
||||
/**
|
||||
* Resolve a node with a given id
|
||||
*
|
||||
* @param node id of the node to discover
|
||||
* @return discovered node matching the given id
|
||||
* @throws ElasticSearchIllegalArgumentException if more than one node matches the request or no nodes have been resolved
|
||||
* @throws ElasticSearchIllegalArgumentException
|
||||
* if more than one node matches the request or no nodes have been resolved
|
||||
*/
|
||||
public DiscoveryNode resolveNode(String node) {
|
||||
String[] resolvedNodeIds = resolveNodesIds(node);
|
||||
|
@ -278,7 +300,7 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
return nodes.get(resolvedNodeIds[0]);
|
||||
}
|
||||
|
||||
|
||||
public String[] resolveNodesIds(String... nodesIds) {
|
||||
if (isAllNodes(nodesIds)) {
|
||||
int index = 0;
|
||||
|
@ -347,7 +369,7 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
return resolvedNodesIds.toArray(new String[resolvedNodesIds.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DiscoveryNodes removeDeadMembers(Set<String> newNodes, String masterNodeId) {
|
||||
Builder builder = new Builder().masterNodeId(masterNodeId).localNodeId(localNodeId);
|
||||
for (DiscoveryNode node : this) {
|
||||
|
@ -357,9 +379,9 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
public DiscoveryNodes newNode(DiscoveryNode node) {
|
||||
return new Builder().putAll(this).put(node).build();
|
||||
return new Builder(this).put(node).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -415,7 +437,7 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public Delta emptyDelta() {
|
||||
return new Delta(null, null, localNodeId, DiscoveryNode.EMPTY_LIST, DiscoveryNode.EMPTY_LIST);
|
||||
}
|
||||
|
@ -520,26 +542,29 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder newNodesBuilder() {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
|
||||
public static Builder builder(DiscoveryNodes nodes) {
|
||||
return new Builder(nodes);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Map<String, DiscoveryNode> nodes = newHashMap();
|
||||
|
||||
private String masterNodeId;
|
||||
|
||||
private String localNodeId;
|
||||
|
||||
public Builder putAll(DiscoveryNodes nodes) {
|
||||
public Builder() {
|
||||
|
||||
}
|
||||
|
||||
public Builder(DiscoveryNodes nodes) {
|
||||
this.masterNodeId = nodes.masterNodeId();
|
||||
this.localNodeId = nodes.localNodeId();
|
||||
for (DiscoveryNode node : nodes) {
|
||||
put(node);
|
||||
}
|
||||
return this;
|
||||
this.nodes.putAll(nodes.nodes());
|
||||
}
|
||||
|
||||
public Builder put(DiscoveryNode node) {
|
||||
|
@ -547,13 +572,6 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder putAll(Iterable<DiscoveryNode> nodes) {
|
||||
for (DiscoveryNode node : nodes) {
|
||||
put(node);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder remove(String nodeId) {
|
||||
nodes.remove(nodeId);
|
||||
return this;
|
||||
|
|
|
@ -132,7 +132,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent<Discovery> implem
|
|||
clusterService.submitStateUpdateTask("local-disco-initial_connect(master)", new ProcessedClusterStateUpdateTask() {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.newNodesBuilder();
|
||||
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder();
|
||||
for (LocalDiscovery discovery : clusterGroups.get(clusterName).members()) {
|
||||
nodesBuilder.put(discovery.localNode);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent<Discovery> implem
|
|||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
// make sure we have the local node id set, we might need it as a result of the new metadata
|
||||
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.newNodesBuilder().putAll(currentState.nodes()).put(localNode).localNodeId(localNode.id());
|
||||
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(currentState.nodes()).put(localNode).localNodeId(localNode.id());
|
||||
return ClusterState.builder(currentState).metaData(masterState.metaData()).nodes(nodesBuilder).build();
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent<Discovery> implem
|
|||
firstMaster.clusterService.submitStateUpdateTask("local-disco-receive(from node[" + localNode + "])", new ProcessedClusterStateUpdateTask() {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.newNodesBuilder();
|
||||
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder();
|
||||
for (LocalDiscovery discovery : clusterGroups.get(clusterName).members()) {
|
||||
nodesBuilder.put(discovery.localNode);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
||||
|
||||
/**
|
||||
|
@ -252,7 +251,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
return latestNodes;
|
||||
}
|
||||
// have not decided yet, just send the local node
|
||||
return newNodesBuilder().put(localNode).localNodeId(localNode.id()).build();
|
||||
return DiscoveryNodes.builder().put(localNode).localNodeId(localNode.id()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -371,8 +370,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
clusterService.submitStateUpdateTask("zen-disco-node_left(" + node + ")", Priority.URGENT, new ClusterStateUpdateTask() {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder()
|
||||
.putAll(currentState.nodes())
|
||||
DiscoveryNodes.Builder builder = DiscoveryNodes.builder(currentState.nodes())
|
||||
.remove(node.id());
|
||||
latestDiscoNodes = builder.build();
|
||||
currentState = ClusterState.builder(currentState).nodes(latestDiscoNodes).build();
|
||||
|
@ -407,8 +405,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
clusterService.submitStateUpdateTask("zen-disco-node_failed(" + node + "), reason " + reason, Priority.URGENT, new ProcessedClusterStateUpdateTask() {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder()
|
||||
.putAll(currentState.nodes())
|
||||
DiscoveryNodes.Builder builder = DiscoveryNodes.builder(currentState.nodes())
|
||||
.remove(node.id());
|
||||
latestDiscoNodes = builder.build();
|
||||
currentState = ClusterState.builder(currentState).nodes(latestDiscoNodes).build();
|
||||
|
@ -486,9 +483,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
return currentState;
|
||||
}
|
||||
|
||||
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.newNodesBuilder()
|
||||
.putAll(currentState.nodes())
|
||||
// make sure the old master node, which has failed, is not part of the nodes we publish
|
||||
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(currentState.nodes())
|
||||
// make sure the old master node, which has failed, is not part of the nodes we publish
|
||||
.remove(masterNode.id())
|
||||
.masterNodeId(null);
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.hamcrest.Matcher;
|
|||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
|
@ -88,7 +87,7 @@ public class AddIncrementallyTests extends ElasticsearchTestCase {
|
|||
assertNumIndexShardsPerNode(clusterState, Matchers.equalTo(3));
|
||||
|
||||
logger.info("now, start one more node, check that rebalancing will happen because we set it to always");
|
||||
DiscoveryNodes.Builder nodes = newNodesBuilder().putAll(clusterState.nodes());
|
||||
DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(clusterState.nodes());
|
||||
nodes.put(newNode("node2"));
|
||||
clusterState = ClusterState.builder(clusterState).nodes(nodes.build()).build();
|
||||
|
||||
|
@ -159,7 +158,7 @@ public class AddIncrementallyTests extends ElasticsearchTestCase {
|
|||
assertNumIndexShardsPerNode(clusterState, Matchers.equalTo(3));
|
||||
|
||||
logger.info("now, start one more node, check that rebalancing will happen because we set it to always");
|
||||
DiscoveryNodes.Builder nodes = newNodesBuilder().putAll(clusterState.nodes());
|
||||
DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(clusterState.nodes());
|
||||
nodes.put(newNode("node2"));
|
||||
clusterState = ClusterState.builder(clusterState).nodes(nodes.build()).build();
|
||||
|
||||
|
@ -237,7 +236,7 @@ public class AddIncrementallyTests extends ElasticsearchTestCase {
|
|||
|
||||
private ClusterState addNodes(ClusterState clusterState, AllocationService service, int numNodes, int nodeOffset) {
|
||||
logger.info("now, start [{}] more node, check that rebalancing will happen because we set it to always", numNodes);
|
||||
DiscoveryNodes.Builder nodes = newNodesBuilder().putAll(clusterState.nodes());
|
||||
DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(clusterState.nodes());
|
||||
for (int i = 0; i < numNodes; i++) {
|
||||
nodes.put(newNode("node" + (i + nodeOffset)));
|
||||
}
|
||||
|
@ -284,7 +283,7 @@ public class AddIncrementallyTests extends ElasticsearchTestCase {
|
|||
RoutingTable routingTable = routingTableBuilder.build();
|
||||
|
||||
logger.info("start " + numberOfNodes + " nodes");
|
||||
DiscoveryNodes.Builder nodes = newNodesBuilder();
|
||||
DiscoveryNodes.Builder nodes = DiscoveryNodes.builder();
|
||||
for (int i = 0; i < numberOfNodes; i++) {
|
||||
nodes.put(newNode("node" + i));
|
||||
}
|
||||
|
@ -364,7 +363,7 @@ public class AddIncrementallyTests extends ElasticsearchTestCase {
|
|||
|
||||
private ClusterState removeNodes(ClusterState clusterState, AllocationService service, int numNodes) {
|
||||
logger.info("Removing [{}] nodes", numNodes);
|
||||
DiscoveryNodes.Builder nodes = newNodesBuilder().putAll(clusterState.nodes());
|
||||
DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(clusterState.nodes());
|
||||
|
||||
for (DiscoveryNode node : clusterState.nodes()) {
|
||||
nodes.remove(node.id());
|
||||
|
|
|
@ -22,13 +22,13 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -55,7 +55,7 @@ public class AllocatePostApiFlagTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingTable().index("test").shard(0).primaryAllocatedPostApi(), equalTo(false));
|
||||
|
||||
logger.info("adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
assertThat(clusterState.routingTable().index("test").shard(0).primaryAllocatedPostApi(), equalTo(false));
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
||||
import org.elasticsearch.cluster.routing.allocation.command.AllocateAllocationCommand;
|
||||
|
@ -41,7 +42,6 @@ import org.elasticsearch.index.shard.ShardId;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
|
@ -68,7 +68,7 @@ public class AllocationCommandsTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class AllocationCommandsTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding 3 nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
.put(newNode("node3"))
|
||||
|
@ -196,7 +196,7 @@ public class AllocationCommandsTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding 3 nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
.put(newNode("node3"))
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
||||
|
@ -31,7 +32,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -64,7 +64,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node2", ImmutableMap.of("rack_id", "1")))
|
||||
).build();
|
||||
|
@ -83,7 +83,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(2));
|
||||
|
||||
logger.info("--> add a new node with a new rack and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", ImmutableMap.of("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -103,7 +103,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, make sure nothing moves");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", ImmutableMap.of("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -133,7 +133,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node2", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node3", ImmutableMap.of("rack_id", "1")))
|
||||
|
@ -153,7 +153,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(2));
|
||||
|
||||
logger.info("--> add a new node with a new rack and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", ImmutableMap.of("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -173,7 +173,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, make sure nothing moves");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node5", ImmutableMap.of("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -208,7 +208,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node2", ImmutableMap.of("rack_id", "1")))
|
||||
).build();
|
||||
|
@ -241,7 +241,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(10));
|
||||
|
||||
logger.info("--> add a new node with a new rack and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", ImmutableMap.of("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -266,7 +266,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, some more relocation should happen");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", ImmutableMap.of("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -308,7 +308,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node2", ImmutableMap.of("rack_id", "1")))
|
||||
).build();
|
||||
|
@ -327,7 +327,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(20));
|
||||
|
||||
logger.info("--> add a new node with a new rack and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", ImmutableMap.of("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -356,7 +356,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, some more relocation should happen");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", ImmutableMap.of("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -400,7 +400,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node2", ImmutableMap.of("rack_id", "1")))
|
||||
).build();
|
||||
|
@ -419,7 +419,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(2));
|
||||
|
||||
logger.info("--> add a new node with a new rack and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", ImmutableMap.of("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -439,7 +439,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, we will have another relocation");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", ImmutableMap.of("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -479,7 +479,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node2", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node3", ImmutableMap.of("rack_id", "1")))
|
||||
|
@ -500,7 +500,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(4));
|
||||
|
||||
logger.info("--> add a new node with a new rack and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node5", ImmutableMap.of("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -520,7 +520,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, we will have another relocation");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node6", ImmutableMap.of("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -561,7 +561,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node2", ImmutableMap.of("rack_id", "1")))
|
||||
).build();
|
||||
|
@ -578,7 +578,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().shardsWithState(INITIALIZING).size(), equalTo(0));
|
||||
|
||||
logger.info("--> add a new node with a new rack and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", ImmutableMap.of("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -598,7 +598,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, make sure nothing moves");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", ImmutableMap.of("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -629,7 +629,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node2", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node3", ImmutableMap.of("rack_id", "1")))
|
||||
|
@ -647,7 +647,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().shardsWithState(INITIALIZING).size(), equalTo(0));
|
||||
|
||||
logger.info("--> add a new node with a new rack and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", ImmutableMap.of("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -667,7 +667,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, make sure nothing moves");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node5", ImmutableMap.of("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -705,7 +705,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("rack_id", "1")))
|
||||
.put(newNode("node2", ImmutableMap.of("rack_id", "1")))
|
||||
).build();
|
||||
|
@ -720,7 +720,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(10));
|
||||
|
||||
logger.info("--> add a new node with a new rack and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", ImmutableMap.of("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -744,7 +744,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, some more relocation should happen");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", ImmutableMap.of("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -785,7 +785,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("A-0", ImmutableMap.of("zone", "a")))
|
||||
.put(newNode("B-0", ImmutableMap.of("zone", "b")))
|
||||
).build();
|
||||
|
@ -807,7 +807,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().shardsWithState(INITIALIZING).size(), equalTo(0));
|
||||
|
||||
logger.info("--> add a new node in zone 'a' and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("A-1", ImmutableMap.of("zone", "a")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.junit.Test;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
|
@ -159,7 +158,7 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
|||
|
||||
|
||||
logger.info("start " + numberOfNodes + " nodes");
|
||||
DiscoveryNodes.Builder nodes = newNodesBuilder();
|
||||
DiscoveryNodes.Builder nodes = DiscoveryNodes.builder();
|
||||
for (int i = 0; i < numberOfNodes; i++) {
|
||||
nodes.put(newNode("node" + i));
|
||||
}
|
||||
|
@ -196,7 +195,7 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
|||
|
||||
private ClusterState addNode(ClusterState clusterState, AllocationService strategy) {
|
||||
logger.info("now, start 1 more node, check that rebalancing will happen because we set it to always");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node" + numberOfNodes)))
|
||||
.build();
|
||||
|
||||
|
@ -221,7 +220,7 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
|||
|
||||
private ClusterState removeNodes(ClusterState clusterState, AllocationService strategy) {
|
||||
logger.info("Removing half the nodes (" + (numberOfNodes + 1) / 2 + ")");
|
||||
DiscoveryNodes.Builder nodes = newNodesBuilder().putAll(clusterState.nodes());
|
||||
DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(clusterState.nodes());
|
||||
|
||||
for (int i = (numberOfNodes + 1) / 2; i <= numberOfNodes; i++) {
|
||||
nodes.remove("node" + i);
|
||||
|
@ -458,7 +457,7 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
|||
routingTableBuilder.addAsNew(index);
|
||||
}
|
||||
RoutingTable routingTable = routingTableBuilder.build();
|
||||
DiscoveryNodes.Builder nodes = newNodesBuilder();
|
||||
DiscoveryNodes.Builder nodes = DiscoveryNodes.builder();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
DiscoveryNode node = newNode("node" + i);
|
||||
nodes.put(node);
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
|
||||
|
@ -30,7 +31,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -57,7 +57,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -113,7 +113,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("now, start 1 more node, check that rebalancing will happen (for test1) because we set it to always");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
|
@ -143,7 +143,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -218,7 +218,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("now, start 1 more node, check that rebalancing happen (for test1) because we set it to primaries_active");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
|
@ -247,7 +247,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -303,7 +303,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("now, start 1 more node, check that rebalancing will not happen (for test1) because we set it to primaries_active");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
|
@ -331,7 +331,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -425,7 +425,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("now, start 1 more node, check that rebalancing happen (for test1) because we set it to all_active");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
|
@ -454,7 +454,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -510,7 +510,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("now, start 1 more node, check that rebalancing will not happen (for test1) because we set it to all_active");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
|
@ -538,7 +538,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -613,7 +613,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("now, start 1 more node, check that rebalancing will not happen (for test1) because we set it to all_active");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
|
@ -29,7 +30,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -69,7 +69,7 @@ public class ConcurrentRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("start two nodes and fully start the shards");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -94,7 +94,7 @@ public class ConcurrentRebalanceRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("now, start 8 more nodes, and check that no rebalancing/relocation have happened");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3")).put(newNode("node4")).put(newNode("node5")).put(newNode("node6")).put(newNode("node7")).put(newNode("node8")).put(newNode("node9")).put(newNode("node10")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.allocation.command.AllocationCommands;
|
||||
import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand;
|
||||
|
@ -30,7 +31,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -59,7 +59,7 @@ public class DeadNodesAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding 2 nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
@ -83,7 +83,7 @@ public class DeadNodesAllocationTests extends ElasticsearchTestCase {
|
|||
logger.info("--> fail node with primary");
|
||||
String nodeIdToFail = clusterState.routingTable().index("test").shard(0).primaryShard().currentNodeId();
|
||||
String nodeIdRemaining = nodeIdToFail.equals("node1") ? "node2" : "node1";
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode(nodeIdRemaining))
|
||||
).build();
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class DeadNodesAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding 2 nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
@ -133,7 +133,7 @@ public class DeadNodesAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().node("node2").shards().get(0).state(), equalTo(STARTED));
|
||||
|
||||
logger.info("--> adding additional node");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
rerouteResult = allocation.reroute(clusterState);
|
||||
|
@ -158,7 +158,7 @@ public class DeadNodesAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().node("node3").shards().get(0).state(), equalTo(INITIALIZING));
|
||||
|
||||
logger.info("--> fail primary shard recovering instance on node3 being initialized by killing node3");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode(origPrimaryNodeId))
|
||||
.put(newNode(origReplicaNodeId))
|
||||
).build();
|
||||
|
@ -186,7 +186,7 @@ public class DeadNodesAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding 2 nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
@ -208,7 +208,7 @@ public class DeadNodesAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().node("node2").shards().get(0).state(), equalTo(STARTED));
|
||||
|
||||
logger.info("--> adding additional node");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
rerouteResult = allocation.reroute(clusterState);
|
||||
|
@ -233,7 +233,7 @@ public class DeadNodesAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().node("node3").shards().get(0).state(), equalTo(INITIALIZING));
|
||||
|
||||
logger.info("--> fail primary shard recovering instance on 'origPrimaryNodeId' being relocated");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node3"))
|
||||
.put(newNode(origReplicaNodeId))
|
||||
).build();
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.allocation.decider.DisableAllocationDecider;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
|
@ -30,7 +31,6 @@ import org.elasticsearch.common.settings.ImmutableSettings;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
|
@ -63,7 +63,7 @@ public class DisableAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
@ -92,7 +92,7 @@ public class DisableAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
@ -125,7 +125,7 @@ public class DisableAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
|
@ -30,7 +31,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
|
@ -61,7 +61,7 @@ public class ElectReplicaAsPrimaryDuringRelocationTests extends ElasticsearchTes
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -85,7 +85,7 @@ public class ElectReplicaAsPrimaryDuringRelocationTests extends ElasticsearchTes
|
|||
assertThat(routingNodes.node("node2").numberOfShardsWithState(STARTED), equalTo(2));
|
||||
|
||||
logger.info("Start another node and perform rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -101,7 +101,7 @@ public class ElectReplicaAsPrimaryDuringRelocationTests extends ElasticsearchTes
|
|||
// we might have primary relocating, and the test is only for replicas, so only test in the case of replica allocation
|
||||
if (indexShardRoutingTable != null) {
|
||||
logger.info("kill the node [{}] of the primary shard for the relocating replica", indexShardRoutingTable.primaryShard().currentNodeId());
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).remove(indexShardRoutingTable.primaryShard().currentNodeId())).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove(indexShardRoutingTable.primaryShard().currentNodeId())).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNode;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
|
@ -31,7 +32,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
|
@ -59,7 +59,7 @@ public class FailedNodeRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start 4 nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -86,7 +86,7 @@ public class FailedNodeRoutingTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("remove 2 nodes where primaries are allocated, reroute");
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.remove(routingTable.index("test1").shard(0).primaryShard().currentNodeId())
|
||||
.remove(routingTable.index("test2").shard(0).primaryShard().currentNodeId())
|
||||
)
|
||||
|
@ -119,7 +119,7 @@ public class FailedNodeRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start 4 nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -146,7 +146,7 @@ public class FailedNodeRoutingTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("remove 2 nodes where primaries are allocated, reroute");
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.remove(routingTable.index("test1").shard(0).primaryShard().currentNodeId())
|
||||
.remove(routingTable.index("test2").shard(0).primaryShard().currentNodeId())
|
||||
)
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.ImmutableShardRouting;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
|
@ -33,7 +34,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -63,7 +63,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding 2 nodes on same rack and do rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
@ -85,7 +85,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.routingNodes().node("node2").shards().get(0).state(), equalTo(STARTED));
|
||||
|
||||
logger.info("--> adding additional node");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
rerouteResult = allocation.reroute(clusterState);
|
||||
|
@ -155,7 +155,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -236,7 +236,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Adding single node and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -293,7 +293,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -350,7 +350,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -392,7 +392,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("Adding third node and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.MutableShardRouting;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
||||
|
@ -34,7 +35,6 @@ import org.junit.Test;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -66,7 +66,7 @@ public class FilterRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding four nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("tag1", "value1")))
|
||||
.put(newNode("node2", ImmutableMap.of("tag1", "value2")))
|
||||
.put(newNode("node3", ImmutableMap.of("tag1", "value3")))
|
||||
|
@ -115,7 +115,7 @@ public class FilterRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("tag1", "value1")))
|
||||
.put(newNode("node2", ImmutableMap.of("tag1", "value2")))
|
||||
.put(newNode("node3", ImmutableMap.of("tag1", "value3")))
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
|
@ -30,7 +31,6 @@ import org.elasticsearch.common.settings.ImmutableSettings;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -83,7 +83,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("Adding three node and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState)
|
||||
.nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3"))).build();
|
||||
.nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -101,7 +101,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("Another round of rebalancing");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -213,7 +213,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("Adding one node and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -232,7 +232,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("Add another node and perform rerouting, nothing will happen since primary not started");
|
||||
clusterState = ClusterState.builder(clusterState)
|
||||
.nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
.nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -296,7 +296,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("Add another node and perform rerouting, nothing will happen since primary not started");
|
||||
clusterState = ClusterState.builder(clusterState)
|
||||
.nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
.nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -366,7 +366,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("Adding three node and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState)
|
||||
.nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3"))).build();
|
||||
.nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -384,7 +384,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("Another round of rebalancing");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -476,7 +476,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("Another round of rebalancing");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
|
|
@ -22,13 +22,13 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -63,7 +63,7 @@ public class PreferPrimaryAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("adding two nodes and performing rerouting till all are allocated");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
|
@ -29,7 +30,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
|
@ -61,7 +61,7 @@ public class PrimaryElectionRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -79,7 +79,7 @@ public class PrimaryElectionRoutingTests extends ElasticsearchTestCase {
|
|||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Adding third node and reroute and kill first node");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node3")).remove("node1")).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3")).remove("node1")).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -112,7 +112,7 @@ public class PrimaryElectionRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class PrimaryElectionRoutingTests extends ElasticsearchTestCase {
|
|||
logger.info("--> fail node with primary");
|
||||
String nodeIdToFail = clusterState.routingTable().index("test").shard(0).primaryShard().currentNodeId();
|
||||
String nodeIdRemaining = nodeIdToFail.equals("node1") ? "node2" : "node1";
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode(nodeIdRemaining))
|
||||
).build();
|
||||
rerouteResult = allocation.reroute(clusterState);
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
|
@ -29,7 +30,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
|
@ -64,7 +64,7 @@ public class PrimaryNotRelocatedWhileBeingRecoveredTests extends ElasticsearchTe
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class PrimaryNotRelocatedWhileBeingRecoveredTests extends ElasticsearchTe
|
|||
assertThat(routingTable.shardsWithState(STARTED).size(), equalTo(5));
|
||||
|
||||
logger.info("start another node, replica will start recovering form primary");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class PrimaryNotRelocatedWhileBeingRecoveredTests extends ElasticsearchTe
|
|||
assertThat(routingTable.shardsWithState(INITIALIZING).size(), equalTo(5));
|
||||
|
||||
logger.info("start another node, make sure the primary is not relocated");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ import java.util.Arrays;
|
|||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -88,8 +87,7 @@ public class RandomAllocationDeciderTests extends ElasticsearchTestCase {
|
|||
final boolean frequentNodes = randomBoolean();
|
||||
for (int i = 0; i < numIters; i++) {
|
||||
ClusterState.Builder stateBuilder = ClusterState.builder(clusterState);
|
||||
DiscoveryNodes.Builder newNodesBuilder = newNodesBuilder();
|
||||
newNodesBuilder.putAll(clusterState.nodes());
|
||||
DiscoveryNodes.Builder newNodesBuilder = DiscoveryNodes.builder(clusterState.nodes());
|
||||
|
||||
if (clusterState.nodes().size() <= atMostNodes &&
|
||||
(nodeIdCounter == 0 || (frequentNodes ? frequently() : rarely()))) {
|
||||
|
@ -119,8 +117,7 @@ public class RandomAllocationDeciderTests extends ElasticsearchTestCase {
|
|||
logger.info("Fill up nodes such that every shard can be allocated");
|
||||
if (clusterState.nodes().size() < maxNumReplicas) {
|
||||
ClusterState.Builder stateBuilder = ClusterState.builder(clusterState);
|
||||
DiscoveryNodes.Builder newNodesBuilder = newNodesBuilder();
|
||||
newNodesBuilder.putAll(clusterState.nodes());
|
||||
DiscoveryNodes.Builder newNodesBuilder = DiscoveryNodes.builder(clusterState.nodes());
|
||||
for (int j = 0; j < (maxNumReplicas - clusterState.nodes().size()); j++) {
|
||||
logger.info("adding node [{}]", nodeIdCounter);
|
||||
newNodesBuilder.put(newNode("NODE_" + (nodeIdCounter++)));
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNode;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
|
@ -30,7 +31,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -74,7 +74,7 @@ public class RebalanceAfterActiveTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("start two nodes and fully start the shards");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -99,7 +99,7 @@ public class RebalanceAfterActiveTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("now, start 8 more nodes, and check that no rebalancing/relocation have happened");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3")).put(newNode("node4")).put(newNode("node5")).put(newNode("node6")).put(newNode("node7")).put(newNode("node8")).put(newNode("node9")).put(newNode("node10")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
|
@ -29,7 +30,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -68,7 +68,7 @@ public class ReplicaAllocatedAfterPrimaryTests extends ElasticsearchTestCase {
|
|||
assertThat(routingTable.index("test").shard(0).shards().get(1).currentNodeId(), nullValue());
|
||||
|
||||
logger.info("Adding one node and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.MutableShardRouting;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
||||
|
@ -13,7 +14,6 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -39,7 +39,7 @@ public class SameShardRoutingTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes with the same host");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", new InetSocketTransportAddress("test1", 80)))
|
||||
.put(newNode("node2", new InetSocketTransportAddress("test1", 80)))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -55,8 +55,7 @@ public class SameShardRoutingTests extends ElasticsearchTestCase {
|
|||
assertThat(clusterState.readOnlyRoutingNodes().numberOfShardsOfType(ShardRoutingState.INITIALIZING), equalTo(0));
|
||||
|
||||
logger.info("--> add another node, with a different host, replicas will be allocating");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
.putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", new InetSocketTransportAddress("test2", 80)))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
|
||||
|
@ -30,7 +31,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -57,7 +57,7 @@ public class ShardVersioningTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.MutableShardRouting;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
|
@ -33,7 +34,6 @@ import org.elasticsearch.common.settings.ImmutableSettings;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -64,7 +64,7 @@ public class ShardsLimitAllocationTests extends ElasticsearchTestCase {
|
|||
|
||||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class ShardsLimitAllocationTests extends ElasticsearchTestCase {
|
|||
|
||||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
logger.info("Adding one node and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
|
@ -139,7 +139,7 @@ public class ShardsLimitAllocationTests extends ElasticsearchTestCase {
|
|||
clusterState = ClusterState.builder(clusterState).metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Add another one node and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ import java.util.Set;
|
|||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -74,7 +73,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
|||
assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), nullValue());
|
||||
|
||||
logger.info("Adding one node and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -106,7 +105,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
|||
assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), equalTo("node1"));
|
||||
|
||||
logger.info("Starting another node and making sure nothing changed");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -120,7 +119,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("Killing node1 where the shard is, checking the shard is relocated");
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).remove("node1")).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node1")).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -133,7 +132,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
|||
assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), equalTo("node2"));
|
||||
|
||||
logger.info("Start another node, make sure that things remain the same (shard is in node2 and initializing)");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -176,7 +175,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
|||
assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), nullValue());
|
||||
|
||||
logger.info("Adding one node and rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -237,7 +236,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("Adding " + (numberOfIndices / 2) + " nodes");
|
||||
DiscoveryNodes.Builder nodesBuilder = newNodesBuilder();
|
||||
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder();
|
||||
List<DiscoveryNode> nodes = newArrayList();
|
||||
for (int i = 0; i < (numberOfIndices / 2); i++) {
|
||||
nodesBuilder.put(newNode("node" + i));
|
||||
|
@ -276,7 +275,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("Adding additional " + (numberOfIndices / 2) + " nodes, nothing should change");
|
||||
nodesBuilder = newNodesBuilder().putAll(clusterState.nodes());
|
||||
nodesBuilder = DiscoveryNodes.builder(clusterState.nodes());
|
||||
for (int i = (numberOfIndices / 2); i < numberOfIndices; i++) {
|
||||
nodesBuilder.put(newNode("node" + i));
|
||||
}
|
||||
|
@ -345,7 +344,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("Starting 3 nodes and rerouting");
|
||||
clusterState = ClusterState.builder(clusterState)
|
||||
.nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")))
|
||||
.nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")))
|
||||
.build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -366,7 +365,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("Start two more nodes, things should remain the same");
|
||||
clusterState = ClusterState.builder(clusterState)
|
||||
.nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node4")).put(newNode("node5")))
|
||||
.nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node4")).put(newNode("node5")))
|
||||
.build();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
|
@ -29,7 +30,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -68,7 +68,7 @@ public class SingleShardOneReplicaRoutingTests extends ElasticsearchTestCase {
|
|||
assertThat(routingTable.index("test").shard(0).shards().get(1).currentNodeId(), nullValue());
|
||||
|
||||
logger.info("Adding one node and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -85,7 +85,7 @@ public class SingleShardOneReplicaRoutingTests extends ElasticsearchTestCase {
|
|||
assertThat(routingTable.index("test").shard(0).replicaShards().get(0).currentNodeId(), nullValue());
|
||||
|
||||
logger.info("Add another node and perform rerouting, nothing will happen since primary shards not started");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -133,7 +133,7 @@ public class SingleShardOneReplicaRoutingTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("Kill node1, backup shard should become primary");
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).remove("node1")).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node1")).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -151,7 +151,7 @@ public class SingleShardOneReplicaRoutingTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("Start another node, backup shard should start initializing");
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
|
@ -29,7 +30,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -77,7 +77,7 @@ public class TenShardsOneReplicaRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("Adding one node and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -96,7 +96,7 @@ public class TenShardsOneReplicaRoutingTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
logger.info("Add another node and perform rerouting, nothing will happen since primary not started");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
@ -149,7 +149,7 @@ public class TenShardsOneReplicaRoutingTests extends ElasticsearchTestCase {
|
|||
assertThat(routingNodes.node("node2").numberOfShardsWithState(STARTED), equalTo(10));
|
||||
|
||||
logger.info("Add another node and perform rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
|
|
@ -22,13 +22,13 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -61,7 +61,7 @@ public class ThrottlingAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start one node, do reroute, only 3 should initialize");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class ThrottlingAllocationTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start one node, do reroute, only 3 should initialize");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
|
@ -147,7 +147,7 @@ public class ThrottlingAllocationTests extends ElasticsearchTestCase {
|
|||
assertThat(routingTable.shardsWithState(UNASSIGNED).size(), equalTo(5));
|
||||
|
||||
logger.info("start another node, replicas should start being allocated");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.elasticsearch.cluster.routing.allocation;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
|
@ -10,7 +11,6 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -49,7 +49,7 @@ public class UpdateNumberOfReplicasTests extends ElasticsearchTestCase {
|
|||
|
||||
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -97,7 +97,7 @@ public class UpdateNumberOfReplicasTests extends ElasticsearchTestCase {
|
|||
assertThat(routingTable.index("test").shard(0).replicaShards().get(1).state(), equalTo(UNASSIGNED));
|
||||
|
||||
logger.info("Add another node and start the added replica");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.DiskUsage;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.*;
|
||||
import org.elasticsearch.cluster.routing.allocation.AllocationService;
|
||||
import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocators;
|
||||
|
@ -40,7 +41,6 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -96,7 +96,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
@ -127,7 +127,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("--> adding node3");
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -214,7 +214,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("--> adding node4");
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -285,7 +285,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
|||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> adding two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
@ -316,7 +316,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("--> adding node3");
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -403,7 +403,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
|||
|
||||
logger.info("--> adding node4");
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
|
@ -470,7 +470,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
|||
|
||||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
logger.info("--> adding node1");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2")) // node2 is added because DiskThresholdDecider automatically ignore single-node clusters
|
||||
).build();
|
||||
|
@ -532,7 +532,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
|||
|
||||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
logger.info("--> adding node1");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node3")) // node3 is added because DiskThresholdDecider automatically ignore single-node clusters
|
||||
).build();
|
||||
|
|
|
@ -50,7 +50,7 @@ public class ClusterSerializationTests extends ElasticsearchTestCase {
|
|||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
DiscoveryNodes nodes = DiscoveryNodes.newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).localNodeId("node1").masterNodeId("node2").build();
|
||||
DiscoveryNodes nodes = DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).localNodeId("node1").masterNodeId("node2").build();
|
||||
|
||||
ClusterState clusterState = ClusterState.builder().nodes(nodes).metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class ClusterSerializationTests extends ElasticsearchTestCase {
|
|||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
DiscoveryNodes nodes = DiscoveryNodes.newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).build();
|
||||
DiscoveryNodes nodes = DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).build();
|
||||
|
||||
ClusterState clusterState = ClusterState.builder().nodes(nodes).metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.*;
|
||||
import org.elasticsearch.cluster.routing.allocation.AllocationService;
|
||||
import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider;
|
||||
|
@ -34,7 +35,6 @@ import org.elasticsearch.index.shard.ShardId;
|
|||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -264,7 +264,7 @@ public class RoutingIteratorTests extends ElasticsearchTestCase {
|
|||
|
||||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1", ImmutableMap.of("rack_id", "rack_1", "zone", "zone1")))
|
||||
.put(newNode("node2", ImmutableMap.of("rack_id", "rack_2", "zone", "zone2")))
|
||||
.localNodeId("node1")
|
||||
|
@ -313,7 +313,7 @@ public class RoutingIteratorTests extends ElasticsearchTestCase {
|
|||
|
||||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(newNodesBuilder()
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
.localNodeId("node1")
|
||||
|
|
|
@ -73,7 +73,7 @@ public class MulticastZenPingTests extends ElasticsearchTestCase {
|
|||
zenPingA.setNodesProvider(new DiscoveryNodesProvider() {
|
||||
@Override
|
||||
public DiscoveryNodes nodes() {
|
||||
return DiscoveryNodes.newNodesBuilder().put(nodeA).localNodeId("A").build();
|
||||
return DiscoveryNodes.builder().put(nodeA).localNodeId("A").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,7 +87,7 @@ public class MulticastZenPingTests extends ElasticsearchTestCase {
|
|||
zenPingB.setNodesProvider(new DiscoveryNodesProvider() {
|
||||
@Override
|
||||
public DiscoveryNodes nodes() {
|
||||
return DiscoveryNodes.newNodesBuilder().put(nodeB).localNodeId("B").build();
|
||||
return DiscoveryNodes.builder().put(nodeB).localNodeId("B").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,7 +124,7 @@ public class MulticastZenPingTests extends ElasticsearchTestCase {
|
|||
zenPingA.setNodesProvider(new DiscoveryNodesProvider() {
|
||||
@Override
|
||||
public DiscoveryNodes nodes() {
|
||||
return DiscoveryNodes.newNodesBuilder().put(nodeA).localNodeId("A").build();
|
||||
return DiscoveryNodes.builder().put(nodeA).localNodeId("A").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -76,7 +76,7 @@ public class UnicastZenPingTests extends ElasticsearchTestCase {
|
|||
zenPingA.setNodesProvider(new DiscoveryNodesProvider() {
|
||||
@Override
|
||||
public DiscoveryNodes nodes() {
|
||||
return DiscoveryNodes.newNodesBuilder().put(nodeA).localNodeId("UZP_A").build();
|
||||
return DiscoveryNodes.builder().put(nodeA).localNodeId("UZP_A").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,7 +90,7 @@ public class UnicastZenPingTests extends ElasticsearchTestCase {
|
|||
zenPingB.setNodesProvider(new DiscoveryNodesProvider() {
|
||||
@Override
|
||||
public DiscoveryNodes nodes() {
|
||||
return DiscoveryNodes.newNodesBuilder().put(nodeB).localNodeId("UZP_B").build();
|
||||
return DiscoveryNodes.builder().put(nodeB).localNodeId("UZP_B").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue