From 597f3b7a8f4cefad424bb48f378c23840e5758e8 Mon Sep 17 00:00:00 2001 From: kimchy Date: Wed, 8 Jun 2011 13:49:22 +0300 Subject: [PATCH] throw explicit failure when trying to change the number of shards on an index --- .../cluster/metadata/MetaDataUpdateSettingsService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java index a6306b90e50..a7d6301ad15 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java @@ -19,6 +19,7 @@ package org.elasticsearch.cluster.metadata; +import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; @@ -113,6 +114,14 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements 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 removedSettings = Sets.newHashSet(); for (String key : updatedSettingsBuilder.internalMap().keySet()) { if (!IndexMetaData.dynamicSettings().contains(key)) {