throw explicit failure when trying to change the number of shards on an index

This commit is contained in:
kimchy 2011-06-08 13:49:22 +03:00
parent e3526f7f07
commit 597f3b7a8f
1 changed files with 9 additions and 0 deletions

View File

@ -19,6 +19,7 @@
package org.elasticsearch.cluster.metadata; package org.elasticsearch.cluster.metadata;
import org.elasticsearch.ElasticSearchIllegalArgumentException;
import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
@ -113,6 +114,14 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements
updatedSettingsBuilder.put(entry.getKey(), entry.getValue()); updatedSettingsBuilder.put(entry.getKey(), entry.getValue());
} }
} }
// never allow to change the number of shards
for (String key : updatedSettingsBuilder.internalMap().keySet()) {
if (key.equals(IndexMetaData.SETTING_NUMBER_OF_SHARDS)) {
listener.onFailure(new ElasticSearchIllegalArgumentException("can't change the number of shards for an index"));
return;
}
}
Set<String> removedSettings = Sets.newHashSet(); Set<String> removedSettings = Sets.newHashSet();
for (String key : updatedSettingsBuilder.internalMap().keySet()) { for (String key : updatedSettingsBuilder.internalMap().keySet()) {
if (!IndexMetaData.dynamicSettings().contains(key)) { if (!IndexMetaData.dynamicSettings().contains(key)) {