|
@@ -157,25 +157,23 @@ public class IndexMetaData implements Diffable<IndexMetaData>, FromXContentBuild
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- static {
|
|
|
+ static Setting<Integer> buildNumberOfShardsSetting() {
|
|
|
+ /* This is a safety limit that should only be exceeded in very rare and special cases. The assumption is that
|
|
|
+ * 99% of the users have less than 1024 shards per index. We also make it a hard check that requires restart of nodes
|
|
|
+ * if a cluster should allow to create more than 1024 shards per index. NOTE: this does not limit the number of shards per cluster.
|
|
|
+ * this also prevents creating stuff like a new index with millions of shards by accident which essentially kills the entire cluster
|
|
|
+ * with OOM on the spot.*/
|
|
|
final int maxNumShards = Integer.parseInt(System.getProperty("es.index.max_number_of_shards", "1024"));
|
|
|
if (maxNumShards < 1) {
|
|
|
throw new IllegalArgumentException("es.index.max_number_of_shards must be > 0");
|
|
|
}
|
|
|
- MAX_NUMBER_OF_SHARDS = maxNumShards;
|
|
|
+ return Setting.intSetting(SETTING_NUMBER_OF_SHARDS, Math.min(5, maxNumShards), 1, maxNumShards,
|
|
|
+ Property.IndexScope);
|
|
|
}
|
|
|
- /* This is a safety limit that should only be exceeded in very rare and special cases. The assumption is that
|
|
|
- * 99% of the users have less than 1024 shards per index. We also make it a hard check that requires restart of nodes
|
|
|
- * if a cluster should allow to create more than 1024 shards per index. NOTE: this does not limit the number of shards per cluster.
|
|
|
- * this also prevents creating stuff like a new index with millions of shards by accident which essentially kills the entire cluster
|
|
|
- * with OOM on the spot.*/
|
|
|
- private static final int MAX_NUMBER_OF_SHARDS;
|
|
|
|
|
|
public static final String INDEX_SETTING_PREFIX = "index.";
|
|
|
public static final String SETTING_NUMBER_OF_SHARDS = "index.number_of_shards";
|
|
|
- public static final Setting<Integer> INDEX_NUMBER_OF_SHARDS_SETTING =
|
|
|
- Setting.intSetting(SETTING_NUMBER_OF_SHARDS, Math.min(5, MAX_NUMBER_OF_SHARDS), 1, MAX_NUMBER_OF_SHARDS,
|
|
|
- Property.IndexScope);
|
|
|
+ public static final Setting<Integer> INDEX_NUMBER_OF_SHARDS_SETTING = buildNumberOfShardsSetting();
|
|
|
public static final String SETTING_NUMBER_OF_REPLICAS = "index.number_of_replicas";
|
|
|
public static final Setting<Integer> INDEX_NUMBER_OF_REPLICAS_SETTING =
|
|
|
Setting.intSetting(SETTING_NUMBER_OF_REPLICAS, 1, 0, Property.Dynamic, Property.IndexScope);
|