diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java index c83fc7d177d..2c25ee34f18 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java @@ -36,15 +36,15 @@ import org.elasticsearch.node.settings.NodeSettingsService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import java.util.Arrays; - /** * Close index action */ -public class TransportCloseIndexAction extends TransportMasterNodeAction { +public class TransportCloseIndexAction extends TransportMasterNodeAction implements NodeSettingsService.Listener { private final MetaDataIndexStateService indexStateService; private final DestructiveOperations destructiveOperations; + private volatile boolean closeIndexEnabled; + public static final String SETTING_CLUSTER_INDICES_CLOSE_ENABLE = "cluster.indices.close.enable"; @Inject public TransportCloseIndexAction(Settings settings, TransportService transportService, ClusterService clusterService, @@ -54,6 +54,8 @@ public class TransportCloseIndexAction extends TransportMasterNodeAction listener) { destructiveOperations.failDestructive(request.indices()); + if (closeIndexEnabled == false) { + throw new IllegalStateException("closing indices is disabled - set [" + SETTING_CLUSTER_INDICES_CLOSE_ENABLE + ": true] to enable it. NOTE: closed indices still consume a significant amount of diskspace"); + } super.doExecute(request, listener); } @@ -99,4 +104,13 @@ public class TransportCloseIndexAction extends TransportMasterNodeAction