remove max_shards_per_node setting (actually, you could not set it even...), will be revisted when proper SLA based shard allocation will be implemented

This commit is contained in:
kimchy 2010-07-14 14:29:56 +03:00
parent a6bd64f30d
commit e7d80b8244
5 changed files with 4 additions and 35 deletions

View File

@ -51,9 +51,6 @@ public class MetaData implements Iterable<IndexMetaData> {
private final ImmutableMap<String, IndexMetaData> indices;
// limits the number of shards per node
private final int maxNumberOfShardsPerNode;
private final transient int totalNumberOfShards;
private final boolean recoveredFromGateway;
@ -64,10 +61,9 @@ public class MetaData implements Iterable<IndexMetaData> {
private final ImmutableMap<String, String[]> aliasAndIndexToIndexMap;
private final ImmutableMap<String, ImmutableSet<String>> aliasAndIndexToIndexMap2;
private MetaData(ImmutableMap<String, IndexMetaData> indices, boolean recoveredFromGateway, int maxNumberOfShardsPerNode) {
private MetaData(ImmutableMap<String, IndexMetaData> indices, boolean recoveredFromGateway) {
this.indices = ImmutableMap.copyOf(indices);
this.recoveredFromGateway = recoveredFromGateway;
this.maxNumberOfShardsPerNode = maxNumberOfShardsPerNode;
int totalNumberOfShards = 0;
for (IndexMetaData indexMetaData : indices.values()) {
totalNumberOfShards += indexMetaData.totalNumberOfShards();
@ -212,14 +208,6 @@ public class MetaData implements Iterable<IndexMetaData> {
return indices();
}
public int maxNumberOfShardsPerNode() {
return this.maxNumberOfShardsPerNode;
}
public int getMaxNumberOfShardsPerNode() {
return maxNumberOfShardsPerNode();
}
public int totalNumberOfShards() {
return this.totalNumberOfShards;
}
@ -238,9 +226,6 @@ public class MetaData implements Iterable<IndexMetaData> {
public static class Builder {
// limits the number of shards per node
private int maxNumberOfShardsPerNode = 100;
private MapBuilder<String, IndexMetaData> indices = newMapBuilder();
private boolean recoveredFromGateway = false;
@ -269,11 +254,6 @@ public class MetaData implements Iterable<IndexMetaData> {
return this;
}
public Builder maxNumberOfShardsPerNode(int maxNumberOfShardsPerNode) {
this.maxNumberOfShardsPerNode = maxNumberOfShardsPerNode;
return this;
}
/**
* Indicates that this cluster state has been recovered from the gateawy.
*/
@ -283,7 +263,7 @@ public class MetaData implements Iterable<IndexMetaData> {
}
public MetaData build() {
return new MetaData(indices.immutableMap(), recoveredFromGateway, maxNumberOfShardsPerNode);
return new MetaData(indices.immutableMap(), recoveredFromGateway);
}
public static String toXContent(MetaData metaData) throws IOException {
@ -296,7 +276,6 @@ public class MetaData implements Iterable<IndexMetaData> {
public static void toXContent(MetaData metaData, XContentBuilder builder, ToXContent.Params params) throws IOException {
builder.startObject("meta-data");
builder.field("max_number_of_shards_per_node", metaData.maxNumberOfShardsPerNode());
builder.startObject("indices");
for (IndexMetaData indexMetaData : metaData) {
@ -325,10 +304,6 @@ public class MetaData implements Iterable<IndexMetaData> {
builder.put(IndexMetaData.Builder.fromXContent(parser, globalSettings));
}
}
} else if (token.isValue()) {
if ("max_number_of_shards_per_node".equals(currentFieldName)) {
builder.maxNumberOfShardsPerNode(parser.intValue());
}
}
}
return builder.build();
@ -336,7 +311,6 @@ public class MetaData implements Iterable<IndexMetaData> {
public static MetaData readFrom(StreamInput in, @Nullable Settings globalSettings) throws IOException {
Builder builder = new Builder();
builder.maxNumberOfShardsPerNode(in.readInt());
// we only serialize it using readFrom, not in to/from XContent
builder.recoveredFromGateway = in.readBoolean();
int size = in.readVInt();
@ -347,7 +321,6 @@ public class MetaData implements Iterable<IndexMetaData> {
}
public static void writeTo(MetaData metaData, StreamOutput out) throws IOException {
out.writeInt(metaData.maxNumberOfShardsPerNode());
out.writeBoolean(metaData.recoveredFromGateway());
out.writeVInt(metaData.indices.size());
for (IndexMetaData indexMetaData : metaData) {

View File

@ -120,7 +120,7 @@ public class RoutingNode implements Iterable<MutableShardRouting> {
}
public boolean canAllocate(MetaData metaData, RoutingTable routingTable) {
return shards().size() < metaData.maxNumberOfShardsPerNode();
return true;
}
public boolean canAllocate(ShardRouting requested) {

View File

@ -236,8 +236,7 @@ public class GatewayService extends AbstractLifecycleComponent<GatewayService> i
private void updateClusterStateFromGateway(final MetaData fMetaData, final CountDownLatch latch) {
clusterService.submitStateUpdateTask("gateway (recovered meta-data)", new ProcessedClusterStateUpdateTask() {
@Override public ClusterState execute(ClusterState currentState) {
MetaData.Builder metaDataBuilder = newMetaDataBuilder()
.metaData(currentState.metaData()).maxNumberOfShardsPerNode(fMetaData.maxNumberOfShardsPerNode());
MetaData.Builder metaDataBuilder = newMetaDataBuilder().metaData(currentState.metaData());
// mark the metadata as read from gateway
metaDataBuilder.markAsRecoveredFromGateway();
return newClusterStateBuilder().state(currentState).metaData(metaDataBuilder).build();

View File

@ -116,7 +116,6 @@ public class RestClusterStateAction extends BaseRestHandler {
// meta data
builder.startObject("metadata");
builder.field("max_number_of_shards_per_node", state.metaData().maxNumberOfShardsPerNode());
builder.startObject("indices");
for (IndexMetaData indexMetaData : state.metaData()) {
builder.startObject(indexMetaData.index());

View File

@ -40,7 +40,6 @@ public class ToAndFromJsonMetaDataTests {
@Test
public void testSimpleJsonFromAndTo() throws IOException {
MetaData metaData = newMetaDataBuilder()
.maxNumberOfShardsPerNode(2)
.put(newIndexMetaDataBuilder("test1")
.numberOfShards(1)
.numberOfReplicas(2))
@ -64,7 +63,6 @@ public class ToAndFromJsonMetaDataTests {
System.out.println("ToJson: " + metaDataSource);
MetaData parsedMetaData = MetaData.Builder.fromXContent(XContentFactory.xContent(XContentType.JSON).createParser(metaDataSource), null);
assertThat(parsedMetaData.maxNumberOfShardsPerNode(), equalTo(2));
IndexMetaData indexMetaData = parsedMetaData.index("test1");
assertThat(indexMetaData.numberOfShards(), equalTo(1));