Disable allocation: New indices allocation not to be disabled by default
When setting cluster.routing.allocation.disable_allocation, it causes new indices primary shards to not be allocated. By default, new indices created should allow to, at the very least, allocate primary shards so they become operations. A new setting, cluster.routing.allocation.disable_new_allocation, allows to also disable "new" allocations. closes #2258.
This commit is contained in:
parent
90e0a70e0e
commit
7924115b90
|
@ -319,7 +319,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
|
|||
|
||||
if (request.state == State.OPEN) {
|
||||
RoutingTable.Builder routingTableBuilder = RoutingTable.builder().routingTable(updatedState.routingTable())
|
||||
.add(updatedState.metaData().index(request.index), true);
|
||||
.addAsNew(updatedState.metaData().index(request.index));
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(newClusterStateBuilder().state(updatedState).routingTable(routingTableBuilder).build());
|
||||
updatedState = newClusterStateBuilder().state(updatedState).routingResult(routingResult).build();
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ public class MetaDataStateIndexService extends AbstractComponent {
|
|||
ClusterState updatedState = ClusterState.builder().state(currentState).metaData(mdBuilder).blocks(blocks).build();
|
||||
|
||||
RoutingTable.Builder rtBuilder = RoutingTable.builder().routingTable(updatedState.routingTable())
|
||||
.add(updatedState.metaData().index(request.index), false);
|
||||
.addAsRecovery(updatedState.metaData().index(request.index));
|
||||
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(newClusterStateBuilder().state(updatedState).routingTable(rtBuilder).build());
|
||||
|
||||
|
|
|
@ -23,10 +23,12 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
import org.elasticsearch.ElasticSearchIllegalStateException;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
@ -270,18 +272,30 @@ public class IndexRoutingTable implements Iterable<IndexShardRoutingTable> {
|
|||
/**
|
||||
* Initializes a new empty index, as if it was created from an API.
|
||||
*/
|
||||
public Builder initializeEmpty(IndexMetaData indexMetaData) {
|
||||
public Builder initializeAsNew(IndexMetaData indexMetaData) {
|
||||
return initializeEmpty(indexMetaData, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new empty index, as if it was created from an API.
|
||||
*/
|
||||
public Builder initializeAsRecovery(IndexMetaData indexMetaData) {
|
||||
return initializeEmpty(indexMetaData, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new empty index, with an option to control if its from an API or not.
|
||||
*/
|
||||
public Builder initializeEmpty(IndexMetaData indexMetaData, boolean fromApi) {
|
||||
for (int shardId = 0; shardId < indexMetaData.numberOfShards(); shardId++) {
|
||||
for (int i = 0; i <= indexMetaData.numberOfReplicas(); i++) {
|
||||
addShard(shardId, null, i == 0, ShardRoutingState.UNASSIGNED, 0, fromApi);
|
||||
private Builder initializeEmpty(IndexMetaData indexMetaData, boolean asNew) {
|
||||
if (!shards.isEmpty()) {
|
||||
throw new ElasticSearchIllegalStateException("trying to initialize an index with fresh shards, but already has shards created");
|
||||
}
|
||||
for (int shardId = 0; shardId < indexMetaData.numberOfShards(); shardId++) {
|
||||
IndexShardRoutingTable.Builder indexShardRoutingBuilder = new IndexShardRoutingTable.Builder(new ShardId(indexMetaData.index(), shardId), asNew ? false : true);
|
||||
for (int i = 0; i <= indexMetaData.numberOfReplicas(); i++) {
|
||||
indexShardRoutingBuilder.addShard(new ImmutableShardRouting(index, shardId, null, i == 0, ShardRoutingState.UNASSIGNED, 0));
|
||||
}
|
||||
shards.put(shardId, indexShardRoutingBuilder.build());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -289,7 +303,10 @@ public class IndexRoutingTable implements Iterable<IndexShardRoutingTable> {
|
|||
public Builder addReplica() {
|
||||
for (int shardId : shards.keySet()) {
|
||||
// version 0, will get updated when reroute will happen
|
||||
addShard(shardId, null, false, ShardRoutingState.UNASSIGNED, 0, false);
|
||||
ImmutableShardRouting shard = new ImmutableShardRouting(index, shardId, null, false, ShardRoutingState.UNASSIGNED, 0);
|
||||
shards.put(shardId,
|
||||
new IndexShardRoutingTable.Builder(shards.get(shard.id())).addShard(shard).build()
|
||||
);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -302,7 +319,7 @@ public class IndexRoutingTable implements Iterable<IndexShardRoutingTable> {
|
|||
return this;
|
||||
}
|
||||
// re-add all the current ones
|
||||
IndexShardRoutingTable.Builder builder = new IndexShardRoutingTable.Builder(indexShard.shardId(), indexShard.allocatedPostApi());
|
||||
IndexShardRoutingTable.Builder builder = new IndexShardRoutingTable.Builder(indexShard.shardId(), indexShard.primaryAllocatedPostApi());
|
||||
for (ShardRouting shardRouting : indexShard) {
|
||||
builder.addShard(new ImmutableShardRouting(shardRouting));
|
||||
}
|
||||
|
@ -334,21 +351,16 @@ public class IndexRoutingTable implements Iterable<IndexShardRoutingTable> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder addShard(ShardRouting shard, boolean fromApi) {
|
||||
return internalAddShard(new ImmutableShardRouting(shard), fromApi);
|
||||
}
|
||||
|
||||
private Builder addShard(int shardId, String nodeId, boolean primary, ShardRoutingState state, long version, boolean fromApi) {
|
||||
ImmutableShardRouting shard = new ImmutableShardRouting(index, shardId, nodeId, primary, state, version);
|
||||
return internalAddShard(shard, fromApi);
|
||||
}
|
||||
|
||||
private Builder internalAddShard(ImmutableShardRouting shard, boolean fromApi) {
|
||||
/**
|
||||
* Adds a new shard routing (makes a copy of it), with reference data used from the index shard routing table
|
||||
* if it needs to be created.
|
||||
*/
|
||||
public Builder addShard(IndexShardRoutingTable refData, ShardRouting shard) {
|
||||
IndexShardRoutingTable indexShard = shards.get(shard.id());
|
||||
if (indexShard == null) {
|
||||
indexShard = new IndexShardRoutingTable.Builder(shard.shardId(), fromApi ? false : true).addShard(shard).build();
|
||||
indexShard = new IndexShardRoutingTable.Builder(refData.shardId(), refData.primaryAllocatedPostApi()).addShard(new ImmutableShardRouting(shard)).build();
|
||||
} else {
|
||||
indexShard = new IndexShardRoutingTable.Builder(indexShard).addShard(shard).build();
|
||||
indexShard = new IndexShardRoutingTable.Builder(indexShard).addShard(new ImmutableShardRouting(shard)).build();
|
||||
}
|
||||
shards.put(indexShard.shardId().id(), indexShard);
|
||||
return this;
|
||||
|
|
|
@ -51,12 +51,12 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
|||
|
||||
final AtomicInteger counter;
|
||||
|
||||
final boolean allocatedPostApi;
|
||||
final boolean primaryAllocatedPostApi;
|
||||
|
||||
IndexShardRoutingTable(ShardId shardId, ImmutableList<ShardRouting> shards, boolean allocatedPostApi) {
|
||||
IndexShardRoutingTable(ShardId shardId, ImmutableList<ShardRouting> shards, boolean primaryAllocatedPostApi) {
|
||||
this.shardId = shardId;
|
||||
this.shards = shards;
|
||||
this.allocatedPostApi = allocatedPostApi;
|
||||
this.primaryAllocatedPostApi = primaryAllocatedPostApi;
|
||||
this.counter = new AtomicInteger(ThreadLocalRandom.current().nextInt(shards.size()));
|
||||
|
||||
ShardRouting primary = null;
|
||||
|
@ -120,15 +120,15 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
|||
shardRoutings.add(new ImmutableShardRouting(shards.get(i), highestVersion));
|
||||
}
|
||||
}
|
||||
return new IndexShardRoutingTable(shardId, ImmutableList.copyOf(shardRoutings), allocatedPostApi);
|
||||
return new IndexShardRoutingTable(shardId, ImmutableList.copyOf(shardRoutings), primaryAllocatedPostApi);
|
||||
}
|
||||
|
||||
/**
|
||||
* Has this shard group primary shard been allocated post API creation. Will be set to
|
||||
* <tt>true</tt> if it was created because of recovery action.
|
||||
*/
|
||||
public boolean allocatedPostApi() {
|
||||
return allocatedPostApi;
|
||||
public boolean primaryAllocatedPostApi() {
|
||||
return primaryAllocatedPostApi;
|
||||
}
|
||||
|
||||
public ShardId shardId() {
|
||||
|
@ -404,18 +404,18 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
|||
|
||||
private final List<ShardRouting> shards;
|
||||
|
||||
private boolean allocatedPostApi;
|
||||
private boolean primaryAllocatedPostApi;
|
||||
|
||||
public Builder(IndexShardRoutingTable indexShard) {
|
||||
this.shardId = indexShard.shardId;
|
||||
this.shards = newArrayList(indexShard.shards);
|
||||
this.allocatedPostApi = indexShard.allocatedPostApi();
|
||||
this.primaryAllocatedPostApi = indexShard.primaryAllocatedPostApi();
|
||||
}
|
||||
|
||||
public Builder(ShardId shardId, boolean allocatedPostApi) {
|
||||
public Builder(ShardId shardId, boolean primaryAllocatedPostApi) {
|
||||
this.shardId = shardId;
|
||||
this.shards = newArrayList();
|
||||
this.allocatedPostApi = allocatedPostApi;
|
||||
this.primaryAllocatedPostApi = primaryAllocatedPostApi;
|
||||
}
|
||||
|
||||
public Builder addShard(ImmutableShardRouting shardEntry) {
|
||||
|
@ -438,14 +438,14 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
|||
|
||||
public IndexShardRoutingTable build() {
|
||||
// we can automatically set allocatedPostApi to true if the primary is active
|
||||
if (!allocatedPostApi) {
|
||||
if (!primaryAllocatedPostApi) {
|
||||
for (ShardRouting shardRouting : shards) {
|
||||
if (shardRouting.primary() && shardRouting.active()) {
|
||||
allocatedPostApi = true;
|
||||
primaryAllocatedPostApi = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new IndexShardRoutingTable(shardId, ImmutableList.copyOf(shards), allocatedPostApi);
|
||||
return new IndexShardRoutingTable(shardId, ImmutableList.copyOf(shards), primaryAllocatedPostApi);
|
||||
}
|
||||
|
||||
public static IndexShardRoutingTable readFrom(StreamInput in) throws IOException {
|
||||
|
@ -474,7 +474,7 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
|||
|
||||
public static void writeToThin(IndexShardRoutingTable indexShard, StreamOutput out) throws IOException {
|
||||
out.writeVInt(indexShard.shardId.id());
|
||||
out.writeBoolean(indexShard.allocatedPostApi());
|
||||
out.writeBoolean(indexShard.primaryAllocatedPostApi());
|
||||
|
||||
out.writeVInt(indexShard.shards.size());
|
||||
for (ShardRouting entry : indexShard) {
|
||||
|
|
|
@ -285,8 +285,8 @@ public class RoutingTable implements Iterable<IndexRoutingTable> {
|
|||
indexRoutingTableBuilders.put(index, indexBuilder);
|
||||
}
|
||||
|
||||
boolean allocatedPostApi = routingNodes.routingTable().index(shardRoutingEntry.index()).shard(shardRoutingEntry.id()).allocatedPostApi();
|
||||
indexBuilder.addShard(new ImmutableShardRouting(shardRoutingEntry), !allocatedPostApi);
|
||||
IndexShardRoutingTable refData = routingNodes.routingTable().index(shardRoutingEntry.index()).shard(shardRoutingEntry.id());
|
||||
indexBuilder.addShard(refData, shardRoutingEntry);
|
||||
}
|
||||
}
|
||||
for (MutableShardRouting shardRoutingEntry : Iterables.concat(routingNodes.unassigned(), routingNodes.ignoredUnassigned())) {
|
||||
|
@ -296,8 +296,8 @@ public class RoutingTable implements Iterable<IndexRoutingTable> {
|
|||
indexBuilder = new IndexRoutingTable.Builder(index);
|
||||
indexRoutingTableBuilders.put(index, indexBuilder);
|
||||
}
|
||||
boolean allocatedPostApi = routingNodes.routingTable().index(shardRoutingEntry.index()).shard(shardRoutingEntry.id()).allocatedPostApi();
|
||||
indexBuilder.addShard(new ImmutableShardRouting(shardRoutingEntry), !allocatedPostApi);
|
||||
IndexShardRoutingTable refData = routingNodes.routingTable().index(shardRoutingEntry.index()).shard(shardRoutingEntry.id());
|
||||
indexBuilder.addShard(refData, shardRoutingEntry);
|
||||
}
|
||||
for (IndexRoutingTable.Builder indexBuilder : indexRoutingTableBuilders.values()) {
|
||||
add(indexBuilder);
|
||||
|
@ -341,10 +341,19 @@ public class RoutingTable implements Iterable<IndexRoutingTable> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder add(IndexMetaData indexMetaData, boolean fromApi) {
|
||||
public Builder addAsNew(IndexMetaData indexMetaData) {
|
||||
if (indexMetaData.state() == IndexMetaData.State.OPEN) {
|
||||
IndexRoutingTable.Builder indexRoutingBuilder = new IndexRoutingTable.Builder(indexMetaData.index())
|
||||
.initializeEmpty(indexMetaData, fromApi);
|
||||
.initializeAsNew(indexMetaData);
|
||||
add(indexRoutingBuilder);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addAsRecovery(IndexMetaData indexMetaData) {
|
||||
if (indexMetaData.state() == IndexMetaData.State.OPEN) {
|
||||
IndexRoutingTable.Builder indexRoutingBuilder = new IndexRoutingTable.Builder(indexMetaData.index())
|
||||
.initializeAsRecovery(indexMetaData);
|
||||
add(indexRoutingBuilder);
|
||||
}
|
||||
return this;
|
||||
|
|
|
@ -33,6 +33,7 @@ public class DisableAllocationDecider extends AllocationDecider {
|
|||
|
||||
static {
|
||||
MetaData.addDynamicSettings(
|
||||
"cluster.routing.allocation.disable_new_allocation",
|
||||
"cluster.routing.allocation.disable_allocation",
|
||||
"cluster.routing.allocation.disable_replica_allocation"
|
||||
);
|
||||
|
@ -41,6 +42,12 @@ public class DisableAllocationDecider extends AllocationDecider {
|
|||
class ApplySettings implements NodeSettingsService.Listener {
|
||||
@Override
|
||||
public void onRefreshSettings(Settings settings) {
|
||||
boolean disableNewAllocation = settings.getAsBoolean("cluster.routing.allocation.disable_new_allocation", DisableAllocationDecider.this.disableNewAllocation);
|
||||
if (disableNewAllocation != DisableAllocationDecider.this.disableNewAllocation) {
|
||||
logger.info("updating [cluster.routing.allocation.disable_new_allocation] from [{}] to [{}]", DisableAllocationDecider.this.disableNewAllocation, disableNewAllocation);
|
||||
DisableAllocationDecider.this.disableNewAllocation = disableNewAllocation;
|
||||
}
|
||||
|
||||
boolean disableAllocation = settings.getAsBoolean("cluster.routing.allocation.disable_allocation", DisableAllocationDecider.this.disableAllocation);
|
||||
if (disableAllocation != DisableAllocationDecider.this.disableAllocation) {
|
||||
logger.info("updating [cluster.routing.allocation.disable_allocation] from [{}] to [{}]", DisableAllocationDecider.this.disableAllocation, disableAllocation);
|
||||
|
@ -55,12 +62,14 @@ public class DisableAllocationDecider extends AllocationDecider {
|
|||
}
|
||||
}
|
||||
|
||||
private volatile boolean disableNewAllocation;
|
||||
private volatile boolean disableAllocation;
|
||||
private volatile boolean disableReplicaAllocation;
|
||||
|
||||
@Inject
|
||||
public DisableAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) {
|
||||
super(settings);
|
||||
this.disableNewAllocation = settings.getAsBoolean("cluster.routing.allocation.disable_new_allocation", false);
|
||||
this.disableAllocation = settings.getAsBoolean("cluster.routing.allocation.disable_allocation", false);
|
||||
this.disableReplicaAllocation = settings.getAsBoolean("cluster.routing.allocation.disable_replica_allocation", false);
|
||||
|
||||
|
@ -69,6 +78,11 @@ public class DisableAllocationDecider extends AllocationDecider {
|
|||
|
||||
@Override
|
||||
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
|
||||
if (shardRouting.primary() && !allocation.routingNodes().routingTable().index(shardRouting.index()).shard(shardRouting.id()).primaryAllocatedPostApi()) {
|
||||
// if its primary, and it hasn't been allocated post API (meaning its a "fresh newly created shard"), only disable allocation
|
||||
// on a special disable allocation flag
|
||||
return allocation.ignoreDisable() ? Decision.YES : disableNewAllocation ? Decision.NO : Decision.YES;
|
||||
}
|
||||
if (disableAllocation) {
|
||||
return allocation.ignoreDisable() ? Decision.YES : Decision.NO;
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ public class GatewayService extends AbstractLifecycleComponent<GatewayService> i
|
|||
// initialize all index routing tables as empty
|
||||
RoutingTable.Builder routingTableBuilder = RoutingTable.builder().routingTable(updatedState.routingTable());
|
||||
for (IndexMetaData indexMetaData : updatedState.metaData().indices().values()) {
|
||||
routingTableBuilder.add(indexMetaData, false /* not from API */);
|
||||
routingTableBuilder.addAsRecovery(indexMetaData);
|
||||
}
|
||||
// start with 0 based versions for routing table
|
||||
routingTableBuilder.version(0);
|
||||
|
|
|
@ -118,7 +118,7 @@ public class LocalGatewayAllocator extends AbstractComponent implements GatewayA
|
|||
}
|
||||
|
||||
// this is an API allocation, ignore since we know there is no data...
|
||||
if (!routingNodes.routingTable().index(shard.index()).shard(shard.id()).allocatedPostApi()) {
|
||||
if (!routingNodes.routingTable().index(shard.index()).shard(shard.id()).primaryAllocatedPostApi()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ public class LocalAllocateDangledIndices extends AbstractComponent {
|
|||
importNeeded = true;
|
||||
metaData.put(indexMetaData, false);
|
||||
blocks.addBlocks(indexMetaData);
|
||||
routingTableBuilder.add(indexMetaData, false);
|
||||
routingTableBuilder.addAsRecovery(indexMetaData);
|
||||
sb.append("[").append(indexMetaData.index()).append("/").append(indexMetaData.state()).append("]");
|
||||
}
|
||||
if (!importNeeded) {
|
||||
|
|
|
@ -616,7 +616,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
|||
if (shardRouting.relocatingNodeId() == null) {
|
||||
// we are the first primary, recover from the gateway
|
||||
// if its post api allocation, the index should exists
|
||||
boolean indexShouldExists = indexShardRouting.allocatedPostApi();
|
||||
boolean indexShouldExists = indexShardRouting.primaryAllocatedPostApi();
|
||||
IndexShardGatewayService shardGatewayService = indexService.shardInjector(shardId).getInstance(IndexShardGatewayService.class);
|
||||
shardGatewayService.recover(indexShouldExists, new IndexShardGatewayService.RecoveryListener() {
|
||||
@Override
|
||||
|
|
|
@ -60,6 +60,7 @@ public class ClusterRerouteTests extends AbstractNodesTests {
|
|||
@Test
|
||||
public void rerouteWithCommands() throws Exception {
|
||||
Settings commonSettings = settingsBuilder()
|
||||
.put("cluster.routing.allocation.disable_new_allocation", true)
|
||||
.put("cluster.routing.allocation.disable_allocation", true)
|
||||
.build();
|
||||
|
||||
|
@ -122,6 +123,7 @@ public class ClusterRerouteTests extends AbstractNodesTests {
|
|||
@Test
|
||||
public void rerouteWithAllocateLocalGateway() throws Exception {
|
||||
Settings commonSettings = settingsBuilder()
|
||||
.put("cluster.routing.allocation.disable_new_allocation", true)
|
||||
.put("cluster.routing.allocation.disable_allocation", true)
|
||||
.put("gateway.type", "local")
|
||||
.build();
|
||||
|
|
|
@ -32,7 +32,6 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -56,20 +55,20 @@ public class AllocatePostApiFlagTests {
|
|||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
||||
.build();
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
assertThat(clusterState.routingTable().index("test").shard(0).allocatedPostApi(), equalTo(false));
|
||||
assertThat(clusterState.routingTable().index("test").shard(0).primaryAllocatedPostApi(), equalTo(false));
|
||||
|
||||
logger.info("adding two nodes and performing rerouting");
|
||||
clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2"))).build();
|
||||
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState);
|
||||
clusterState = newClusterStateBuilder().state(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
assertThat(clusterState.routingTable().index("test").shard(0).allocatedPostApi(), equalTo(false));
|
||||
assertThat(clusterState.routingTable().index("test").shard(0).primaryAllocatedPostApi(), equalTo(false));
|
||||
|
||||
logger.info("start primary shard");
|
||||
rerouteResult = allocation.applyStartedShards(clusterState, clusterState.routingNodes().shardsWithState(INITIALIZING));
|
||||
clusterState = newClusterStateBuilder().state(clusterState).routingTable(rerouteResult.routingTable()).build();
|
||||
assertThat(clusterState.routingTable().index("test").shard(0).allocatedPostApi(), equalTo(true));
|
||||
assertThat(clusterState.routingTable().index("test").shard(0).primaryAllocatedPostApi(), equalTo(true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
|
@ -69,7 +68,7 @@ public class AllocationCommandsTests {
|
|||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
||||
.build();
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
|
@ -107,6 +106,7 @@ public class AllocationCommandsTests {
|
|||
@Test
|
||||
public void allocateCommand() {
|
||||
AllocationService allocation = new AllocationService(settingsBuilder()
|
||||
.put("cluster.routing.allocation.disable_new_allocation", true)
|
||||
.put("cluster.routing.allocation.disable_allocation", true)
|
||||
.build());
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class AllocationCommandsTests {
|
|||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||
.build();
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
|
@ -187,6 +187,7 @@ public class AllocationCommandsTests {
|
|||
@Test
|
||||
public void cancelCommand() {
|
||||
AllocationService allocation = new AllocationService(settingsBuilder()
|
||||
.put("cluster.routing.allocation.disable_new_allocation", true)
|
||||
.put("cluster.routing.allocation.disable_allocation", true)
|
||||
.build());
|
||||
|
||||
|
@ -195,7 +196,7 @@ public class AllocationCommandsTests {
|
|||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||
.build();
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
|
|
|
@ -33,11 +33,10 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
|
@ -63,7 +62,7 @@ public class AwarenessAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -132,7 +131,7 @@ public class AwarenessAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -204,7 +203,7 @@ public class AwarenessAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -289,8 +288,8 @@ public class AwarenessAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -372,7 +371,7 @@ public class AwarenessAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -451,7 +450,7 @@ public class AwarenessAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -533,7 +532,7 @@ public class AwarenessAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -601,7 +600,7 @@ public class AwarenessAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -673,8 +672,8 @@ public class AwarenessAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -33,7 +33,6 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -56,8 +55,8 @@ public class ClusterRebalanceRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -142,8 +141,8 @@ public class ClusterRebalanceRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -246,8 +245,8 @@ public class ClusterRebalanceRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -330,8 +329,8 @@ public class ClusterRebalanceRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -453,8 +452,8 @@ public class ClusterRebalanceRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -537,8 +536,8 @@ public class ClusterRebalanceRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -32,7 +32,6 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -60,7 +59,7 @@ public class ConcurrentRebalanceRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -34,7 +34,6 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -61,7 +60,7 @@ public class DeadNodesAllocationTests {
|
|||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||
.build();
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
|
@ -113,7 +112,7 @@ public class DeadNodesAllocationTests {
|
|||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||
.build();
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
|
@ -188,7 +187,7 @@ public class DeadNodesAllocationTests {
|
|||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||
.build();
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
|
|
|
@ -31,11 +31,10 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
|
@ -49,6 +48,7 @@ public class DisableAllocationTests {
|
|||
@Test
|
||||
public void testDisableAllocation() {
|
||||
AllocationService strategy = new AllocationService(settingsBuilder()
|
||||
.put("cluster.routing.allocation.disable_new_allocation", true)
|
||||
.put("cluster.routing.allocation.disable_allocation", true)
|
||||
.build());
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class DisableAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -88,7 +88,7 @@ public class DisableAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -33,7 +33,6 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
|
@ -60,7 +59,7 @@ public class ElectReplicaAsPrimaryDuringRelocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -34,11 +34,9 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -57,8 +55,8 @@ public class FailedNodeRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -117,8 +115,8 @@ public class FailedNodeRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -37,7 +37,6 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -65,7 +64,7 @@ public class FailedShardsRoutingTests {
|
|||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||
.build();
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
|
@ -156,7 +155,7 @@ public class FailedShardsRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -237,7 +236,7 @@ public class FailedShardsRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -294,7 +293,7 @@ public class FailedShardsRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -351,7 +350,7 @@ public class FailedShardsRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -37,11 +37,10 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
|
@ -66,7 +65,7 @@ public class FilterRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -115,7 +114,7 @@ public class FilterRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -32,12 +32,11 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
@ -60,7 +59,7 @@ public class PrimaryElectionRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -32,12 +32,11 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
|
@ -63,7 +62,7 @@ public class PrimaryNotRelocatedWhileBeingRecoveredTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -33,11 +33,10 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
@ -64,7 +63,7 @@ public class RebalanceAfterActiveTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -32,11 +32,10 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
@ -59,7 +58,7 @@ public class ReplicaAllocatedAfterPrimaryTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -16,7 +16,6 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -40,7 +39,7 @@ public class SameShardRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
||||
|
|
|
@ -33,11 +33,10 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
|
@ -56,8 +55,8 @@ public class ShardVersioningTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -37,7 +37,6 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -66,7 +65,7 @@ public class ShardsLimitAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -113,7 +112,7 @@ public class ShardsLimitAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -137,7 +136,7 @@ public class ShardsLimitAllocationTests {
|
|||
))
|
||||
.build();
|
||||
routingTable = routingTable().routingTable(routingTable)
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.build();
|
||||
|
||||
clusterState = newClusterStateBuilder().state(clusterState).metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -41,10 +41,8 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
@ -67,7 +65,7 @@ public class SingleShardNoReplicasRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -169,7 +167,7 @@ public class SingleShardNoReplicasRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -227,7 +225,7 @@ public class SingleShardNoReplicasRoutingTests {
|
|||
|
||||
RoutingTable.Builder routingTableBuilder = routingTable();
|
||||
for (int i = 0; i < numberOfIndices; i++) {
|
||||
routingTableBuilder.add(indexRoutingTable("test" + i).initializeEmpty(metaData.index("test" + i)));
|
||||
routingTableBuilder.addAsNew(metaData.index("test" + i));
|
||||
}
|
||||
RoutingTable routingTable = routingTableBuilder.build();
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -340,7 +338,7 @@ public class SingleShardNoReplicasRoutingTests {
|
|||
|
||||
RoutingTable.Builder routingTableBuilder = routingTable();
|
||||
for (int i = 0; i < numberOfIndices; i++) {
|
||||
routingTableBuilder.add(indexRoutingTable("test" + i).initializeEmpty(metaData.index("test" + i)));
|
||||
routingTableBuilder.addAsNew(metaData.index("test" + i));
|
||||
}
|
||||
RoutingTable routingTable = routingTableBuilder.build();
|
||||
|
||||
|
|
|
@ -32,11 +32,10 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
@ -59,7 +58,7 @@ public class SingleShardOneReplicaRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -32,11 +32,10 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
|
@ -63,7 +62,7 @@ public class TenShardsOneReplicaRoutingTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -31,10 +31,8 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -60,7 +58,7 @@ public class ThrottlingAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -121,7 +119,7 @@ public class ThrottlingAllocationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -13,11 +13,10 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
|
@ -39,7 +38,7 @@ public class UpdateNumberOfReplicasTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.testng.annotations.Test;
|
|||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -50,7 +49,7 @@ public class ClusterSerializationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
DiscoveryNodes nodes = DiscoveryNodes.newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).localNodeId("node1").masterNodeId("node2").build();
|
||||
|
@ -73,7 +72,7 @@ public class ClusterSerializationTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
DiscoveryNodes nodes = DiscoveryNodes.newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).build();
|
||||
|
|
|
@ -37,7 +37,6 @@ import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable;
|
||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
|
@ -92,7 +91,7 @@ public class RoutingIteratorTests {
|
|||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(2))
|
||||
.build();
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.build();
|
||||
|
||||
ShardIterator shardIterator = routingTable.index("test1").shard(0).shardsIt(0);
|
||||
|
@ -128,8 +127,8 @@ public class RoutingIteratorTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ShardIterator shardIterator = routingTable.index("test1").shard(0).shardsIt(0);
|
||||
|
@ -231,8 +230,8 @@ public class RoutingIteratorTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test1").initializeEmpty(metaData.index("test1")))
|
||||
.add(indexRoutingTable("test2").initializeEmpty(metaData.index("test2")))
|
||||
.addAsNew(metaData.index("test1"))
|
||||
.addAsNew(metaData.index("test2"))
|
||||
.build();
|
||||
|
||||
ShardIterator shardIterator = routingTable.index("test1").shard(0).shardsRandomIt();
|
||||
|
@ -264,7 +263,7 @@ public class RoutingIteratorTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
@ -313,7 +312,7 @@ public class RoutingIteratorTests {
|
|||
.build();
|
||||
|
||||
RoutingTable routingTable = routingTable()
|
||||
.add(indexRoutingTable("test").initializeEmpty(metaData.index("test")))
|
||||
.addAsNew(metaData.index("test"))
|
||||
.build();
|
||||
|
||||
ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build();
|
||||
|
|
Loading…
Reference in New Issue