From 2cd77088f17698909ddd60f08b3dad9c147301b9 Mon Sep 17 00:00:00 2001 From: kimchy Date: Mon, 30 May 2011 19:26:45 +0300 Subject: [PATCH] protected from changing teh number of shards in update settings --- .../metadata/MetaDataUpdateSettingsService.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 a8f12a3760f..1dce1f43f39 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,7 +19,12 @@ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.cluster.*; +import org.elasticsearch.ElasticSearchIllegalArgumentException; +import org.elasticsearch.cluster.ClusterChangedEvent; +import org.elasticsearch.cluster.ClusterService; +import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.ClusterStateListener; +import org.elasticsearch.cluster.ProcessedClusterStateUpdateTask; import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.component.AbstractComponent; @@ -105,6 +110,10 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements } } final Settings settings = updatedSettingsBuilder.build(); + if (settings.get(IndexMetaData.SETTING_NUMBER_OF_SHARDS) != null) { + listener.onFailure(new ElasticSearchIllegalArgumentException("can't change the number of shards for an index")); + return; + } clusterService.submitStateUpdateTask("update-settings", new ProcessedClusterStateUpdateTask() { @Override public ClusterState execute(ClusterState currentState) { try {