From f8e26c2f758cbdae6a6305fa1b828b59b2a8d2c7 Mon Sep 17 00:00:00 2001 From: Brian Murphy Date: Wed, 26 Nov 2014 15:50:14 +0000 Subject: [PATCH] Remove dependency on the alert history indices being started in the actions. Original commit: elastic/x-pack-elasticsearch@a3f0e0fe46a797ce1fcb2508c1dbaba976e72ba3 --- .../actions/ack/TransportAckAlertAction.java | 11 +---------- .../actions/delete/TransportDeleteAlertAction.java | 11 +---------- .../actions/put/TransportPutAlertAction.java | 12 +----------- 3 files changed, 3 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/elasticsearch/alerts/transport/actions/ack/TransportAckAlertAction.java b/src/main/java/org/elasticsearch/alerts/transport/actions/ack/TransportAckAlertAction.java index 8959391d89b..277c0f9d012 100644 --- a/src/main/java/org/elasticsearch/alerts/transport/actions/ack/TransportAckAlertAction.java +++ b/src/main/java/org/elasticsearch/alerts/transport/actions/ack/TransportAckAlertAction.java @@ -8,11 +8,9 @@ package org.elasticsearch.alerts.transport.actions.ack; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction; import org.elasticsearch.alerts.AlertManager; import org.elasticsearch.alerts.AlertsStore; -import org.elasticsearch.alerts.actions.AlertActionManager; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlockException; @@ -22,10 +20,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - /** * Performs the delete operation. */ @@ -67,10 +61,7 @@ public class TransportAckAlertAction extends TransportMasterNodeOperationAction< @Override protected ClusterBlockException checkBlock(AckAlertRequest request, ClusterState state) { - String[] indices = state.metaData().concreteIndices(IndicesOptions.lenientExpandOpen(), AlertActionManager.ALERT_HISTORY_INDEX_PREFIX + "*"); - List indicesToCheck = new ArrayList<>(Arrays.asList(indices)); - indicesToCheck.add(AlertsStore.ALERT_INDEX); - return state.blocks().indicesBlockedException(ClusterBlockLevel.WRITE, indicesToCheck.toArray(new String[indicesToCheck.size()])); + return state.blocks().indicesBlockedException(ClusterBlockLevel.WRITE, new String[]{AlertsStore.ALERT_INDEX}); } diff --git a/src/main/java/org/elasticsearch/alerts/transport/actions/delete/TransportDeleteAlertAction.java b/src/main/java/org/elasticsearch/alerts/transport/actions/delete/TransportDeleteAlertAction.java index 0aa5a24ffd1..97a8ae6e8ba 100644 --- a/src/main/java/org/elasticsearch/alerts/transport/actions/delete/TransportDeleteAlertAction.java +++ b/src/main/java/org/elasticsearch/alerts/transport/actions/delete/TransportDeleteAlertAction.java @@ -8,11 +8,9 @@ package org.elasticsearch.alerts.transport.actions.delete; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction; import org.elasticsearch.alerts.AlertManager; import org.elasticsearch.alerts.AlertsStore; -import org.elasticsearch.alerts.actions.AlertActionManager; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlockException; @@ -22,10 +20,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - /** * Performs the delete operation. */ @@ -67,10 +61,7 @@ public class TransportDeleteAlertAction extends TransportMasterNodeOperationActi @Override protected ClusterBlockException checkBlock(DeleteAlertRequest request, ClusterState state) { - String[] indices = state.metaData().concreteIndices(IndicesOptions.lenientExpandOpen(), AlertActionManager.ALERT_HISTORY_INDEX_PREFIX + "*"); - List indicesToCheck = new ArrayList<>(Arrays.asList(indices)); - indicesToCheck.add(AlertsStore.ALERT_INDEX); - return state.blocks().indicesBlockedException(ClusterBlockLevel.WRITE, indicesToCheck.toArray(new String[indicesToCheck.size()])); + return state.blocks().indicesBlockedException(ClusterBlockLevel.WRITE, new String[]{AlertsStore.ALERT_INDEX}); } diff --git a/src/main/java/org/elasticsearch/alerts/transport/actions/put/TransportPutAlertAction.java b/src/main/java/org/elasticsearch/alerts/transport/actions/put/TransportPutAlertAction.java index ad0a92cc150..bcc1e88ae3e 100644 --- a/src/main/java/org/elasticsearch/alerts/transport/actions/put/TransportPutAlertAction.java +++ b/src/main/java/org/elasticsearch/alerts/transport/actions/put/TransportPutAlertAction.java @@ -9,11 +9,9 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction; import org.elasticsearch.alerts.AlertManager; import org.elasticsearch.alerts.AlertsStore; -import org.elasticsearch.alerts.actions.AlertActionManager; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlockException; @@ -23,10 +21,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - /** */ public class TransportPutAlertAction extends TransportMasterNodeOperationAction { @@ -68,11 +62,7 @@ public class TransportPutAlertAction extends TransportMasterNodeOperationAction< @Override protected ClusterBlockException checkBlock(PutAlertRequest request, ClusterState state) { request.beforeLocalFork(); // This is the best place to make the alert source safe - String[] indices = state.metaData().concreteIndices(IndicesOptions.lenientExpandOpen(), AlertActionManager.ALERT_HISTORY_INDEX_PREFIX + "*"); - List indicesToCheck = new ArrayList<>(Arrays.asList(indices)); - indicesToCheck.add(AlertsStore.ALERT_INDEX); - return state.blocks().indicesBlockedException(ClusterBlockLevel.WRITE, indicesToCheck.toArray(new String[indicesToCheck.size()])); - + return state.blocks().indicesBlockedException(ClusterBlockLevel.WRITE, new String[]{AlertsStore.ALERT_INDEX}); } }