mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-26 14:54:56 +00:00
Log cluster health status changes
With this commit the cluster health status changes are logged on INFO level. The change is only logged on master and actively triggered in AllocationService in order to minimize the impact of constantly reevaluating ClusterState in a ClusterStateListener although we know that no health-relevant change happened. Closes #11657
This commit is contained in:
parent
56f543734e
commit
e31d66d137
@ -23,6 +23,7 @@ import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.IndicesRequest;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
|
@ -21,6 +21,7 @@ package org.elasticsearch.action.admin.cluster.health;
|
||||
|
||||
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ElasticsearchClient;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
|
@ -22,10 +22,9 @@ package org.elasticsearch.action.admin.cluster.health;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
import org.elasticsearch.cluster.routing.RoutingTableValidation;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.cluster.health.ClusterStateHealth;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterIndexHealth;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
@ -36,38 +35,22 @@ import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth.readClusterIndexHealth;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ClusterHealthResponse extends ActionResponse implements Iterable<ClusterIndexHealth>, StatusToXContent {
|
||||
|
||||
public class ClusterHealthResponse extends ActionResponse implements StatusToXContent {
|
||||
private String clusterName;
|
||||
int numberOfNodes = 0;
|
||||
int numberOfDataNodes = 0;
|
||||
int activeShards = 0;
|
||||
int relocatingShards = 0;
|
||||
int activePrimaryShards = 0;
|
||||
int initializingShards = 0;
|
||||
int unassignedShards = 0;
|
||||
int numberOfPendingTasks = 0;
|
||||
int numberOfInFlightFetch = 0;
|
||||
int delayedUnassignedShards = 0;
|
||||
TimeValue taskMaxWaitingTime = TimeValue.timeValueMillis(0);
|
||||
double activeShardsPercent = 100;
|
||||
boolean timedOut = false;
|
||||
ClusterHealthStatus status = ClusterHealthStatus.RED;
|
||||
private List<String> validationFailures;
|
||||
Map<String, ClusterIndexHealth> indices = new HashMap<>();
|
||||
private int numberOfPendingTasks = 0;
|
||||
private int numberOfInFlightFetch = 0;
|
||||
private int delayedUnassignedShards = 0;
|
||||
private TimeValue taskMaxWaitingTime = TimeValue.timeValueMillis(0);
|
||||
private boolean timedOut = false;
|
||||
private ClusterStateHealth clusterStateHealth;
|
||||
private ClusterHealthStatus clusterHealthStatus;
|
||||
|
||||
ClusterHealthResponse() {
|
||||
}
|
||||
@ -87,107 +70,53 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
|
||||
this.numberOfPendingTasks = numberOfPendingTasks;
|
||||
this.numberOfInFlightFetch = numberOfInFlightFetch;
|
||||
this.taskMaxWaitingTime = taskMaxWaitingTime;
|
||||
RoutingTableValidation validation = clusterState.routingTable().validate(clusterState.metaData());
|
||||
validationFailures = validation.failures();
|
||||
numberOfNodes = clusterState.nodes().size();
|
||||
numberOfDataNodes = clusterState.nodes().dataNodes().size();
|
||||
|
||||
for (String index : concreteIndices) {
|
||||
IndexRoutingTable indexRoutingTable = clusterState.routingTable().index(index);
|
||||
IndexMetaData indexMetaData = clusterState.metaData().index(index);
|
||||
if (indexRoutingTable == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ClusterIndexHealth indexHealth = new ClusterIndexHealth(indexMetaData, indexRoutingTable);
|
||||
|
||||
indices.put(indexHealth.getIndex(), indexHealth);
|
||||
}
|
||||
|
||||
status = ClusterHealthStatus.GREEN;
|
||||
|
||||
for (ClusterIndexHealth indexHealth : indices.values()) {
|
||||
activePrimaryShards += indexHealth.getActivePrimaryShards();
|
||||
activeShards += indexHealth.getActiveShards();
|
||||
relocatingShards += indexHealth.getRelocatingShards();
|
||||
initializingShards += indexHealth.getInitializingShards();
|
||||
unassignedShards += indexHealth.getUnassignedShards();
|
||||
if (indexHealth.getStatus() == ClusterHealthStatus.RED) {
|
||||
status = ClusterHealthStatus.RED;
|
||||
} else if (indexHealth.getStatus() == ClusterHealthStatus.YELLOW && status != ClusterHealthStatus.RED) {
|
||||
status = ClusterHealthStatus.YELLOW;
|
||||
}
|
||||
}
|
||||
|
||||
if (!validationFailures.isEmpty()) {
|
||||
status = ClusterHealthStatus.RED;
|
||||
} else if (clusterState.blocks().hasGlobalBlock(RestStatus.SERVICE_UNAVAILABLE)) {
|
||||
status = ClusterHealthStatus.RED;
|
||||
}
|
||||
|
||||
// shortcut on green
|
||||
if (status.equals(ClusterHealthStatus.GREEN)) {
|
||||
this.activeShardsPercent = 100;
|
||||
} else {
|
||||
List<ShardRouting> shardRoutings = clusterState.getRoutingTable().allShards();
|
||||
int activeShardCount = 0;
|
||||
int totalShardCount = 0;
|
||||
for (ShardRouting shardRouting : shardRoutings) {
|
||||
if (shardRouting.active()) activeShardCount++;
|
||||
totalShardCount++;
|
||||
}
|
||||
this.activeShardsPercent = (((double) activeShardCount) / totalShardCount) * 100;
|
||||
}
|
||||
this.clusterStateHealth = new ClusterStateHealth(clusterState, concreteIndices);
|
||||
this.clusterHealthStatus = clusterStateHealth.getStatus();
|
||||
}
|
||||
|
||||
public String getClusterName() {
|
||||
return clusterName;
|
||||
}
|
||||
|
||||
//package private for testing
|
||||
ClusterStateHealth getClusterStateHealth() {
|
||||
return clusterStateHealth;
|
||||
}
|
||||
|
||||
/**
|
||||
* The validation failures on the cluster level (without index validation failures).
|
||||
*/
|
||||
public List<String> getValidationFailures() {
|
||||
return this.validationFailures;
|
||||
return clusterStateHealth.getValidationFailures();
|
||||
}
|
||||
|
||||
/**
|
||||
* All the validation failures, including index level validation failures.
|
||||
*/
|
||||
public List<String> getAllValidationFailures() {
|
||||
List<String> allFailures = new ArrayList<>(getValidationFailures());
|
||||
for (ClusterIndexHealth indexHealth : indices.values()) {
|
||||
allFailures.addAll(indexHealth.getValidationFailures());
|
||||
}
|
||||
return allFailures;
|
||||
}
|
||||
|
||||
public int getActiveShards() {
|
||||
return activeShards;
|
||||
return clusterStateHealth.getActiveShards();
|
||||
}
|
||||
|
||||
public int getRelocatingShards() {
|
||||
return relocatingShards;
|
||||
return clusterStateHealth.getRelocatingShards();
|
||||
}
|
||||
|
||||
public int getActivePrimaryShards() {
|
||||
return activePrimaryShards;
|
||||
return clusterStateHealth.getActivePrimaryShards();
|
||||
}
|
||||
|
||||
public int getInitializingShards() {
|
||||
return initializingShards;
|
||||
return clusterStateHealth.getInitializingShards();
|
||||
}
|
||||
|
||||
public int getUnassignedShards() {
|
||||
return unassignedShards;
|
||||
return clusterStateHealth.getUnassignedShards();
|
||||
}
|
||||
|
||||
public int getNumberOfNodes() {
|
||||
return this.numberOfNodes;
|
||||
return clusterStateHealth.getNumberOfNodes();
|
||||
}
|
||||
|
||||
public int getNumberOfDataNodes() {
|
||||
return this.numberOfDataNodes;
|
||||
return clusterStateHealth.getNumberOfDataNodes();
|
||||
}
|
||||
|
||||
public int getNumberOfPendingTasks() {
|
||||
@ -214,12 +143,28 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
|
||||
return this.timedOut;
|
||||
}
|
||||
|
||||
public void setTimedOut(boolean timedOut) {
|
||||
this.timedOut = timedOut;
|
||||
}
|
||||
|
||||
public ClusterHealthStatus getStatus() {
|
||||
return status;
|
||||
return clusterHealthStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to explicitly override the derived cluster health status.
|
||||
*
|
||||
* @param status The override status. Must not be null.
|
||||
*/
|
||||
public void setStatus(ClusterHealthStatus status) {
|
||||
if (status == null) {
|
||||
throw new IllegalArgumentException("'status' must not be null");
|
||||
}
|
||||
this.clusterHealthStatus = status;
|
||||
}
|
||||
|
||||
public Map<String, ClusterIndexHealth> getIndices() {
|
||||
return indices;
|
||||
return clusterStateHealth.getIndices();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -234,15 +179,9 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
|
||||
* The percentage of active shards, should be 100% in a green system
|
||||
*/
|
||||
public double getActiveShardsPercent() {
|
||||
return activeShardsPercent;
|
||||
return clusterStateHealth.getActiveShardsPercent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ClusterIndexHealth> iterator() {
|
||||
return indices.values().iterator();
|
||||
}
|
||||
|
||||
|
||||
public static ClusterHealthResponse readResponseFrom(StreamInput in) throws IOException {
|
||||
ClusterHealthResponse response = new ClusterHealthResponse();
|
||||
response.readFrom(in);
|
||||
@ -253,36 +192,14 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
clusterName = in.readString();
|
||||
activePrimaryShards = in.readVInt();
|
||||
activeShards = in.readVInt();
|
||||
relocatingShards = in.readVInt();
|
||||
initializingShards = in.readVInt();
|
||||
unassignedShards = in.readVInt();
|
||||
numberOfNodes = in.readVInt();
|
||||
numberOfDataNodes = in.readVInt();
|
||||
clusterHealthStatus = ClusterHealthStatus.fromValue(in.readByte());
|
||||
clusterStateHealth = ClusterStateHealth.readClusterHealth(in);
|
||||
numberOfPendingTasks = in.readInt();
|
||||
status = ClusterHealthStatus.fromValue(in.readByte());
|
||||
int size = in.readVInt();
|
||||
for (int i = 0; i < size; i++) {
|
||||
ClusterIndexHealth indexHealth = readClusterIndexHealth(in);
|
||||
indices.put(indexHealth.getIndex(), indexHealth);
|
||||
}
|
||||
timedOut = in.readBoolean();
|
||||
size = in.readVInt();
|
||||
if (size == 0) {
|
||||
validationFailures = Collections.emptyList();
|
||||
} else {
|
||||
for (int i = 0; i < size; i++) {
|
||||
validationFailures.add(in.readString());
|
||||
}
|
||||
}
|
||||
|
||||
numberOfInFlightFetch = in.readInt();
|
||||
if (in.getVersion().onOrAfter(Version.V_1_7_0)) {
|
||||
delayedUnassignedShards= in.readInt();
|
||||
}
|
||||
|
||||
activeShardsPercent = in.readDouble();
|
||||
taskMaxWaitingTime = TimeValue.readTimeValue(in);
|
||||
}
|
||||
|
||||
@ -290,31 +207,14 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(clusterName);
|
||||
out.writeVInt(activePrimaryShards);
|
||||
out.writeVInt(activeShards);
|
||||
out.writeVInt(relocatingShards);
|
||||
out.writeVInt(initializingShards);
|
||||
out.writeVInt(unassignedShards);
|
||||
out.writeVInt(numberOfNodes);
|
||||
out.writeVInt(numberOfDataNodes);
|
||||
out.writeByte(clusterHealthStatus.value());
|
||||
clusterStateHealth.writeTo(out);
|
||||
out.writeInt(numberOfPendingTasks);
|
||||
out.writeByte(status.value());
|
||||
out.writeVInt(indices.size());
|
||||
for (ClusterIndexHealth indexHealth : this) {
|
||||
indexHealth.writeTo(out);
|
||||
}
|
||||
out.writeBoolean(timedOut);
|
||||
|
||||
out.writeVInt(validationFailures.size());
|
||||
for (String failure : validationFailures) {
|
||||
out.writeString(failure);
|
||||
}
|
||||
|
||||
out.writeInt(numberOfInFlightFetch);
|
||||
if (out.getVersion().onOrAfter(Version.V_1_7_0)) {
|
||||
out.writeInt(delayedUnassignedShards);
|
||||
}
|
||||
out.writeDouble(activeShardsPercent);
|
||||
taskMaxWaitingTime.writeTo(out);
|
||||
}
|
||||
|
||||
@ -389,7 +289,7 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
|
||||
// if we don't print index level information, still print the index validation failures
|
||||
// so we know why the status is red
|
||||
if (!outputIndices) {
|
||||
for (ClusterIndexHealth indexHealth : indices.values()) {
|
||||
for (ClusterIndexHealth indexHealth : clusterStateHealth.getIndices().values()) {
|
||||
builder.startObject(indexHealth.getIndex());
|
||||
|
||||
if (!indexHealth.getValidationFailures().isEmpty()) {
|
||||
@ -408,7 +308,7 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
|
||||
|
||||
if (outputIndices) {
|
||||
builder.startObject(Fields.INDICES);
|
||||
for (ClusterIndexHealth indexHealth : indices.values()) {
|
||||
for (ClusterIndexHealth indexHealth : clusterStateHealth.getIndices().values()) {
|
||||
builder.startObject(indexHealth.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
|
||||
indexHealth.toXContent(builder, params);
|
||||
builder.endObject();
|
||||
|
@ -25,6 +25,7 @@ import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
|
||||
import org.elasticsearch.cluster.*;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||
import org.elasticsearch.common.Strings;
|
||||
@ -184,7 +185,7 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
|
||||
// if the state is sufficient for what we where waiting for we don't need to mark this as timedOut.
|
||||
// We spend too much time in waiting for events such that we might already reached a valid state.
|
||||
// this should not mark the request as timed out
|
||||
response.timedOut = timedOut && valid == false;
|
||||
response.setTimedOut(timedOut && valid == false);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -204,7 +205,7 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
|
||||
indexNameExpressionResolver.concreteIndices(clusterState, IndicesOptions.strictExpand(), request.indices());
|
||||
waitForCounter++;
|
||||
} catch (IndexNotFoundException e) {
|
||||
response.status = ClusterHealthStatus.RED; // no indices, make sure its RED
|
||||
response.setStatus(ClusterHealthStatus.RED); // no indices, make sure its RED
|
||||
// missing indices, wait a bit more...
|
||||
}
|
||||
}
|
||||
@ -274,7 +275,7 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
|
||||
ClusterHealthResponse response = new ClusterHealthResponse(clusterName.value(), Strings.EMPTY_ARRAY, clusterState,
|
||||
numberOfPendingTasks, numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(System.currentTimeMillis(), settings, clusterState),
|
||||
pendingTaskTimeInQueue);
|
||||
response.status = ClusterHealthStatus.RED;
|
||||
response.setStatus(ClusterHealthStatus.RED);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeAct
|
||||
@Override
|
||||
public ClusterState execute(final ClusterState currentState) {
|
||||
// now, reroute in case things that require it changed (e.g. number of replicas)
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(currentState);
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(currentState, "reroute after cluster update settings");
|
||||
if (!routingResult.changed()) {
|
||||
return currentState;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.action.admin.cluster.stats;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
|
||||
import org.elasticsearch.action.admin.indices.stats.ShardStats;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.action.admin.cluster.stats;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
|
@ -19,8 +19,7 @@
|
||||
|
||||
package org.elasticsearch.action.admin.cluster.stats;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
|
||||
import org.elasticsearch.action.admin.indices.stats.CommonStats;
|
||||
@ -31,10 +30,8 @@ import org.elasticsearch.action.support.nodes.BaseNodeRequest;
|
||||
import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.health.ClusterStateHealth;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
import org.elasticsearch.cluster.routing.RoutingTableValidation;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
@ -43,7 +40,6 @@ import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.shard.IndexShard;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.node.service.NodeService;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
@ -116,34 +112,7 @@ public class TransportClusterStatsAction extends TransportNodesAction<ClusterSta
|
||||
|
||||
ClusterHealthStatus clusterStatus = null;
|
||||
if (clusterService.state().nodes().localNodeMaster()) {
|
||||
// populate cluster status
|
||||
clusterStatus = ClusterHealthStatus.GREEN;
|
||||
for (IndexRoutingTable indexRoutingTable : clusterService.state().routingTable()) {
|
||||
IndexMetaData indexMetaData = clusterService.state().metaData().index(indexRoutingTable.index());
|
||||
if (indexRoutingTable == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ClusterIndexHealth indexHealth = new ClusterIndexHealth(indexMetaData, indexRoutingTable);
|
||||
switch (indexHealth.getStatus()) {
|
||||
case RED:
|
||||
clusterStatus = ClusterHealthStatus.RED;
|
||||
break;
|
||||
case YELLOW:
|
||||
if (clusterStatus != ClusterHealthStatus.RED) {
|
||||
clusterStatus = ClusterHealthStatus.YELLOW;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RoutingTableValidation validation = clusterService.state().routingTable().validate(clusterService.state().metaData());
|
||||
|
||||
if (!validation.failures().isEmpty()) {
|
||||
clusterStatus = ClusterHealthStatus.RED;
|
||||
} else if (clusterService.state().blocks().hasGlobalBlock(RestStatus.SERVICE_UNAVAILABLE)) {
|
||||
clusterStatus = ClusterHealthStatus.RED;
|
||||
}
|
||||
clusterStatus = new ClusterStateHealth(clusterService.state()).getStatus();
|
||||
}
|
||||
|
||||
return new ClusterStatsNodeResponse(nodeInfo.getNode(), clusterStatus, nodeInfo, nodeStats, shardsStats.toArray(new ShardStats[shardsStats.size()]));
|
||||
|
@ -23,6 +23,7 @@ import org.elasticsearch.action.Action;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ElasticsearchClient;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
|
||||
/**
|
||||
* Request builder for {@link IndicesShardStoresRequest}
|
||||
@ -53,7 +54,7 @@ public class IndicesShardStoreRequestBuilder extends MasterNodeReadOperationRequ
|
||||
/**
|
||||
* Set statuses to filter shards to get stores info on.
|
||||
* @param shardStatuses acceptable values are "green", "yellow", "red" and "all"
|
||||
* see {@link org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus} for details
|
||||
* see {@link ClusterHealthStatus} for details
|
||||
*/
|
||||
public IndicesShardStoreRequestBuilder setShardStatuses(String... shardStatuses) {
|
||||
request.shardStatuses(shardStatuses);
|
||||
|
@ -20,7 +20,7 @@ package org.elasticsearch.action.admin.indices.shards;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.IndicesRequest;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -21,8 +21,8 @@ package org.elasticsearch.action.admin.indices.shards;
|
||||
import org.apache.lucene.util.CollectionUtil;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.FailedNodeException;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterShardHealth;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterShardHealth;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.cluster.health;
|
||||
package org.elasticsearch.cluster.health;
|
||||
|
||||
|
||||
/**
|
@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.cluster.health;
|
||||
package org.elasticsearch.cluster.health;
|
||||
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
@ -37,12 +37,9 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.action.admin.cluster.health.ClusterShardHealth.readClusterShardHealth;
|
||||
import static org.elasticsearch.cluster.health.ClusterShardHealth.readClusterShardHealth;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streamable, ToXContent {
|
||||
public final class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streamable, ToXContent {
|
||||
|
||||
private String index;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.cluster.health;
|
||||
package org.elasticsearch.cluster.health;
|
||||
|
||||
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
@ -27,10 +27,7 @@ import org.elasticsearch.common.io.stream.Streamable;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ClusterShardHealth implements Streamable {
|
||||
public final class ClusterShardHealth implements Streamable {
|
||||
|
||||
private int shardId;
|
||||
|
@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch.cluster.health;
|
||||
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.RoutingTableValidation;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static org.elasticsearch.cluster.health.ClusterIndexHealth.readClusterIndexHealth;
|
||||
|
||||
public final class ClusterStateHealth implements Iterable<ClusterIndexHealth>, Streamable {
|
||||
private int numberOfNodes = 0;
|
||||
private int numberOfDataNodes = 0;
|
||||
private int activeShards = 0;
|
||||
private int relocatingShards = 0;
|
||||
private int activePrimaryShards = 0;
|
||||
private int initializingShards = 0;
|
||||
private int unassignedShards = 0;
|
||||
private double activeShardsPercent = 100;
|
||||
private ClusterHealthStatus status = ClusterHealthStatus.RED;
|
||||
private List<String> validationFailures;
|
||||
private Map<String, ClusterIndexHealth> indices = new HashMap<>();
|
||||
|
||||
public static ClusterStateHealth readClusterHealth(StreamInput in) throws IOException {
|
||||
ClusterStateHealth clusterStateHealth = new ClusterStateHealth();
|
||||
clusterStateHealth.readFrom(in);
|
||||
return clusterStateHealth;
|
||||
}
|
||||
|
||||
ClusterStateHealth() {
|
||||
// only intended for serialization
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>ClusterStateHealth</code> instance based on cluster meta data and its routing table as a convenience.
|
||||
*
|
||||
* @param clusterMetaData Current cluster meta data. Must not be null.
|
||||
* @param routingTables Current routing table. Must not be null.
|
||||
*/
|
||||
public ClusterStateHealth(MetaData clusterMetaData, RoutingTable routingTables) {
|
||||
this(ClusterState.builder(ClusterName.DEFAULT).metaData(clusterMetaData).routingTable(routingTables).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>ClusterStateHealth</code> instance considering the current cluster state and all indices in the cluster.
|
||||
*
|
||||
* @param clusterState The current cluster state. Must not be null.
|
||||
*/
|
||||
public ClusterStateHealth(ClusterState clusterState) {
|
||||
this(clusterState, clusterState.metaData().concreteAllIndices());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>ClusterStateHealth</code> instance considering the current cluster state and the provided index names.
|
||||
*
|
||||
* @param clusterState The current cluster state. Must not be null.
|
||||
* @param concreteIndices An array of index names to consider. Must not be null but may be empty.
|
||||
*/
|
||||
public ClusterStateHealth(ClusterState clusterState, String[] concreteIndices) {
|
||||
RoutingTableValidation validation = clusterState.routingTable().validate(clusterState.metaData());
|
||||
validationFailures = validation.failures();
|
||||
numberOfNodes = clusterState.nodes().size();
|
||||
numberOfDataNodes = clusterState.nodes().dataNodes().size();
|
||||
|
||||
for (String index : concreteIndices) {
|
||||
IndexRoutingTable indexRoutingTable = clusterState.routingTable().index(index);
|
||||
IndexMetaData indexMetaData = clusterState.metaData().index(index);
|
||||
if (indexRoutingTable == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ClusterIndexHealth indexHealth = new ClusterIndexHealth(indexMetaData, indexRoutingTable);
|
||||
|
||||
indices.put(indexHealth.getIndex(), indexHealth);
|
||||
}
|
||||
|
||||
status = ClusterHealthStatus.GREEN;
|
||||
|
||||
for (ClusterIndexHealth indexHealth : indices.values()) {
|
||||
activePrimaryShards += indexHealth.getActivePrimaryShards();
|
||||
activeShards += indexHealth.getActiveShards();
|
||||
relocatingShards += indexHealth.getRelocatingShards();
|
||||
initializingShards += indexHealth.getInitializingShards();
|
||||
unassignedShards += indexHealth.getUnassignedShards();
|
||||
if (indexHealth.getStatus() == ClusterHealthStatus.RED) {
|
||||
status = ClusterHealthStatus.RED;
|
||||
} else if (indexHealth.getStatus() == ClusterHealthStatus.YELLOW && status != ClusterHealthStatus.RED) {
|
||||
status = ClusterHealthStatus.YELLOW;
|
||||
}
|
||||
}
|
||||
|
||||
if (!validationFailures.isEmpty()) {
|
||||
status = ClusterHealthStatus.RED;
|
||||
} else if (clusterState.blocks().hasGlobalBlock(RestStatus.SERVICE_UNAVAILABLE)) {
|
||||
status = ClusterHealthStatus.RED;
|
||||
}
|
||||
|
||||
// shortcut on green
|
||||
if (status.equals(ClusterHealthStatus.GREEN)) {
|
||||
this.activeShardsPercent = 100;
|
||||
} else {
|
||||
List<ShardRouting> shardRoutings = clusterState.getRoutingTable().allShards();
|
||||
int activeShardCount = 0;
|
||||
int totalShardCount = 0;
|
||||
for (ShardRouting shardRouting : shardRoutings) {
|
||||
if (shardRouting.active()) activeShardCount++;
|
||||
totalShardCount++;
|
||||
}
|
||||
this.activeShardsPercent = (((double) activeShardCount) / totalShardCount) * 100;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getValidationFailures() {
|
||||
return Collections.unmodifiableList(validationFailures);
|
||||
}
|
||||
|
||||
public int getActiveShards() {
|
||||
return activeShards;
|
||||
}
|
||||
|
||||
public int getRelocatingShards() {
|
||||
return relocatingShards;
|
||||
}
|
||||
|
||||
public int getActivePrimaryShards() {
|
||||
return activePrimaryShards;
|
||||
}
|
||||
|
||||
public int getInitializingShards() {
|
||||
return initializingShards;
|
||||
}
|
||||
|
||||
public int getUnassignedShards() {
|
||||
return unassignedShards;
|
||||
}
|
||||
|
||||
public int getNumberOfNodes() {
|
||||
return this.numberOfNodes;
|
||||
}
|
||||
|
||||
public int getNumberOfDataNodes() {
|
||||
return this.numberOfDataNodes;
|
||||
}
|
||||
|
||||
public ClusterHealthStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Map<String, ClusterIndexHealth> getIndices() {
|
||||
return Collections.unmodifiableMap(indices);
|
||||
}
|
||||
|
||||
public double getActiveShardsPercent() {
|
||||
return activeShardsPercent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ClusterIndexHealth> iterator() {
|
||||
return indices.values().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
activePrimaryShards = in.readVInt();
|
||||
activeShards = in.readVInt();
|
||||
relocatingShards = in.readVInt();
|
||||
initializingShards = in.readVInt();
|
||||
unassignedShards = in.readVInt();
|
||||
numberOfNodes = in.readVInt();
|
||||
numberOfDataNodes = in.readVInt();
|
||||
status = ClusterHealthStatus.fromValue(in.readByte());
|
||||
int size = in.readVInt();
|
||||
for (int i = 0; i < size; i++) {
|
||||
ClusterIndexHealth indexHealth = readClusterIndexHealth(in);
|
||||
indices.put(indexHealth.getIndex(), indexHealth);
|
||||
}
|
||||
size = in.readVInt();
|
||||
if (size == 0) {
|
||||
validationFailures = Collections.emptyList();
|
||||
} else {
|
||||
for (int i = 0; i < size; i++) {
|
||||
validationFailures.add(in.readString());
|
||||
}
|
||||
}
|
||||
activeShardsPercent = in.readDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeVInt(activePrimaryShards);
|
||||
out.writeVInt(activeShards);
|
||||
out.writeVInt(relocatingShards);
|
||||
out.writeVInt(initializingShards);
|
||||
out.writeVInt(unassignedShards);
|
||||
out.writeVInt(numberOfNodes);
|
||||
out.writeVInt(numberOfDataNodes);
|
||||
out.writeByte(status.value());
|
||||
out.writeVInt(indices.size());
|
||||
for (ClusterIndexHealth indexHealth : this) {
|
||||
indexHealth.writeTo(out);
|
||||
}
|
||||
out.writeVInt(validationFailures.size());
|
||||
for (String failure : validationFailures) {
|
||||
out.writeString(failure);
|
||||
}
|
||||
out.writeDouble(activeShardsPercent);
|
||||
}
|
||||
}
|
@ -398,7 +398,9 @@ public class MetaDataCreateIndexService extends AbstractComponent {
|
||||
if (request.state() == State.OPEN) {
|
||||
RoutingTable.Builder routingTableBuilder = RoutingTable.builder(updatedState.routingTable())
|
||||
.addAsNew(updatedState.metaData().index(request.index()));
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(ClusterState.builder(updatedState).routingTable(routingTableBuilder.build()).build());
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(
|
||||
ClusterState.builder(updatedState).routingTable(routingTableBuilder.build()).build(),
|
||||
"index [" + request.index() + "] created");
|
||||
updatedState = ClusterState.builder(updatedState).routingResult(routingResult).build();
|
||||
}
|
||||
removalReason = "cleaning up after validating index on master";
|
||||
|
@ -39,6 +39,7 @@ import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -136,7 +137,8 @@ public class MetaDataDeleteIndexService extends AbstractComponent {
|
||||
MetaData newMetaData = metaDataBuilder.build();
|
||||
ClusterBlocks blocks = clusterBlocksBuilder.build();
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(
|
||||
ClusterState.builder(currentState).routingTable(routingTableBuilder.build()).metaData(newMetaData).build());
|
||||
ClusterState.builder(currentState).routingTable(routingTableBuilder.build()).metaData(newMetaData).build(),
|
||||
"deleted indices [" + indices + "]");
|
||||
return ClusterState.builder(currentState).routingResult(routingResult).metaData(newMetaData).blocks(blocks).build();
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ import org.elasticsearch.rest.RestStatus;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Service responsible for submitting open/close index requests
|
||||
@ -124,7 +125,9 @@ public class MetaDataIndexStateService extends AbstractComponent {
|
||||
rtBuilder.remove(index);
|
||||
}
|
||||
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(ClusterState.builder(updatedState).routingTable(rtBuilder.build()).build());
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(
|
||||
ClusterState.builder(updatedState).routingTable(rtBuilder.build()).build(),
|
||||
"indices closed [" + indicesAsString + "]");
|
||||
//no explicit wait for other nodes needed as we use AckedClusterStateUpdateTask
|
||||
return ClusterState.builder(updatedState).routingResult(routingResult).build();
|
||||
}
|
||||
@ -181,7 +184,9 @@ public class MetaDataIndexStateService extends AbstractComponent {
|
||||
rtBuilder.addAsFromCloseToOpen(updatedState.metaData().index(index));
|
||||
}
|
||||
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(ClusterState.builder(updatedState).routingTable(rtBuilder.build()).build());
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(
|
||||
ClusterState.builder(updatedState).routingTable(rtBuilder.build()).build(),
|
||||
"indices opened [" + indicesAsString + "]");
|
||||
//no explicit wait for other nodes needed as we use AckedClusterStateUpdateTask
|
||||
return ClusterState.builder(updatedState).routingResult(routingResult).build();
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements
|
||||
ClusterState updatedState = ClusterState.builder(currentState).metaData(metaDataBuilder).routingTable(routingTableBuilder.build()).blocks(blocks).build();
|
||||
|
||||
// now, reroute in case things change that require it (like number of replicas)
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(updatedState);
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(updatedState, "settings update");
|
||||
updatedState = ClusterState.builder(updatedState).routingResult(routingResult).build();
|
||||
|
||||
return updatedState;
|
||||
|
@ -31,6 +31,7 @@ import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
import org.elasticsearch.common.util.concurrent.FutureUtils;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@ -173,7 +174,7 @@ public class RoutingService extends AbstractLifecycleComponent<RoutingService> i
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
rerouting.set(false);
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(currentState);
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(currentState, reason);
|
||||
if (!routingResult.changed()) {
|
||||
// no state changed
|
||||
return currentState;
|
||||
|
@ -22,6 +22,8 @@ package org.elasticsearch.cluster.routing.allocation;
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import org.elasticsearch.cluster.ClusterInfoService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.health.ClusterStateHealth;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
@ -41,6 +43,10 @@ import org.elasticsearch.common.settings.Settings;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@ -85,7 +91,16 @@ public class AllocationService extends AbstractComponent {
|
||||
if (withReroute) {
|
||||
reroute(allocation);
|
||||
}
|
||||
return new RoutingAllocation.Result(true, new RoutingTable.Builder().updateNodes(routingNodes).build().validateRaiseException(clusterState.metaData()));
|
||||
RoutingTable routingTable = new RoutingTable.Builder().updateNodes(routingNodes).build().validateRaiseException(clusterState.metaData());
|
||||
RoutingAllocation.Result result = new RoutingAllocation.Result(true, routingTable);
|
||||
|
||||
String startedShardsAsString = firstListElementsToCommaDelimitedString(startedShards, s -> s.shardId().toString());
|
||||
logClusterHealthStateChange(
|
||||
new ClusterStateHealth(clusterState),
|
||||
new ClusterStateHealth(clusterState.metaData(), routingTable),
|
||||
"shards started [" + startedShardsAsString + "] ..."
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
public RoutingAllocation.Result applyFailedShard(ClusterState clusterState, ShardRouting failedShard) {
|
||||
@ -111,7 +126,32 @@ public class AllocationService extends AbstractComponent {
|
||||
}
|
||||
shardsAllocators.applyFailedShards(allocation);
|
||||
reroute(allocation);
|
||||
return new RoutingAllocation.Result(true, new RoutingTable.Builder().updateNodes(routingNodes).build().validateRaiseException(clusterState.metaData()));
|
||||
RoutingTable routingTable = new RoutingTable.Builder().updateNodes(routingNodes).build().validateRaiseException(clusterState.metaData());
|
||||
RoutingAllocation.Result result = new RoutingAllocation.Result(true, routingTable);
|
||||
String failedShardsAsString = firstListElementsToCommaDelimitedString(failedShards, s -> s.shard.shardId().toString());
|
||||
logClusterHealthStateChange(
|
||||
new ClusterStateHealth(clusterState),
|
||||
new ClusterStateHealth(clusterState.getMetaData(), routingTable),
|
||||
"shards failed [" + failedShardsAsString + "] ..."
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal helper to cap the number of elements in a potentially long list for logging.
|
||||
*
|
||||
* @param elements The elements to log. May be any non-null list. Must not be null.
|
||||
* @param formatter A function that can convert list elements to a String. Must not be null.
|
||||
* @param <T> The list element type.
|
||||
* @return A comma-separated string of the first few elements.
|
||||
*/
|
||||
private <T> String firstListElementsToCommaDelimitedString(List<T> elements, Function<T, String> formatter) {
|
||||
final int maxNumberOfElements = 10;
|
||||
return elements
|
||||
.stream()
|
||||
.limit(maxNumberOfElements)
|
||||
.map(formatter)
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
public RoutingAllocation.Result reroute(ClusterState clusterState, AllocationCommands commands) {
|
||||
@ -134,7 +174,14 @@ public class AllocationService extends AbstractComponent {
|
||||
// the assumption is that commands will move / act on shards (or fail through exceptions)
|
||||
// so, there will always be shard "movements", so no need to check on reroute
|
||||
reroute(allocation);
|
||||
return new RoutingAllocation.Result(true, new RoutingTable.Builder().updateNodes(routingNodes).build().validateRaiseException(clusterState.metaData()), explanations);
|
||||
RoutingTable routingTable = new RoutingTable.Builder().updateNodes(routingNodes).build().validateRaiseException(clusterState.metaData());
|
||||
RoutingAllocation.Result result = new RoutingAllocation.Result(true, routingTable, explanations);
|
||||
logClusterHealthStateChange(
|
||||
new ClusterStateHealth(clusterState),
|
||||
new ClusterStateHealth(clusterState.getMetaData(), routingTable),
|
||||
"reroute commands"
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -142,8 +189,8 @@ public class AllocationService extends AbstractComponent {
|
||||
* <p>
|
||||
* If the same instance of the routing table is returned, then no change has been made.
|
||||
*/
|
||||
public RoutingAllocation.Result reroute(ClusterState clusterState) {
|
||||
return reroute(clusterState, false);
|
||||
public RoutingAllocation.Result reroute(ClusterState clusterState, String reason) {
|
||||
return reroute(clusterState, reason, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,7 +198,7 @@ public class AllocationService extends AbstractComponent {
|
||||
* <p>
|
||||
* If the same instance of the routing table is returned, then no change has been made.
|
||||
*/
|
||||
public RoutingAllocation.Result reroute(ClusterState clusterState, boolean debug) {
|
||||
protected RoutingAllocation.Result reroute(ClusterState clusterState, String reason, boolean debug) {
|
||||
RoutingNodes routingNodes = getMutableRoutingNodes(clusterState);
|
||||
// shuffle the unassigned nodes, just so we won't have things like poison failed shards
|
||||
routingNodes.unassigned().shuffle();
|
||||
@ -160,7 +207,22 @@ public class AllocationService extends AbstractComponent {
|
||||
if (!reroute(allocation)) {
|
||||
return new RoutingAllocation.Result(false, clusterState.routingTable());
|
||||
}
|
||||
return new RoutingAllocation.Result(true, new RoutingTable.Builder().updateNodes(routingNodes).build().validateRaiseException(clusterState.metaData()));
|
||||
RoutingTable routingTable = new RoutingTable.Builder().updateNodes(routingNodes).build().validateRaiseException(clusterState.metaData());
|
||||
RoutingAllocation.Result result = new RoutingAllocation.Result(true, routingTable);
|
||||
logClusterHealthStateChange(
|
||||
new ClusterStateHealth(clusterState),
|
||||
new ClusterStateHealth(clusterState.getMetaData(), routingTable),
|
||||
reason
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void logClusterHealthStateChange(ClusterStateHealth previousStateHealth, ClusterStateHealth newStateHealth, String reason) {
|
||||
ClusterHealthStatus previousHealth = previousStateHealth.getStatus();
|
||||
ClusterHealthStatus currentHealth = newStateHealth.getStatus();
|
||||
if (!previousHealth.equals(currentHealth)) {
|
||||
logger.info("Cluster health status changed from [{}] to [{}] (reason: [{}]).", previousHealth, currentHealth, reason);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean reroute(RoutingAllocation allocation) {
|
||||
|
@ -261,7 +261,8 @@ public class LocalDiscovery extends AbstractLifecycleComponent<Discovery> implem
|
||||
}
|
||||
// reroute here, so we eagerly remove dead nodes from the routing
|
||||
ClusterState updatedState = ClusterState.builder(currentState).nodes(newNodes).build();
|
||||
RoutingAllocation.Result routingResult = master.routingService.getAllocationService().reroute(ClusterState.builder(updatedState).build());
|
||||
RoutingAllocation.Result routingResult = master.routingService.getAllocationService().reroute(
|
||||
ClusterState.builder(updatedState).build(), "elected as master");
|
||||
return ClusterState.builder(updatedState).routingResult(routingResult).build();
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ public class NodeJoinController extends AbstractComponent {
|
||||
currentState = ClusterState.builder(currentState).nodes(builder).blocks(clusterBlocks).build();
|
||||
|
||||
// reroute now to remove any dead nodes (master may have stepped down when they left and didn't update the routing table)
|
||||
RoutingAllocation.Result result = routingService.getAllocationService().reroute(currentState);
|
||||
RoutingAllocation.Result result = routingService.getAllocationService().reroute(currentState, "nodes joined");
|
||||
if (result.changed()) {
|
||||
currentState = ClusterState.builder(currentState).routingResult(result).build();
|
||||
}
|
||||
|
@ -60,10 +60,7 @@ import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -511,7 +508,9 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
||||
return rejoin(currentState, "not enough master nodes");
|
||||
}
|
||||
// eagerly run reroute to remove dead nodes from routing table
|
||||
RoutingAllocation.Result routingResult = routingService.getAllocationService().reroute(ClusterState.builder(currentState).build());
|
||||
RoutingAllocation.Result routingResult = routingService.getAllocationService().reroute(
|
||||
ClusterState.builder(currentState).build(),
|
||||
"[" + node + "] left");
|
||||
return ClusterState.builder(currentState).routingResult(routingResult).build();
|
||||
}
|
||||
|
||||
@ -554,7 +553,9 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
||||
return rejoin(currentState, "not enough master nodes");
|
||||
}
|
||||
// eagerly run reroute to remove dead nodes from routing table
|
||||
RoutingAllocation.Result routingResult = routingService.getAllocationService().reroute(ClusterState.builder(currentState).build());
|
||||
RoutingAllocation.Result routingResult = routingService.getAllocationService().reroute(
|
||||
ClusterState.builder(currentState).build(),
|
||||
"[" + node + "] failed");
|
||||
return ClusterState.builder(currentState).routingResult(routingResult).build();
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,9 @@ public class GatewayService extends AbstractLifecycleComponent<GatewayService> i
|
||||
routingTableBuilder.version(0);
|
||||
|
||||
// now, reroute
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(ClusterState.builder(updatedState).routingTable(routingTableBuilder.build()).build());
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(
|
||||
ClusterState.builder(updatedState).routingTable(routingTableBuilder.build()).build(),
|
||||
"state recovered");
|
||||
|
||||
return ClusterState.builder(updatedState).routingResult(routingResult).build();
|
||||
}
|
||||
|
@ -168,7 +168,8 @@ public class LocalAllocateDangledIndices extends AbstractComponent {
|
||||
ClusterState updatedState = ClusterState.builder(currentState).metaData(metaData).blocks(blocks).routingTable(routingTable).build();
|
||||
|
||||
// now, reroute
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(ClusterState.builder(updatedState).routingTable(routingTable).build());
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(
|
||||
ClusterState.builder(updatedState).routingTable(routingTable).build(), "dangling indices allocated");
|
||||
|
||||
return ClusterState.builder(updatedState).routingResult(routingResult).build();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.health;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.cat;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth;
|
||||
import org.elasticsearch.cluster.health.ClusterIndexHealth;
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
||||
import org.elasticsearch.action.admin.indices.stats.IndexStats;
|
||||
|
@ -288,7 +288,9 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
|
||||
|
||||
RoutingTable rt = rtBuilder.build();
|
||||
ClusterState updatedState = builder.metaData(mdBuilder).blocks(blocks).routingTable(rt).build();
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(ClusterState.builder(updatedState).routingTable(rt).build());
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(
|
||||
ClusterState.builder(updatedState).routingTable(rt).build(),
|
||||
"restored snapshot [" + snapshotId + "]");
|
||||
return ClusterState.builder(updatedState).routingResult(routingResult).build();
|
||||
}
|
||||
|
||||
|
@ -19,25 +19,13 @@
|
||||
|
||||
package org.elasticsearch.action.admin.cluster.health;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.health.ClusterStateHealth;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
||||
import org.elasticsearch.cluster.routing.TestShardRouting;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.hamcrest.Matchers;
|
||||
@ -45,151 +33,14 @@ import org.hamcrest.Matchers;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.allOf;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
public class ClusterHealthResponsesTests extends ESTestCase {
|
||||
|
||||
private final IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(Settings.EMPTY);
|
||||
|
||||
private void assertIndexHealth(ClusterIndexHealth indexHealth, ShardCounter counter, IndexMetaData indexMetaData) {
|
||||
assertThat(indexHealth.getStatus(), equalTo(counter.status()));
|
||||
assertThat(indexHealth.getNumberOfShards(), equalTo(indexMetaData.getNumberOfShards()));
|
||||
assertThat(indexHealth.getNumberOfReplicas(), equalTo(indexMetaData.getNumberOfReplicas()));
|
||||
assertThat(indexHealth.getActiveShards(), equalTo(counter.active));
|
||||
assertThat(indexHealth.getRelocatingShards(), equalTo(counter.relocating));
|
||||
assertThat(indexHealth.getInitializingShards(), equalTo(counter.initializing));
|
||||
assertThat(indexHealth.getUnassignedShards(), equalTo(counter.unassigned));
|
||||
assertThat(indexHealth.getShards().size(), equalTo(indexMetaData.getNumberOfShards()));
|
||||
assertThat(indexHealth.getValidationFailures(), empty());
|
||||
int totalShards = 0;
|
||||
for (ClusterShardHealth shardHealth : indexHealth.getShards().values()) {
|
||||
totalShards += shardHealth.getActiveShards() + shardHealth.getInitializingShards() + shardHealth.getUnassignedShards();
|
||||
}
|
||||
|
||||
assertThat(totalShards, equalTo(indexMetaData.getNumberOfShards() * (1 + indexMetaData.getNumberOfReplicas())));
|
||||
}
|
||||
|
||||
protected class ShardCounter {
|
||||
public int active;
|
||||
public int relocating;
|
||||
public int initializing;
|
||||
public int unassigned;
|
||||
public int primaryActive;
|
||||
public int primaryInactive;
|
||||
|
||||
public ClusterHealthStatus status() {
|
||||
if (primaryInactive > 0) {
|
||||
return ClusterHealthStatus.RED;
|
||||
}
|
||||
if (unassigned > 0 || initializing > 0) {
|
||||
return ClusterHealthStatus.YELLOW;
|
||||
}
|
||||
return ClusterHealthStatus.GREEN;
|
||||
}
|
||||
|
||||
public void update(ShardRouting shardRouting) {
|
||||
if (shardRouting.active()) {
|
||||
active++;
|
||||
if (shardRouting.primary()) {
|
||||
primaryActive++;
|
||||
}
|
||||
if (shardRouting.relocating()) {
|
||||
relocating++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (shardRouting.primary()) {
|
||||
primaryInactive++;
|
||||
}
|
||||
if (shardRouting.initializing()) {
|
||||
initializing++;
|
||||
} else {
|
||||
unassigned++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int node_id = 1;
|
||||
|
||||
private ShardRouting genShardRouting(String index, int shardId, boolean primary) {
|
||||
|
||||
ShardRoutingState state;
|
||||
|
||||
int i = randomInt(40);
|
||||
if (i > 5) {
|
||||
state = ShardRoutingState.STARTED;
|
||||
} else if (i > 3) {
|
||||
state = ShardRoutingState.RELOCATING;
|
||||
} else {
|
||||
state = ShardRoutingState.INITIALIZING;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case STARTED:
|
||||
return TestShardRouting.newShardRouting(index, shardId, "node_" + Integer.toString(node_id++), null, null, primary, ShardRoutingState.STARTED, 1);
|
||||
case INITIALIZING:
|
||||
return TestShardRouting.newShardRouting(index, shardId, "node_" + Integer.toString(node_id++), null, null, primary, ShardRoutingState.INITIALIZING, 1);
|
||||
case RELOCATING:
|
||||
return TestShardRouting.newShardRouting(index, shardId, "node_" + Integer.toString(node_id++), "node_" + Integer.toString(node_id++), null, primary, ShardRoutingState.RELOCATING, 1);
|
||||
default:
|
||||
throw new ElasticsearchException("Unknown state: " + state.name());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private IndexShardRoutingTable genShardRoutingTable(String index, int shardId, int replicas, ShardCounter counter) {
|
||||
IndexShardRoutingTable.Builder builder = new IndexShardRoutingTable.Builder(new ShardId(index, shardId));
|
||||
ShardRouting shardRouting = genShardRouting(index, shardId, true);
|
||||
counter.update(shardRouting);
|
||||
builder.addShard(shardRouting);
|
||||
for (; replicas > 0; replicas--) {
|
||||
shardRouting = genShardRouting(index, shardId, false);
|
||||
counter.update(shardRouting);
|
||||
builder.addShard(shardRouting);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
IndexRoutingTable genIndexRoutingTable(IndexMetaData indexMetaData, ShardCounter counter) {
|
||||
IndexRoutingTable.Builder builder = IndexRoutingTable.builder(indexMetaData.getIndex());
|
||||
for (int shard = 0; shard < indexMetaData.getNumberOfShards(); shard++) {
|
||||
builder.addIndexShard(genShardRoutingTable(indexMetaData.getIndex(), shard, indexMetaData.getNumberOfReplicas(), counter));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public void testClusterIndexHealth() {
|
||||
int numberOfShards = randomInt(3) + 1;
|
||||
int numberOfReplicas = randomInt(4);
|
||||
IndexMetaData indexMetaData = IndexMetaData.builder("test1").settings(settings(Version.CURRENT)).numberOfShards(numberOfShards).numberOfReplicas(numberOfReplicas).build();
|
||||
ShardCounter counter = new ShardCounter();
|
||||
IndexRoutingTable indexRoutingTable = genIndexRoutingTable(indexMetaData, counter);
|
||||
|
||||
ClusterIndexHealth indexHealth = new ClusterIndexHealth(indexMetaData, indexRoutingTable);
|
||||
logger.info("index status: {}, expected {}", indexHealth.getStatus(), counter.status());
|
||||
assertIndexHealth(indexHealth, counter, indexMetaData);
|
||||
}
|
||||
|
||||
private void assertClusterHealth(ClusterHealthResponse clusterHealth, ShardCounter counter) {
|
||||
assertThat(clusterHealth.getStatus(), equalTo(counter.status()));
|
||||
assertThat(clusterHealth.getActiveShards(), equalTo(counter.active));
|
||||
assertThat(clusterHealth.getActivePrimaryShards(), equalTo(counter.primaryActive));
|
||||
assertThat(clusterHealth.getInitializingShards(), equalTo(counter.initializing));
|
||||
assertThat(clusterHealth.getRelocatingShards(), equalTo(counter.relocating));
|
||||
assertThat(clusterHealth.getUnassignedShards(), equalTo(counter.unassigned));
|
||||
assertThat(clusterHealth.getValidationFailures(), empty());
|
||||
}
|
||||
|
||||
public void testIsTimeout() throws IOException {
|
||||
ClusterHealthResponse res = new ClusterHealthResponse();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
res.timedOut = randomBoolean();
|
||||
res.setTimedOut(randomBoolean());
|
||||
if (res.isTimedOut()) {
|
||||
assertEquals(RestStatus.REQUEST_TIMEOUT, res.status());
|
||||
} else {
|
||||
@ -199,26 +50,14 @@ public class ClusterHealthResponsesTests extends ESTestCase {
|
||||
}
|
||||
|
||||
public void testClusterHealth() throws IOException {
|
||||
ShardCounter counter = new ShardCounter();
|
||||
RoutingTable.Builder routingTable = RoutingTable.builder();
|
||||
MetaData.Builder metaData = MetaData.builder();
|
||||
for (int i = randomInt(4); i >= 0; i--) {
|
||||
int numberOfShards = randomInt(3) + 1;
|
||||
int numberOfReplicas = randomInt(4);
|
||||
IndexMetaData indexMetaData = IndexMetaData.builder("test_" + Integer.toString(i)).settings(settings(Version.CURRENT)).numberOfShards(numberOfShards).numberOfReplicas(numberOfReplicas).build();
|
||||
IndexRoutingTable indexRoutingTable = genIndexRoutingTable(indexMetaData, counter);
|
||||
metaData.put(indexMetaData, true);
|
||||
routingTable.add(indexRoutingTable);
|
||||
}
|
||||
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable.build()).build();
|
||||
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).build();
|
||||
int pendingTasks = randomIntBetween(0, 200);
|
||||
int inFlight = randomIntBetween(0, 200);
|
||||
int delayedUnassigned = randomIntBetween(0, 200);
|
||||
TimeValue pendingTaskInQueueTime = TimeValue.timeValueMillis(randomIntBetween(1000, 100000));
|
||||
ClusterHealthResponse clusterHealth = new ClusterHealthResponse("bla", indexNameExpressionResolver.concreteIndices(clusterState, IndicesOptions.strictExpand(), (String[]) null), clusterState, pendingTasks, inFlight, delayedUnassigned, pendingTaskInQueueTime);
|
||||
logger.info("cluster status: {}, expected {}", clusterHealth.getStatus(), counter.status());
|
||||
ClusterHealthResponse clusterHealth = new ClusterHealthResponse("bla", new String[] {MetaData.ALL}, clusterState, pendingTasks, inFlight, delayedUnassigned, pendingTaskInQueueTime);
|
||||
clusterHealth = maybeSerialize(clusterHealth);
|
||||
assertClusterHealth(clusterHealth, counter);
|
||||
assertClusterHealth(clusterHealth);
|
||||
assertThat(clusterHealth.getNumberOfPendingTasks(), Matchers.equalTo(pendingTasks));
|
||||
assertThat(clusterHealth.getNumberOfInFlightFetch(), Matchers.equalTo(inFlight));
|
||||
assertThat(clusterHealth.getDelayedUnassignedShards(), Matchers.equalTo(delayedUnassigned));
|
||||
@ -226,6 +65,19 @@ public class ClusterHealthResponsesTests extends ESTestCase {
|
||||
assertThat(clusterHealth.getActiveShardsPercent(), is(allOf(greaterThanOrEqualTo(0.0), lessThanOrEqualTo(100.0))));
|
||||
}
|
||||
|
||||
private void assertClusterHealth(ClusterHealthResponse clusterHealth) {
|
||||
ClusterStateHealth clusterStateHealth = clusterHealth.getClusterStateHealth();
|
||||
|
||||
assertThat(clusterHealth.getValidationFailures(), Matchers.equalTo(clusterStateHealth.getValidationFailures()));
|
||||
assertThat(clusterHealth.getActiveShards(), Matchers.equalTo(clusterStateHealth.getActiveShards()));
|
||||
assertThat(clusterHealth.getRelocatingShards(), Matchers.equalTo(clusterStateHealth.getRelocatingShards()));
|
||||
assertThat(clusterHealth.getActivePrimaryShards(), Matchers.equalTo(clusterStateHealth.getActivePrimaryShards()));
|
||||
assertThat(clusterHealth.getInitializingShards(), Matchers.equalTo(clusterStateHealth.getInitializingShards()));
|
||||
assertThat(clusterHealth.getUnassignedShards(), Matchers.equalTo(clusterStateHealth.getUnassignedShards()));
|
||||
assertThat(clusterHealth.getNumberOfNodes(), Matchers.equalTo(clusterStateHealth.getNumberOfNodes()));
|
||||
assertThat(clusterHealth.getNumberOfDataNodes(), Matchers.equalTo(clusterStateHealth.getNumberOfDataNodes()));
|
||||
}
|
||||
|
||||
ClusterHealthResponse maybeSerialize(ClusterHealthResponse clusterHealth) throws IOException {
|
||||
if (randomBoolean()) {
|
||||
BytesStreamOutput out = new BytesStreamOutput();
|
||||
@ -235,24 +87,4 @@ public class ClusterHealthResponsesTests extends ESTestCase {
|
||||
}
|
||||
return clusterHealth;
|
||||
}
|
||||
|
||||
public void testValidations() throws IOException {
|
||||
IndexMetaData indexMetaData = IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(2).numberOfReplicas(2).build();
|
||||
ShardCounter counter = new ShardCounter();
|
||||
IndexRoutingTable indexRoutingTable = genIndexRoutingTable(indexMetaData, counter);
|
||||
indexMetaData = IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(2).numberOfReplicas(3).build();
|
||||
|
||||
ClusterIndexHealth indexHealth = new ClusterIndexHealth(indexMetaData, indexRoutingTable);
|
||||
assertThat(indexHealth.getValidationFailures(), Matchers.hasSize(2));
|
||||
|
||||
RoutingTable.Builder routingTable = RoutingTable.builder();
|
||||
MetaData.Builder metaData = MetaData.builder();
|
||||
metaData.put(indexMetaData, true);
|
||||
routingTable.add(indexRoutingTable);
|
||||
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable.build()).build();
|
||||
ClusterHealthResponse clusterHealth = new ClusterHealthResponse("bla", indexNameExpressionResolver.concreteIndices(clusterState, IndicesOptions.strictExpand(), (String[]) null), clusterState, 0, 0, 0, TimeValue.timeValueMillis(0));
|
||||
clusterHealth = maybeSerialize(clusterHealth);
|
||||
// currently we have no cluster level validation failures as index validation issues are reported per index.
|
||||
assertThat(clusterHealth.getValidationFailures(), Matchers.hasSize(0));
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.action.admin.cluster.stats;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.client.Requests;
|
||||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -77,7 +77,7 @@ public class ClusterAllocationRerouteBenchmark {
|
||||
logger.info("[{}] remaining unassigned {}", i, clusterState.getRoutingNodes().unassigned().size());
|
||||
RoutingAllocation.Result result = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING));
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(result).build();
|
||||
result = strategy.reroute(clusterState);
|
||||
result = strategy.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(result).build();
|
||||
}
|
||||
logger.info("[{}] took {}", i, TimeValue.timeValueMillis(System.currentTimeMillis() - runStart));
|
||||
|
@ -19,7 +19,7 @@
|
||||
package org.elasticsearch.benchmark.percolator;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.percolate.PercolateResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.StopWatch;
|
||||
@ -29,7 +29,6 @@ import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.percolator.PercolatorService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.elasticsearch.client.Requests.createIndexRequest;
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
|
||||
|
@ -24,7 +24,7 @@ import org.apache.lucene.index.Fields;
|
||||
import org.apache.lucene.util.English;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.indices.alias.Alias;
|
||||
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse;
|
||||
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
|
||||
@ -40,7 +40,6 @@ import org.elasticsearch.action.get.MultiGetResponse;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.termvectors.TermVectorsResponse;
|
||||
import org.elasticsearch.action.update.UpdateRequestBuilder;
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.cluster;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.cluster.allocation;
|
||||
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch.cluster.health;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
|
||||
public class ClusterIndexHealthTests extends ESTestCase {
|
||||
public void testClusterIndexHealth() {
|
||||
RoutingTableGenerator routingTableGenerator = new RoutingTableGenerator();
|
||||
int numberOfShards = randomInt(3) + 1;
|
||||
int numberOfReplicas = randomInt(4);
|
||||
IndexMetaData indexMetaData = IndexMetaData.builder("test1").settings(settings(Version.CURRENT)).numberOfShards(numberOfShards).numberOfReplicas(numberOfReplicas).build();
|
||||
RoutingTableGenerator.ShardCounter counter = new RoutingTableGenerator.ShardCounter();
|
||||
IndexRoutingTable indexRoutingTable = routingTableGenerator.genIndexRoutingTable(indexMetaData, counter);
|
||||
|
||||
ClusterIndexHealth indexHealth = new ClusterIndexHealth(indexMetaData, indexRoutingTable);
|
||||
logger.info("index status: {}, expected {}", indexHealth.getStatus(), counter.status());
|
||||
assertIndexHealth(indexHealth, counter, indexMetaData);
|
||||
}
|
||||
|
||||
|
||||
private void assertIndexHealth(ClusterIndexHealth indexHealth, RoutingTableGenerator.ShardCounter counter, IndexMetaData indexMetaData) {
|
||||
assertThat(indexHealth.getStatus(), equalTo(counter.status()));
|
||||
assertThat(indexHealth.getNumberOfShards(), equalTo(indexMetaData.getNumberOfShards()));
|
||||
assertThat(indexHealth.getNumberOfReplicas(), equalTo(indexMetaData.getNumberOfReplicas()));
|
||||
assertThat(indexHealth.getActiveShards(), equalTo(counter.active));
|
||||
assertThat(indexHealth.getRelocatingShards(), equalTo(counter.relocating));
|
||||
assertThat(indexHealth.getInitializingShards(), equalTo(counter.initializing));
|
||||
assertThat(indexHealth.getUnassignedShards(), equalTo(counter.unassigned));
|
||||
assertThat(indexHealth.getShards().size(), equalTo(indexMetaData.getNumberOfShards()));
|
||||
assertThat(indexHealth.getValidationFailures(), empty());
|
||||
int totalShards = 0;
|
||||
for (ClusterShardHealth shardHealth : indexHealth.getShards().values()) {
|
||||
totalShards += shardHealth.getActiveShards() + shardHealth.getInitializingShards() + shardHealth.getUnassignedShards();
|
||||
}
|
||||
|
||||
assertThat(totalShards, equalTo(indexMetaData.getNumberOfShards() * (1 + indexMetaData.getNumberOfReplicas())));
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch.cluster.health;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.hamcrest.Matchers;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.allOf;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
public class ClusterStateHealthTests extends ESTestCase {
|
||||
private final IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(Settings.EMPTY);
|
||||
|
||||
public void testClusterHealth() throws IOException {
|
||||
RoutingTableGenerator routingTableGenerator = new RoutingTableGenerator();
|
||||
RoutingTableGenerator.ShardCounter counter = new RoutingTableGenerator.ShardCounter();
|
||||
RoutingTable.Builder routingTable = RoutingTable.builder();
|
||||
MetaData.Builder metaData = MetaData.builder();
|
||||
for (int i = randomInt(4); i >= 0; i--) {
|
||||
int numberOfShards = randomInt(3) + 1;
|
||||
int numberOfReplicas = randomInt(4);
|
||||
IndexMetaData indexMetaData = IndexMetaData
|
||||
.builder("test_" + Integer.toString(i))
|
||||
.settings(settings(Version.CURRENT))
|
||||
.numberOfShards(numberOfShards)
|
||||
.numberOfReplicas(numberOfReplicas)
|
||||
.build();
|
||||
IndexRoutingTable indexRoutingTable = routingTableGenerator.genIndexRoutingTable(indexMetaData, counter);
|
||||
metaData.put(indexMetaData, true);
|
||||
routingTable.add(indexRoutingTable);
|
||||
}
|
||||
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable.build()).build();
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, IndicesOptions.strictExpand(), (String[]) null);
|
||||
ClusterStateHealth clusterStateHealth = new ClusterStateHealth(clusterState, concreteIndices);
|
||||
logger.info("cluster status: {}, expected {}", clusterStateHealth.getStatus(), counter.status());
|
||||
clusterStateHealth = maybeSerialize(clusterStateHealth);
|
||||
assertClusterHealth(clusterStateHealth, counter);
|
||||
}
|
||||
|
||||
public void testValidations() throws IOException {
|
||||
RoutingTableGenerator routingTableGenerator = new RoutingTableGenerator();
|
||||
IndexMetaData indexMetaData = IndexMetaData
|
||||
.builder("test")
|
||||
.settings(settings(Version.CURRENT))
|
||||
.numberOfShards(2)
|
||||
.numberOfReplicas(2)
|
||||
.build();
|
||||
RoutingTableGenerator.ShardCounter counter = new RoutingTableGenerator.ShardCounter();
|
||||
IndexRoutingTable indexRoutingTable = routingTableGenerator.genIndexRoutingTable(indexMetaData, counter);
|
||||
indexMetaData = IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(2).numberOfReplicas(3).build();
|
||||
|
||||
ClusterIndexHealth indexHealth = new ClusterIndexHealth(indexMetaData, indexRoutingTable);
|
||||
assertThat(indexHealth.getValidationFailures(), Matchers.hasSize(2));
|
||||
|
||||
RoutingTable.Builder routingTable = RoutingTable.builder();
|
||||
MetaData.Builder metaData = MetaData.builder();
|
||||
metaData.put(indexMetaData, true);
|
||||
routingTable.add(indexRoutingTable);
|
||||
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable.build()).build();
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, IndicesOptions.strictExpand(), (String[]) null);
|
||||
ClusterStateHealth clusterStateHealth = new ClusterStateHealth(clusterState, concreteIndices);
|
||||
clusterStateHealth = maybeSerialize(clusterStateHealth);
|
||||
// currently we have no cluster level validation failures as index validation issues are reported per index.
|
||||
assertThat(clusterStateHealth.getValidationFailures(), Matchers.hasSize(0));
|
||||
}
|
||||
|
||||
|
||||
ClusterStateHealth maybeSerialize(ClusterStateHealth clusterStateHealth) throws IOException {
|
||||
if (randomBoolean()) {
|
||||
BytesStreamOutput out = new BytesStreamOutput();
|
||||
clusterStateHealth.writeTo(out);
|
||||
StreamInput in = StreamInput.wrap(out.bytes());
|
||||
clusterStateHealth = ClusterStateHealth.readClusterHealth(in);
|
||||
}
|
||||
return clusterStateHealth;
|
||||
}
|
||||
|
||||
private void assertClusterHealth(ClusterStateHealth clusterStateHealth, RoutingTableGenerator.ShardCounter counter) {
|
||||
assertThat(clusterStateHealth.getStatus(), equalTo(counter.status()));
|
||||
assertThat(clusterStateHealth.getActiveShards(), equalTo(counter.active));
|
||||
assertThat(clusterStateHealth.getActivePrimaryShards(), equalTo(counter.primaryActive));
|
||||
assertThat(clusterStateHealth.getInitializingShards(), equalTo(counter.initializing));
|
||||
assertThat(clusterStateHealth.getRelocatingShards(), equalTo(counter.relocating));
|
||||
assertThat(clusterStateHealth.getUnassignedShards(), equalTo(counter.unassigned));
|
||||
assertThat(clusterStateHealth.getValidationFailures(), empty());
|
||||
assertThat(clusterStateHealth.getActiveShardsPercent(), is(allOf(greaterThanOrEqualTo(0.0), lessThanOrEqualTo(100.0))));
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch.cluster.health;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.RandomizedContext;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.routing.*;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
||||
class RoutingTableGenerator {
|
||||
private static int node_id = 1;
|
||||
|
||||
private ShardRouting genShardRouting(String index, int shardId, boolean primary) {
|
||||
|
||||
ShardRoutingState state;
|
||||
|
||||
int stateRandomizer = RandomizedContext.current().getRandom().nextInt(40);
|
||||
if (stateRandomizer > 5) {
|
||||
state = ShardRoutingState.STARTED;
|
||||
} else if (stateRandomizer > 3) {
|
||||
state = ShardRoutingState.RELOCATING;
|
||||
} else {
|
||||
state = ShardRoutingState.INITIALIZING;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case STARTED:
|
||||
return TestShardRouting.newShardRouting(index, shardId, "node_" + Integer.toString(node_id++), null, null, primary, ShardRoutingState.STARTED, 1);
|
||||
case INITIALIZING:
|
||||
return TestShardRouting.newShardRouting(index, shardId, "node_" + Integer.toString(node_id++), null, null, primary, ShardRoutingState.INITIALIZING, 1);
|
||||
case RELOCATING:
|
||||
return TestShardRouting.newShardRouting(index, shardId, "node_" + Integer.toString(node_id++), "node_" + Integer.toString(node_id++), null, primary, ShardRoutingState.RELOCATING, 1);
|
||||
default:
|
||||
throw new ElasticsearchException("Unknown state: " + state.name());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IndexShardRoutingTable genShardRoutingTable(String index, int shardId, int replicas, ShardCounter counter) {
|
||||
IndexShardRoutingTable.Builder builder = new IndexShardRoutingTable.Builder(new ShardId(index, shardId));
|
||||
ShardRouting shardRouting = genShardRouting(index, shardId, true);
|
||||
counter.update(shardRouting);
|
||||
builder.addShard(shardRouting);
|
||||
for (; replicas > 0; replicas--) {
|
||||
shardRouting = genShardRouting(index, shardId, false);
|
||||
counter.update(shardRouting);
|
||||
builder.addShard(shardRouting);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public IndexRoutingTable genIndexRoutingTable(IndexMetaData indexMetaData, ShardCounter counter) {
|
||||
IndexRoutingTable.Builder builder = IndexRoutingTable.builder(indexMetaData.getIndex());
|
||||
for (int shard = 0; shard < indexMetaData.getNumberOfShards(); shard++) {
|
||||
builder.addIndexShard(genShardRoutingTable(indexMetaData.getIndex(), shard, indexMetaData.getNumberOfReplicas(), counter));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
static class ShardCounter {
|
||||
public int active;
|
||||
public int relocating;
|
||||
public int initializing;
|
||||
public int unassigned;
|
||||
public int primaryActive;
|
||||
public int primaryInactive;
|
||||
|
||||
public ClusterHealthStatus status() {
|
||||
if (primaryInactive > 0) {
|
||||
return ClusterHealthStatus.RED;
|
||||
}
|
||||
if (unassigned > 0 || initializing > 0) {
|
||||
return ClusterHealthStatus.YELLOW;
|
||||
}
|
||||
return ClusterHealthStatus.GREEN;
|
||||
}
|
||||
|
||||
public void update(ShardRouting shardRouting) {
|
||||
if (shardRouting.active()) {
|
||||
active++;
|
||||
if (shardRouting.primary()) {
|
||||
primaryActive++;
|
||||
}
|
||||
if (shardRouting.relocating()) {
|
||||
relocating++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (shardRouting.primary()) {
|
||||
primaryInactive++;
|
||||
}
|
||||
if (shardRouting.initializing()) {
|
||||
initializing++;
|
||||
} else {
|
||||
unassigned++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -86,7 +86,7 @@ public class RoutingServiceTests extends ESAllocationTestCase {
|
||||
.metaData(metaData)
|
||||
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).localNodeId("node1").masterNodeId("node1")).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
// starting primaries
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING))).build();
|
||||
// starting replicas
|
||||
@ -95,7 +95,7 @@ public class RoutingServiceTests extends ESAllocationTestCase {
|
||||
// remove node2 and reroute
|
||||
ClusterState prevState = clusterState;
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node2")).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
ClusterState newState = clusterState;
|
||||
|
||||
assertThat(routingService.getRegisteredNextDelaySetting(), equalTo(Long.MAX_VALUE));
|
||||
@ -115,7 +115,7 @@ public class RoutingServiceTests extends ESAllocationTestCase {
|
||||
.metaData(metaData)
|
||||
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).localNodeId("node1").masterNodeId("node1")).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
// starting primaries
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING))).build();
|
||||
// starting replicas
|
||||
@ -135,7 +135,7 @@ public class RoutingServiceTests extends ESAllocationTestCase {
|
||||
|
||||
ClusterState prevState = clusterState;
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove(nodeId)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
// We need to update the routing service's last attempted run to
|
||||
// signal that the GatewayAllocator tried to allocated it but
|
||||
// it was delayed
|
||||
@ -175,7 +175,7 @@ public class RoutingServiceTests extends ESAllocationTestCase {
|
||||
.put(newNode("node0", singletonMap("data", Boolean.FALSE.toString()))).localNodeId("node0").masterNodeId("node0")
|
||||
.put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build();
|
||||
// allocate shards
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
// start primaries
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING))).build();
|
||||
// start replicas
|
||||
@ -207,7 +207,7 @@ public class RoutingServiceTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove(shortDelayReplica.currentNodeId()).remove(longDelayReplica.currentNodeId())).build();
|
||||
// make sure both replicas are marked as delayed (i.e. not reallocated)
|
||||
mockGatewayAllocator.setShardsToDelay(Arrays.asList(shortDelayReplica, longDelayReplica));
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
|
||||
// check that shortDelayReplica and longDelayReplica have been marked unassigned
|
||||
RoutingNodes.UnassignedShards unassigned = clusterState.getRoutingNodes().unassigned();
|
||||
@ -260,7 +260,7 @@ public class RoutingServiceTests extends ESAllocationTestCase {
|
||||
.metaData(metaData)
|
||||
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).localNodeId("node1").masterNodeId("node1")).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
// starting primaries
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING))).build();
|
||||
// starting replicas
|
||||
@ -269,7 +269,7 @@ public class RoutingServiceTests extends ESAllocationTestCase {
|
||||
// remove node2 and reroute
|
||||
ClusterState prevState = clusterState;
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node2")).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
// Set it in the future so the delay will be negative
|
||||
routingService.setUnassignedShardsAllocatedTimestamp(System.currentTimeMillis() + TimeValue.timeValueMinutes(1).millis());
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class RoutingTableTests extends ESAllocationTestCase {
|
||||
discoBuilder = discoBuilder.put(newNode("node" + i));
|
||||
}
|
||||
this.clusterState = ClusterState.builder(clusterState).nodes(discoBuilder).build();
|
||||
RoutingAllocation.Result rerouteResult = ALLOCATION_SERVICE.reroute(clusterState);
|
||||
RoutingAllocation.Result rerouteResult = ALLOCATION_SERVICE.reroute(clusterState, "reroute");
|
||||
this.testRoutingTable = rerouteResult.routingTable();
|
||||
assertThat(rerouteResult.changed(), is(true));
|
||||
this.clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
@ -167,7 +167,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
|
||||
.metaData(metaData)
|
||||
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
// starting primaries
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING))).build();
|
||||
IndexRoutingTable.Builder builder = IndexRoutingTable.builder("test");
|
||||
@ -208,7 +208,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
|
||||
.metaData(metaData)
|
||||
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
// starting primaries
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING))).build();
|
||||
// starting replicas
|
||||
@ -216,7 +216,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().unassigned().size() > 0, equalTo(false));
|
||||
// remove node2 and reroute
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node2")).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
// verify that NODE_LEAVE is the reason for meta
|
||||
assertThat(clusterState.getRoutingNodes().unassigned().size() > 0, equalTo(true));
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(1));
|
||||
@ -237,7 +237,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
|
||||
.metaData(metaData)
|
||||
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
// starting primaries
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING))).build();
|
||||
// starting replicas
|
||||
@ -298,7 +298,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
|
||||
.metaData(metaData)
|
||||
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test1")).addAsNew(metaData.index("test2")).build()).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
assertThat(UnassignedInfo.getNumberOfDelayedUnassigned(System.currentTimeMillis(),
|
||||
Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING, "10h").build(), clusterState), equalTo(0));
|
||||
// starting primaries
|
||||
@ -308,7 +308,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().unassigned().size() > 0, equalTo(false));
|
||||
// remove node2 and reroute
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node2")).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
assertThat(clusterState.prettyPrint(), UnassignedInfo.getNumberOfDelayedUnassigned(System.currentTimeMillis(),
|
||||
Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING, "10h").build(), clusterState), equalTo(2));
|
||||
}
|
||||
@ -323,7 +323,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
|
||||
.metaData(metaData)
|
||||
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test1")).addAsNew(metaData.index("test2")).build()).build();
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
assertThat(UnassignedInfo.getNumberOfDelayedUnassigned(System.currentTimeMillis(),
|
||||
Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING, "10h").build(), clusterState), equalTo(0));
|
||||
// starting primaries
|
||||
@ -333,7 +333,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().unassigned().size() > 0, equalTo(false));
|
||||
// remove node2 and reroute
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node2")).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState)).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingResult(allocation.reroute(clusterState, "reroute")).build();
|
||||
|
||||
long nextDelaySetting = UnassignedInfo.findSmallestDelayedAllocationSetting(Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING, "10h").build(), clusterState);
|
||||
assertThat(nextDelaySetting, equalTo(TimeValue.timeValueHours(10).millis()));
|
||||
|
@ -113,7 +113,7 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
|
||||
nodes.put(newNode("node2"));
|
||||
clusterState = ClusterState.builder(clusterState).nodes(nodes.build()).build();
|
||||
|
||||
RoutingTable routingTable = service.reroute(clusterState).routingTable();
|
||||
RoutingTable routingTable = service.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
RoutingNodes routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -182,7 +182,7 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
|
||||
nodes.put(newNode("node2"));
|
||||
clusterState = ClusterState.builder(clusterState).nodes(nodes.build()).build();
|
||||
|
||||
RoutingTable routingTable = service.reroute(clusterState).routingTable();
|
||||
RoutingTable routingTable = service.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
RoutingNodes routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -263,7 +263,7 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(nodes.build()).build();
|
||||
|
||||
RoutingTable routingTable = service.reroute(clusterState).routingTable();
|
||||
RoutingTable routingTable = service.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
RoutingNodes routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -308,7 +308,7 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
|
||||
nodes.put(newNode("node" + i));
|
||||
}
|
||||
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).nodes(nodes).metaData(metaData).routingTable(routingTable).build();
|
||||
routingTable = service.reroute(clusterState).routingTable();
|
||||
routingTable = service.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
RoutingNodes routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -353,7 +353,7 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
|
||||
MetaData metaData = metaDataBuilder.build();
|
||||
RoutingTable routingTable = routingTableBuilder.build();
|
||||
clusterState = ClusterState.builder(clusterState).metaData(metaData).routingTable(routingTable).build();
|
||||
routingTable = service.reroute(clusterState).routingTable();
|
||||
routingTable = service.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
RoutingNodes routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -411,7 +411,7 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
logger.info("rebalancing");
|
||||
routingTable = service.reroute(clusterState).routingTable();
|
||||
routingTable = service.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
logger.info("start primary shard");
|
||||
@ -118,7 +118,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3"))
|
||||
.put(newNode("node4", singletonMap("data", Boolean.FALSE.toString())))
|
||||
).build();
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(0));
|
||||
|
||||
@ -205,7 +205,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2"))
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(0));
|
||||
|
||||
|
@ -67,10 +67,10 @@ public class AllocationPriorityTests extends ESAllocationTestCase {
|
||||
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
routingTable = allocation.reroute(clusterState).routingTable();
|
||||
routingTable = allocation.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertEquals(2, clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size());
|
||||
assertEquals(highPriorityName, clusterState.getRoutingNodes().shardsWithState(INITIALIZING).get(0).index());
|
||||
|
@ -76,7 +76,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1", singletonMap("rack_id", "1")))
|
||||
.put(newNode("node2", singletonMap("rack_id", "1")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
|
||||
|
||||
@ -94,7 +94,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", singletonMap("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(1));
|
||||
@ -108,13 +108,13 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(2));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, make sure nothing moves");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", singletonMap("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(routingTable, sameInstance(clusterState.routingTable()));
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
|
||||
@ -145,7 +145,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2", singletonMap("rack_id", "1")))
|
||||
.put(newNode("node3", singletonMap("rack_id", "1")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
|
||||
|
||||
@ -163,7 +163,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", singletonMap("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(1));
|
||||
@ -177,13 +177,13 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(2));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, make sure nothing moves");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node5", singletonMap("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(routingTable, sameInstance(clusterState.routingTable()));
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
|
||||
@ -218,7 +218,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1", singletonMap("rack_id", "1")))
|
||||
.put(newNode("node2", singletonMap("rack_id", "1")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(INITIALIZING)) {
|
||||
@ -250,7 +250,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", singletonMap("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(5));
|
||||
@ -269,13 +269,13 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(10));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, some more relocation should happen");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", singletonMap("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(RELOCATING).size(), greaterThan(0));
|
||||
|
||||
@ -286,7 +286,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(10));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
}
|
||||
|
||||
public void testMoveShardOnceNewNodeWithAttributeAdded4() {
|
||||
@ -317,7 +317,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1", singletonMap("rack_id", "1")))
|
||||
.put(newNode("node2", singletonMap("rack_id", "1")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(10));
|
||||
|
||||
@ -335,7 +335,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", singletonMap("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(10));
|
||||
@ -358,13 +358,13 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(5));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, some more relocation should happen");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", singletonMap("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(RELOCATING).size(), greaterThan(0));
|
||||
|
||||
@ -381,7 +381,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(5));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
}
|
||||
|
||||
public void testMoveShardOnceNewNodeWithAttributeAdded5() {
|
||||
@ -408,7 +408,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1", singletonMap("rack_id", "1")))
|
||||
.put(newNode("node2", singletonMap("rack_id", "1")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
|
||||
|
||||
@ -426,7 +426,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", singletonMap("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(2));
|
||||
@ -440,13 +440,13 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(3));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, we will have another relocation");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", singletonMap("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.RELOCATING).size(), equalTo(1));
|
||||
@ -459,7 +459,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(3));
|
||||
|
||||
logger.info("--> make sure another reroute does not move things");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
}
|
||||
|
||||
public void testMoveShardOnceNewNodeWithAttributeAdded6() {
|
||||
@ -488,7 +488,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3", singletonMap("rack_id", "1")))
|
||||
.put(newNode("node4", singletonMap("rack_id", "1")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
|
||||
|
||||
@ -506,7 +506,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node5", singletonMap("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(3));
|
||||
@ -520,13 +520,13 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(4));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, we will have another relocation");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node6", singletonMap("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(3));
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.RELOCATING).size(), equalTo(1));
|
||||
@ -539,7 +539,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(4));
|
||||
|
||||
logger.info("--> make sure another reroute does not move things");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
}
|
||||
|
||||
public void testFullAwareness1() {
|
||||
@ -567,7 +567,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1", singletonMap("rack_id", "1")))
|
||||
.put(newNode("node2", singletonMap("rack_id", "1")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
|
||||
|
||||
@ -583,7 +583,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", singletonMap("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(1));
|
||||
@ -597,13 +597,13 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(2));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, make sure nothing moves");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", singletonMap("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(routingTable, sameInstance(clusterState.routingTable()));
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
|
||||
@ -635,7 +635,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2", singletonMap("rack_id", "1")))
|
||||
.put(newNode("node3", singletonMap("rack_id", "1")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
|
||||
|
||||
@ -651,7 +651,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", singletonMap("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(1));
|
||||
@ -665,13 +665,13 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(2));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, make sure nothing moves");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node5", singletonMap("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(routingTable, sameInstance(clusterState.routingTable()));
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
|
||||
@ -709,7 +709,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1", singletonMap("rack_id", "1")))
|
||||
.put(newNode("node2", singletonMap("rack_id", "1")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(10));
|
||||
|
||||
@ -723,7 +723,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3", singletonMap("rack_id", "2")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(10));
|
||||
@ -741,13 +741,13 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(20));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
|
||||
logger.info("--> add another node with a new rack, some more relocation should happen");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4", singletonMap("rack_id", "3")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(RELOCATING).size(), greaterThan(0));
|
||||
|
||||
@ -758,7 +758,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(20));
|
||||
|
||||
logger.info("--> do another reroute, make sure nothing moves");
|
||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||
assertThat(strategy.reroute(clusterState, "reroute").routingTable(), sameInstance(clusterState.routingTable()));
|
||||
}
|
||||
|
||||
public void testUnbalancedZones() {
|
||||
@ -788,7 +788,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("A-0", singletonMap("zone", "a")))
|
||||
.put(newNode("B-0", singletonMap("zone", "b")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(0));
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(5));
|
||||
@ -809,7 +809,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("A-1", singletonMap("zone", "a")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(8));
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(2));
|
||||
@ -853,7 +853,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("A-4", singletonMap("zone", "a")))
|
||||
.put(newNode("B-0", singletonMap("zone", "b")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(0));
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
|
||||
|
@ -132,7 +132,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
|
||||
nodes.put(newNode("node" + i));
|
||||
}
|
||||
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).nodes(nodes).metaData(metaData).routingTable(routingTable).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
RoutingNodes routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -168,7 +168,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node" + numberOfNodes)))
|
||||
.build();
|
||||
|
||||
RoutingTable routingTable = strategy.reroute(clusterState).routingTable();
|
||||
RoutingTable routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
RoutingNodes routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -209,7 +209,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
logger.info("rebalancing");
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -424,7 +424,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
|
||||
}
|
||||
|
||||
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).nodes(nodes).metaData(metaData).routingTable(routingTable).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
RoutingNodes routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -458,7 +458,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
|
||||
}
|
||||
|
||||
logger.info("rebalancing");
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class BalanceUnbalancedClusterTests extends CatAllocationTestCase {
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = ClusterState.builder(state).metaData(metaData).routingTable(routingTable).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
while (true) {
|
||||
if (routingTable.shardsWithState(INITIALIZING).isEmpty()) {
|
||||
|
@ -137,7 +137,7 @@ public abstract class CatAllocationTestCase extends ESAllocationTestCase {
|
||||
private ClusterState rebalance(ClusterState clusterState) {
|
||||
RoutingTable routingTable;AllocationService strategy = createAllocationService(settingsBuilder()
|
||||
.build());
|
||||
RoutingAllocation.Result reroute = strategy.reroute(clusterState);
|
||||
RoutingAllocation.Result reroute = strategy.reroute(clusterState, "reroute");
|
||||
routingTable = reroute.routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingTable = clusterState.routingTable();
|
||||
|
@ -64,7 +64,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test1").shards().size(); i++) {
|
||||
@ -122,7 +122,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -150,7 +150,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test1").shards().size(); i++) {
|
||||
@ -227,7 +227,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -254,7 +254,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test1").shards().size(); i++) {
|
||||
@ -312,7 +312,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -338,7 +338,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test1").shards().size(); i++) {
|
||||
@ -434,7 +434,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -461,7 +461,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test1").shards().size(); i++) {
|
||||
@ -519,7 +519,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -545,7 +545,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test1").shards().size(); i++) {
|
||||
@ -622,7 +622,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -664,7 +664,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test").shards().size(); i++) {
|
||||
@ -687,7 +687,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2")))
|
||||
.build();
|
||||
logger.debug("reroute and check that nothing has changed");
|
||||
RoutingAllocation.Result reroute = strategy.reroute(clusterState);
|
||||
RoutingAllocation.Result reroute = strategy.reroute(clusterState, "reroute");
|
||||
assertFalse(reroute.changed());
|
||||
routingTable = reroute.routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
@ -702,7 +702,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
}
|
||||
logger.debug("now set allocateTest1 to true and reroute we should see the [test1] index initializing");
|
||||
allocateTest1.set(true);
|
||||
reroute = strategy.reroute(clusterState);
|
||||
reroute = strategy.reroute(clusterState, "reroute");
|
||||
assertTrue(reroute.changed());
|
||||
routingTable = reroute.routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
@ -763,7 +763,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test").shards().size(); i++) {
|
||||
@ -786,7 +786,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2")))
|
||||
.build();
|
||||
logger.debug("reroute and check that nothing has changed");
|
||||
RoutingAllocation.Result reroute = strategy.reroute(clusterState);
|
||||
RoutingAllocation.Result reroute = strategy.reroute(clusterState, "reroute");
|
||||
assertFalse(reroute.changed());
|
||||
routingTable = reroute.routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
@ -801,7 +801,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
}
|
||||
logger.debug("now set hasFetches to true and reroute we should now see exactly one relocating shard");
|
||||
hasFetches.set(false);
|
||||
reroute = strategy.reroute(clusterState);
|
||||
reroute = strategy.reroute(clusterState, "reroute");
|
||||
assertTrue(reroute.changed());
|
||||
routingTable = reroute.routingTable();
|
||||
int numStarted = 0;
|
||||
|
@ -70,7 +70,7 @@ public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("start two nodes and fully start the shards");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test").shards().size(); i++) {
|
||||
@ -95,7 +95,7 @@ public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
|
||||
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();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
// starting primaries
|
||||
@ -87,7 +87,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode(nodeIdRemaining))
|
||||
).build();
|
||||
|
||||
rerouteResult = allocation.reroute(clusterState);
|
||||
rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().node(nodeIdRemaining).get(0).primary(), equalTo(true));
|
||||
@ -115,7 +115,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
// starting primaries
|
||||
@ -135,7 +135,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
rerouteResult = allocation.reroute(clusterState);
|
||||
rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
||||
@ -161,7 +161,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode(origPrimaryNodeId))
|
||||
.put(newNode(origReplicaNodeId))
|
||||
).build();
|
||||
rerouteResult = allocation.reroute(clusterState);
|
||||
rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().node(origPrimaryNodeId).get(0).state(), equalTo(STARTED));
|
||||
@ -189,7 +189,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
// starting primaries
|
||||
@ -209,7 +209,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
rerouteResult = allocation.reroute(clusterState);
|
||||
rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
||||
@ -235,7 +235,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3"))
|
||||
.put(newNode(origReplicaNodeId))
|
||||
).build();
|
||||
rerouteResult = allocation.reroute(clusterState);
|
||||
rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().node(origReplicaNodeId).get(0).state(), equalTo(STARTED));
|
||||
|
@ -60,7 +60,7 @@ public class ElectReplicaAsPrimaryDuringRelocationTests extends ESAllocationTest
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Start the primary shards");
|
||||
@ -84,7 +84,7 @@ public class ElectReplicaAsPrimaryDuringRelocationTests extends ESAllocationTest
|
||||
logger.info("Start another node and perform rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("find the replica shard that gets relocated");
|
||||
@ -100,7 +100,7 @@ public class ElectReplicaAsPrimaryDuringRelocationTests extends ESAllocationTest
|
||||
logger.info("kill the node [{}] of the primary shard for the relocating replica", indexShardRoutingTable.primaryShard().currentNodeId());
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove(indexShardRoutingTable.primaryShard().currentNodeId())).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("make sure all the primary shards are active");
|
||||
|
@ -82,7 +82,7 @@ public class ExpectedShardSizeAllocationTests extends ESAllocationTestCase {
|
||||
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build();
|
||||
logger.info("Adding one node and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertEquals(1, clusterState.getRoutingNodes().node("node1").numberOfShardsWithState(ShardRoutingState.INITIALIZING));
|
||||
@ -97,7 +97,7 @@ public class ExpectedShardSizeAllocationTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Add another one node and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertEquals(1, clusterState.getRoutingNodes().node("node2").numberOfShardsWithState(ShardRoutingState.INITIALIZING));
|
||||
@ -135,7 +135,7 @@ public class ExpectedShardSizeAllocationTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
logger.info("start primary shard");
|
||||
|
@ -59,7 +59,7 @@ public class FailedNodeRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("start 4 nodes");
|
||||
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();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("start all the primary shards, replicas will start initializing");
|
||||
@ -90,7 +90,7 @@ public class FailedNodeRoutingTests extends ESAllocationTestCase {
|
||||
)
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
// starting primaries
|
||||
@ -95,7 +95,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
rerouteResult = allocation.reroute(clusterState);
|
||||
rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
||||
@ -163,7 +163,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Start the shards (primaries)");
|
||||
@ -244,7 +244,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Adding single node and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -311,7 +311,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
|
||||
)
|
||||
.build();
|
||||
// and assign more unassigned
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(strategy.reroute(clusterState).routingTable()).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(strategy.reroute(clusterState, "reroute").routingTable()).build();
|
||||
}
|
||||
|
||||
int shardsToFail = randomIntBetween(1, numberOfReplicas);
|
||||
@ -356,7 +356,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
final String nodeHoldingPrimary = routingTable.index("test").shard(0).primaryShard().currentNodeId();
|
||||
|
||||
@ -416,7 +416,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Start the shards (primaries)");
|
||||
@ -458,7 +458,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Adding third node and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -506,7 +506,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
|
||||
|
||||
// add 4 nodes
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(allocation.reroute(clusterState).routingTable()).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(allocation.reroute(clusterState, "reroute").routingTable()).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(2));
|
||||
// start primary shards
|
||||
@ -552,7 +552,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
|
||||
|
||||
// add 4 nodes
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(allocation.reroute(clusterState).routingTable()).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(allocation.reroute(clusterState, "reroute").routingTable()).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(2));
|
||||
// start primary shards
|
||||
|
@ -71,7 +71,7 @@ public class FilterRoutingTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3", singletonMap("tag1", "value3")))
|
||||
.put(newNode("node4", singletonMap("tag1", "value4")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(2));
|
||||
|
||||
@ -119,7 +119,7 @@ public class FilterRoutingTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3", singletonMap("tag1", "value3")))
|
||||
.put(newNode("node4", singletonMap("tag1", "value4")))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(2));
|
||||
|
||||
@ -149,7 +149,7 @@ public class FilterRoutingTests extends ESAllocationTestCase {
|
||||
.build()))
|
||||
.build();
|
||||
clusterState = ClusterState.builder(clusterState).metaData(metaData).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(2));
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.RELOCATING).size(), equalTo(2));
|
||||
@ -185,7 +185,7 @@ public class FilterRoutingTests extends ESAllocationTestCase {
|
||||
DiscoveryNode node1 = newNode("node1", singletonMap("tag1", "value1"));
|
||||
DiscoveryNode node2 = newNode("node2", singletonMap("tag1", "value2"));
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(node1).put(node2)).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().node(node1.getId()).numberOfShardsWithState(INITIALIZING), equalTo(2));
|
||||
assertThat(clusterState.getRoutingNodes().node(node2.getId()).numberOfShardsWithState(INITIALIZING), equalTo(2));
|
||||
@ -204,7 +204,7 @@ public class FilterRoutingTests extends ESAllocationTestCase {
|
||||
.build());
|
||||
|
||||
logger.info("--> move shards from node1 to node2");
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
logger.info("--> check that concurrent rebalance only allows 1 shard to move");
|
||||
assertThat(clusterState.getRoutingNodes().node(node1.getId()).numberOfShardsWithState(STARTED), equalTo(1));
|
||||
@ -216,7 +216,7 @@ public class FilterRoutingTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("--> move second shard from node1 to node2");
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().node(node2.getId()).numberOfShardsWithState(INITIALIZING), equalTo(1));
|
||||
assertThat(clusterState.getRoutingNodes().node(node2.getId()).numberOfShardsWithState(STARTED), equalTo(3));
|
||||
@ -225,7 +225,7 @@ public class FilterRoutingTests extends ESAllocationTestCase {
|
||||
routingTable = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING)).routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().node(node2.getId()).numberOfShardsWithState(STARTED), equalTo(4));
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
.nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -102,7 +102,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
logger.info("Another round of rebalancing");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
@ -127,7 +127,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Reroute, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
|
||||
logger.info("Start the more shards");
|
||||
@ -214,7 +214,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -232,7 +232,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState)
|
||||
.nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
@ -258,7 +258,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Reroute, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
|
||||
logger.info("Start the backup shard");
|
||||
@ -296,14 +296,14 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState)
|
||||
.nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
|
||||
logger.info("Reroute, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
|
||||
logger.info("Start the backup shard");
|
||||
@ -366,7 +366,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
.nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -383,7 +383,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
logger.info("Another round of rebalancing");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
@ -408,7 +408,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Reroute, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
|
||||
logger.info("Start the more shards");
|
||||
@ -458,7 +458,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
assertThat(routingTable.index("test1").shards().size(), equalTo(3));
|
||||
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -475,7 +475,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
logger.info("Another round of rebalancing");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
@ -500,7 +500,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Reroute, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
|
||||
logger.info("Start the more shards");
|
||||
|
@ -88,7 +88,7 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
|
||||
logger.info("start two nodes and fully start the shards");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test").shards().size(); i++) {
|
||||
@ -129,7 +129,7 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3", VersionUtils.getPreviousVersion())))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -145,7 +145,7 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
|
||||
.put(newNode("node4")))
|
||||
.build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -288,7 +288,7 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
|
||||
private ClusterState stabilize(ClusterState clusterState, AllocationService service) {
|
||||
logger.trace("RoutingNodes: {}", clusterState.getRoutingNodes().prettyPrint());
|
||||
|
||||
RoutingTable routingTable = service.reroute(clusterState).routingTable();
|
||||
RoutingTable routingTable = service.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
RoutingNodes routingNodes = clusterState.getRoutingNodes();
|
||||
assertRecoveryNodeVersions(routingNodes);
|
||||
|
@ -69,7 +69,7 @@ public class PreferLocalPrimariesToRelocatingPrimariesTests extends ESAllocation
|
||||
.put(newNode("node1", singletonMap("tag1", "value1")))
|
||||
.put(newNode("node2", singletonMap("tag1", "value2")))).build();
|
||||
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
while (!clusterState.getRoutingNodes().shardsWithState(INITIALIZING).isEmpty()) {
|
||||
@ -92,7 +92,7 @@ public class PreferLocalPrimariesToRelocatingPrimariesTests extends ESAllocation
|
||||
.build()))
|
||||
.build();
|
||||
clusterState = ClusterState.builder(clusterState).metaData(metaData).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node1")).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("[{}] primaries should be still started but [{}] other primaries should be unassigned", numberOfShards, numberOfShards);
|
||||
@ -103,7 +103,7 @@ public class PreferLocalPrimariesToRelocatingPrimariesTests extends ESAllocation
|
||||
logger.info("start node back up");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node1", singletonMap("tag1", "value1")))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
while (clusterState.getRoutingNodes().shardsWithState(STARTED).size() < totalNumberOfShards) {
|
||||
|
@ -61,7 +61,7 @@ public class PreferPrimaryAllocationTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("adding two nodes and performing rerouting till all are allocated");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
while (!clusterState.getRoutingNodes().shardsWithState(INITIALIZING).isEmpty()) {
|
||||
@ -74,7 +74,7 @@ public class PreferPrimaryAllocationTests extends ESAllocationTestCase {
|
||||
metaData = MetaData.builder(clusterState.metaData()).updateNumberOfReplicas(1).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).metaData(metaData).build();
|
||||
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("2 replicas should be initializing now for the existing indices (we throttle to 1)");
|
||||
@ -92,7 +92,7 @@ public class PreferPrimaryAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
logger.info("reroute, verify that primaries for the new index primary shards are allocated");
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.routingTable().index("new_index").shardsWithState(INITIALIZING).size(), equalTo(2));
|
||||
|
@ -60,7 +60,7 @@ public class PrimaryElectionRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Start the primary shard (on node1)");
|
||||
@ -78,7 +78,7 @@ public class PrimaryElectionRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Adding third node and reroute and kill first node");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3")).remove("node1")).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -109,7 +109,7 @@ public class PrimaryElectionRoutingTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
|
||||
logger.info("Start the primary shards");
|
||||
@ -128,7 +128,7 @@ public class PrimaryElectionRoutingTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(newNode(nodeIdRemaining))
|
||||
).build();
|
||||
rerouteResult = allocation.reroute(clusterState);
|
||||
rerouteResult = allocation.reroute(clusterState, "reroute");
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class PrimaryNotRelocatedWhileBeingRecoveredTests extends ESAllocationTes
|
||||
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Start the primary shard (on node1)");
|
||||
@ -73,7 +73,7 @@ public class PrimaryNotRelocatedWhileBeingRecoveredTests extends ESAllocationTes
|
||||
|
||||
logger.info("start another node, replica will start recovering form primary");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(routingTable.shardsWithState(STARTED).size(), equalTo(5));
|
||||
@ -81,7 +81,7 @@ public class PrimaryNotRelocatedWhileBeingRecoveredTests extends ESAllocationTes
|
||||
|
||||
logger.info("start another node, make sure the primary is not relocated");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(routingTable.shardsWithState(STARTED).size(), equalTo(5));
|
||||
|
@ -105,7 +105,7 @@ public class RandomAllocationDeciderTests extends ESAllocationTestCase {
|
||||
|
||||
stateBuilder.nodes(newNodesBuilder.build());
|
||||
clusterState = stateBuilder.build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
if (clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size() > 0) {
|
||||
routingTable = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING))
|
||||
@ -131,7 +131,7 @@ public class RandomAllocationDeciderTests extends ESAllocationTestCase {
|
||||
int iterations = 0;
|
||||
do {
|
||||
iterations++;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
if (clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size() > 0) {
|
||||
routingTable = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING))
|
||||
|
@ -101,7 +101,7 @@ public class RebalanceAfterActiveTests extends ESAllocationTestCase {
|
||||
logger.info("start two nodes and fully start the shards");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test").shards().size(); i++) {
|
||||
@ -129,7 +129,7 @@ public class RebalanceAfterActiveTests extends ESAllocationTestCase {
|
||||
.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;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class ReplicaAllocatedAfterPrimaryTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
final String nodeHoldingPrimary = routingTable.index("test").shard(0).primaryShard().currentNodeId();
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
|
||||
assertThat(routingNodes.hasUnassignedPrimaries(), equalTo(true));
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -84,7 +84,7 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
|
||||
logger.info("Another round of rebalancing");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
@ -95,7 +95,7 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Reroute, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
|
||||
logger.info("Start the more shards");
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
@ -135,14 +135,14 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Add another node and perform rerouting, nothing will happen since primary not started");
|
||||
clusterState = ClusterState.builder(clusterState)
|
||||
.nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Start the primary shard");
|
||||
@ -153,7 +153,7 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Reroute, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
|
||||
logger.info("Start the backup shard");
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
@ -170,12 +170,12 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState)
|
||||
.nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Reroute, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
|
||||
logger.info("Start the backup shard");
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
@ -233,7 +233,7 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
|
||||
assertThat(routingNodes.hasUnassignedPrimaries(), equalTo(true));
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -245,7 +245,7 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
|
||||
logger.info("Another round of rebalancing");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
@ -270,7 +270,7 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Reroute, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
|
||||
logger.info("Start the more shards");
|
||||
@ -316,13 +316,13 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
|
||||
assertThat(routingTable.index("test1").shards().size(), equalTo(3));
|
||||
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Reroute, assign");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
@ -369,7 +369,7 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
|
||||
logger.info("kill one node");
|
||||
IndexShardRoutingTable indexShardRoutingTable = routingTable.index("test").shard(0);
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove(indexShardRoutingTable.primaryShard().currentNodeId())).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class SameShardRoutingTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
|
||||
.put(new DiscoveryNode("node1", "node1", "test1", "test1", DummyTransportAddress.INSTANCE, emptyMap(), Version.CURRENT))
|
||||
.put(new DiscoveryNode("node2", "node2", "test1", "test1", DummyTransportAddress.INSTANCE, emptyMap(), Version.CURRENT))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(numberOfShardsOfType(clusterState.getRoutingNodes(), ShardRoutingState.INITIALIZING), equalTo(2));
|
||||
@ -76,7 +76,7 @@ public class SameShardRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("--> add another node, with a different host, replicas will be allocating");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(new DiscoveryNode("node3", "node3", "test2", "test2", DummyTransportAddress.INSTANCE, emptyMap(), Version.CURRENT))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(numberOfShardsOfType(clusterState.getRoutingNodes(), ShardRoutingState.STARTED), equalTo(2));
|
||||
|
@ -58,7 +58,7 @@ public class ShardVersioningTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("start two nodes");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
for (int i = 0; i < routingTable.index("test1").shards().size(); i++) {
|
||||
|
@ -31,7 +31,6 @@ import org.elasticsearch.cluster.routing.ShardRoutingState;
|
||||
import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.ESAllocationTestCase;
|
||||
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
@ -65,7 +64,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
|
||||
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build();
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().node("node1").numberOfShardsWithState(ShardRoutingState.INITIALIZING), equalTo(2));
|
||||
@ -109,7 +108,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
|
||||
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build();
|
||||
logger.info("Adding two nodes and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().node("node1").numberOfShardsWithState(ShardRoutingState.INITIALIZING), equalTo(1));
|
||||
@ -131,7 +130,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
|
||||
.build());
|
||||
|
||||
logger.info("Do another reroute, make sure shards are now allocated");
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().node("node1").numberOfShardsWithState(ShardRoutingState.INITIALIZING), equalTo(1));
|
||||
@ -172,7 +171,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
|
||||
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build();
|
||||
logger.info("Adding one node and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Start the primary shards");
|
||||
@ -197,7 +196,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Add another one node and reroute");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
@ -226,7 +225,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).metaData(metaData).build();
|
||||
|
||||
logger.info("reroute after setting");
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(clusterState.getRoutingNodes().node("node1").numberOfShardsWithState(STARTED), equalTo(3));
|
||||
|
@ -82,7 +82,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Adding one node and performing rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(routingTable.index("test").shards().size(), equalTo(1));
|
||||
@ -94,7 +94,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Rerouting again, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
clusterState = ClusterState.builder(clusterState).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(routingTable == prevRoutingTable, equalTo(true));
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
@ -114,7 +114,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Starting another node and making sure nothing changed");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(routingTable == prevRoutingTable, equalTo(true));
|
||||
@ -128,7 +128,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node1")).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(routingTable != prevRoutingTable, equalTo(true));
|
||||
@ -141,7 +141,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Start another node, make sure that things remain the same (shard is in node2 and initializing)");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(routingTable == prevRoutingTable, equalTo(true));
|
||||
|
||||
@ -183,7 +183,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Adding one node and rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -248,7 +248,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
|
||||
}
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
clusterState = ClusterState.builder(clusterState).nodes(nodesBuilder).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -286,7 +286,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
|
||||
}
|
||||
prevRoutingTable = routingTable;
|
||||
clusterState = ClusterState.builder(clusterState).nodes(nodesBuilder).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(false));
|
||||
@ -351,7 +351,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
|
||||
.nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")))
|
||||
.build();
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -374,7 +374,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class SingleShardOneReplicaRoutingTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -86,7 +86,7 @@ public class SingleShardOneReplicaRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Add another node and perform rerouting, nothing will happen since primary shards not started");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
@ -111,7 +111,7 @@ public class SingleShardOneReplicaRoutingTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Reroute, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
|
||||
logger.info("Start the backup shard");
|
||||
@ -134,7 +134,7 @@ public class SingleShardOneReplicaRoutingTests extends ESAllocationTestCase {
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node1")).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -152,7 +152,7 @@ public class SingleShardOneReplicaRoutingTests extends ESAllocationTestCase {
|
||||
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
|
@ -83,7 +83,7 @@ public class TenShardsOneReplicaRoutingTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -101,7 +101,7 @@ public class TenShardsOneReplicaRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Add another node and perform rerouting, nothing will happen since primary not started");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
@ -127,7 +127,7 @@ public class TenShardsOneReplicaRoutingTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("Reroute, nothing should change");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
assertThat(prevRoutingTable == routingTable, equalTo(true));
|
||||
|
||||
logger.info("Start the backup shard");
|
||||
@ -154,7 +154,7 @@ public class TenShardsOneReplicaRoutingTests extends ESAllocationTestCase {
|
||||
logger.info("Add another node and perform rerouting");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
routingNodes = clusterState.getRoutingNodes();
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class ThrottlingAllocationTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("start one node, do reroute, only 3 should initialize");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(routingTable.shardsWithState(STARTED).size(), equalTo(0));
|
||||
@ -121,7 +121,7 @@ public class ThrottlingAllocationTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("start one node, do reroute, only 3 should initialize");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(routingTable.shardsWithState(STARTED).size(), equalTo(0));
|
||||
@ -146,7 +146,7 @@ public class ThrottlingAllocationTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("start another node, replicas should start being allocated");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node2"))).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(routingTable.shardsWithState(STARTED).size(), equalTo(5));
|
||||
|
@ -73,7 +73,7 @@ public class UpdateNumberOfReplicasTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
|
||||
RoutingTable prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logger.info("Start all the primary shards");
|
||||
@ -123,7 +123,7 @@ public class UpdateNumberOfReplicasTests extends ESAllocationTestCase {
|
||||
logger.info("Add another node and start the added replica");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).put(newNode("node3"))).build();
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(true));
|
||||
@ -172,7 +172,7 @@ public class UpdateNumberOfReplicasTests extends ESAllocationTestCase {
|
||||
|
||||
logger.info("do a reroute, should remain the same");
|
||||
prevRoutingTable = routingTable;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
assertThat(prevRoutingTable != routingTable, equalTo(false));
|
||||
|
@ -127,7 +127,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
logShardStates(clusterState);
|
||||
|
||||
@ -157,7 +157,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logShardStates(clusterState);
|
||||
@ -197,7 +197,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
||||
.build(), deciders, makeShardsAllocators(), cis);
|
||||
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
logShardStates(clusterState);
|
||||
|
||||
@ -228,7 +228,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
||||
.build(), deciders, makeShardsAllocators(), cis);
|
||||
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logShardStates(clusterState);
|
||||
@ -244,7 +244,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logShardStates(clusterState);
|
||||
@ -324,7 +324,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
logShardStates(clusterState);
|
||||
|
||||
@ -365,7 +365,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
||||
.build(), deciders, makeShardsAllocators(), cis);
|
||||
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
logShardStates(clusterState);
|
||||
|
||||
@ -392,7 +392,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logShardStates(clusterState);
|
||||
@ -432,7 +432,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
||||
.build(), deciders, makeShardsAllocators(), cis);
|
||||
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
logShardStates(clusterState);
|
||||
|
||||
@ -463,7 +463,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
||||
.build(), deciders, makeShardsAllocators(), cis);
|
||||
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logShardStates(clusterState);
|
||||
@ -479,7 +479,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node4"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logShardStates(clusterState);
|
||||
@ -506,7 +506,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.put(newNode("node5"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
logShardStates(clusterState);
|
||||
@ -586,7 +586,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2")) // node2 is added because DiskThresholdDecider automatically ignore single-node clusters
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
logger.info("--> start the shards (primaries)");
|
||||
routingTable = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING)).routingTable();
|
||||
@ -654,7 +654,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node3")) // node3 is added because DiskThresholdDecider automatically ignore single-node clusters
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
// Shard can be allocated to node1, even though it only has 25% free,
|
||||
@ -760,7 +760,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
logShardStates(clusterState);
|
||||
|
||||
@ -906,7 +906,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.build(), deciders, makeShardsAllocators(), cis);
|
||||
// Ensure that the reroute call doesn't alter the routing table, since the first primary is relocating away
|
||||
// and therefor we will have sufficient disk space on node1.
|
||||
RoutingAllocation.Result result = strategy.reroute(clusterState);
|
||||
RoutingAllocation.Result result = strategy.reroute(clusterState, "reroute");
|
||||
assertThat(result.changed(), is(false));
|
||||
assertThat(result.routingTable().index("test").getShards().get(0).primaryShard().state(), equalTo(STARTED));
|
||||
assertThat(result.routingTable().index("test").getShards().get(0).primaryShard().currentNodeId(), equalTo("node1"));
|
||||
@ -1004,7 +1004,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, "always")
|
||||
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
||||
.build(), deciders, makeShardsAllocators(), cis);
|
||||
RoutingAllocation.Result result = strategy.reroute(clusterState);
|
||||
RoutingAllocation.Result result = strategy.reroute(clusterState, "reroute");
|
||||
|
||||
assertThat(result.routingTable().index("test").getShards().get(0).primaryShard().state(), equalTo(STARTED));
|
||||
assertThat(result.routingTable().index("test").getShards().get(0).primaryShard().currentNodeId(), equalTo("node2"));
|
||||
@ -1039,7 +1039,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
||||
decision = diskThresholdDecider.canRemain(firstRouting, firstRoutingNode, routingAllocation);
|
||||
assertThat(decision.type(), equalTo(Decision.Type.YES));
|
||||
|
||||
result = strategy.reroute(clusterState);
|
||||
result = strategy.reroute(clusterState, "reroute");
|
||||
assertThat(result.routingTable().index("test").getShards().get(0).primaryShard().state(), equalTo(STARTED));
|
||||
assertThat(result.routingTable().index("test").getShards().get(0).primaryShard().currentNodeId(), equalTo("node2"));
|
||||
assertThat(result.routingTable().index("test").getShards().get(0).primaryShard().relocatingNodeId(), nullValue());
|
||||
|
@ -78,7 +78,7 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(0));
|
||||
|
||||
@ -106,7 +106,7 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
|
||||
|
||||
@ -140,7 +140,7 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
|
||||
logger.info("--> start the shards (primaries)");
|
||||
@ -184,7 +184,7 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(4));
|
||||
logger.info("--> start the shards (primaries)");
|
||||
@ -205,7 +205,7 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
ClusterState prevState = clusterState;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(8));
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(RELOCATING).size(), equalTo(0));
|
||||
@ -225,7 +225,7 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||
|
||||
}
|
||||
nodeSettingsService.clusterChanged(new ClusterChangedEvent("foo", clusterState, prevState));
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat("expected 6 shards to be started 2 to relocate useClusterSettings: " + useClusterSetting, clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(6));
|
||||
assertThat("expected 2 shards to relocate useClusterSettings: " + useClusterSetting, clusterState.getRoutingNodes().shardsWithState(RELOCATING).size(), equalTo(2));
|
||||
@ -284,7 +284,7 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node1"))
|
||||
.put(newNode("node2"))
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(6));
|
||||
logger.info("--> start the shards (primaries)");
|
||||
@ -300,7 +300,7 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3"))
|
||||
).build();
|
||||
ClusterState prevState = clusterState;
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(6));
|
||||
assertThat(clusterState.getRoutingNodes().shardsWithState(RELOCATING).size(), equalTo(0));
|
||||
@ -316,7 +316,7 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||
.put(IndexMetaData.builder(meta).settings(settingsBuilder().put(meta.getSettings()).put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE, randomBoolean() ? Rebalance.PRIMARIES : Rebalance.ALL).build()))).build();
|
||||
}
|
||||
nodeSettingsService.clusterChanged(new ClusterChangedEvent("foo", clusterState, prevState));
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
assertThat("expected 4 primaries to be started and 2 to relocate useClusterSettings: " + useClusterSetting, clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(4));
|
||||
assertThat("expected 2 primaries to relocate useClusterSettings: " + useClusterSetting, clusterState.getRoutingNodes().shardsWithState(RELOCATING).size(), equalTo(2));
|
||||
|
@ -51,7 +51,7 @@ public class ClusterSerializationTests extends ESAllocationTestCase {
|
||||
ClusterState clusterState = ClusterState.builder(new ClusterName("clusterName1")).nodes(nodes).metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
AllocationService strategy = createAllocationService();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(strategy.reroute(clusterState).routingTable()).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(strategy.reroute(clusterState, "reroute").routingTable()).build();
|
||||
|
||||
ClusterState serializedClusterState = ClusterState.Builder.fromBytes(ClusterState.Builder.toBytes(clusterState), newNode("node1"));
|
||||
|
||||
@ -74,7 +74,7 @@ public class ClusterSerializationTests extends ESAllocationTestCase {
|
||||
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).nodes(nodes).metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
AllocationService strategy = createAllocationService();
|
||||
RoutingTable source = strategy.reroute(clusterState).routingTable();
|
||||
RoutingTable source = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
|
||||
BytesStreamOutput outStream = new BytesStreamOutput();
|
||||
source.writeTo(outStream);
|
||||
|
@ -51,7 +51,7 @@ public class ClusterStateToStringTests extends ESAllocationTestCase {
|
||||
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).nodes(nodes).metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
AllocationService strategy = createAllocationService();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(strategy.reroute(clusterState).routingTable()).build();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(strategy.reroute(clusterState, "reroute").routingTable()).build();
|
||||
|
||||
String clusterStateString = clusterState.toString();
|
||||
assertNotNull(clusterStateString);
|
||||
|
@ -250,7 +250,7 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2", unmodifiableMap(node2Attributes)))
|
||||
.localNodeId("node1")
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
routingTable = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING)).routingTable();
|
||||
@ -299,7 +299,7 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
|
||||
.localNodeId("node1")
|
||||
).build();
|
||||
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
routingTable = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING)).routingTable();
|
||||
@ -354,7 +354,7 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
|
||||
.put(newNode("node2"))
|
||||
.localNodeId("node1")
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
routingTable = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING)).routingTable();
|
||||
@ -418,7 +418,7 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
|
||||
.put(newNode("node3"))
|
||||
.localNodeId("node1")
|
||||
).build();
|
||||
routingTable = strategy.reroute(clusterState).routingTable();
|
||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||
|
||||
routingTable = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING)).routingTable();
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.consistencylevel;
|
||||
import org.elasticsearch.action.UnavailableShardsException;
|
||||
import org.elasticsearch.action.WriteConsistencyLevel;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
@ -497,7 +497,7 @@ public class NodeJoinControllerTests extends ESTestCase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoutingAllocation.Result reroute(ClusterState clusterState, boolean debug) {
|
||||
protected RoutingAllocation.Result reroute(ClusterState clusterState, String reason, boolean debug) {
|
||||
return new RoutingAllocation.Result(false, clusterState.routingTable());
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.document;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse;
|
||||
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
|
||||
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
|
||||
|
@ -77,7 +77,7 @@ public class GatewayMetaStateTests extends ESAllocationTestCase {
|
||||
.nodes(generateDiscoveryNodes(masterEligible))
|
||||
.build();
|
||||
// new cluster state will have initializing shards on node 1
|
||||
RoutingTable routingTableNewClusterState = strategy.reroute(init).routingTable();
|
||||
RoutingTable routingTableNewClusterState = strategy.reroute(init, "reroute").routingTable();
|
||||
if (initializing == false) {
|
||||
// pretend all initialized, nothing happened
|
||||
ClusterState temp = ClusterState.builder(init).routingTable(routingTableNewClusterState).metaData(metaDataOldClusterState).build();
|
||||
@ -130,7 +130,7 @@ public class GatewayMetaStateTests extends ESAllocationTestCase {
|
||||
.routingTable(routingTableIndexCreated)
|
||||
.nodes(generateDiscoveryNodes(masterEligible))
|
||||
.build();
|
||||
RoutingTable routingTableInitializing = strategy.reroute(init).routingTable();
|
||||
RoutingTable routingTableInitializing = strategy.reroute(init, "reroute").routingTable();
|
||||
ClusterState temp = ClusterState.builder(init).routingTable(routingTableInitializing).build();
|
||||
RoutingTable routingTableStarted = strategy.applyStartedShards(temp, temp.getRoutingNodes().shardsWithState(INITIALIZING)).routingTable();
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.gateway;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.index.IndexAction;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
|
@ -23,7 +23,7 @@ import com.carrotsearch.randomizedtesting.generators.RandomPicks;
|
||||
import org.apache.lucene.index.CheckIndex;
|
||||
import org.apache.lucene.index.IndexFileNames;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
|
||||
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
|
||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.indexlifecycle;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.indices.settings;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.Priority;
|
||||
|
@ -135,7 +135,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
|
||||
routingTable.addAsRecovery(updatedState.metaData().index(index));
|
||||
updatedState = ClusterState.builder(updatedState).routingTable(routingTable.build()).build();
|
||||
|
||||
RoutingAllocation.Result result = allocationService.reroute(updatedState);
|
||||
RoutingAllocation.Result result = allocationService.reroute(updatedState, "reroute");
|
||||
return ClusterState.builder(updatedState).routingResult(result).build();
|
||||
|
||||
}
|
||||
@ -155,7 +155,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
|
||||
builder.nodes(DiscoveryNodes.builder(currentState.nodes()).remove("_non_existent"));
|
||||
|
||||
currentState = builder.build();
|
||||
RoutingAllocation.Result result = allocationService.reroute(currentState);
|
||||
RoutingAllocation.Result result = allocationService.reroute(currentState, "reroute");
|
||||
return ClusterState.builder(currentState).routingResult(result).build();
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.indices.state;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
||||
import org.elasticsearch.action.admin.indices.close.CloseIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.indices.store;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.search.basic;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.search.basic;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.WriteConsistencyLevel;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
||||
import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.search.innerhits;
|
||||
|
||||
import org.apache.lucene.util.ArrayUtil;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.search.morelikethis;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.search.nested;
|
||||
|
||||
import org.apache.lucene.search.Explanation;
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
|
||||
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
|
||||
import org.elasticsearch.action.delete.DeleteResponse;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.search.preference;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.transport.netty;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.component.Lifecycle;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -19,7 +19,7 @@
|
||||
package org.elasticsearch.transport.netty;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user