diff --git a/src/main/java/org/elasticsearch/watcher/history/HistoryStore.java b/src/main/java/org/elasticsearch/watcher/history/HistoryStore.java index 182ef57e767..bfc913e243b 100644 --- a/src/main/java/org/elasticsearch/watcher/history/HistoryStore.java +++ b/src/main/java/org/elasticsearch/watcher/history/HistoryStore.java @@ -10,6 +10,7 @@ import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -39,6 +40,7 @@ public class HistoryStore extends AbstractComponent { private static final ImmutableSet forbiddenIndexSettings = ImmutableSet.of("index.mapper.dynamic"); private final ClientProxy client; + private final IndexNameExpressionResolver indexNameExpressionResolver; private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); private final Lock putUpdateLock = readWriteLock.readLock(); @@ -46,9 +48,10 @@ public class HistoryStore extends AbstractComponent { private final AtomicBoolean started = new AtomicBoolean(false); @Inject - public HistoryStore(Settings settings, ClientProxy client) { + public HistoryStore(Settings settings, ClientProxy client, IndexNameExpressionResolver indexNameExpressionResolver) { super(settings); this.client = client; + this.indexNameExpressionResolver = indexNameExpressionResolver; } public void start() { @@ -56,7 +59,7 @@ public class HistoryStore extends AbstractComponent { } public boolean validate(ClusterState state) { - String[] indices = state.metaData().concreteIndices(IndicesOptions.lenientExpandOpen(), INDEX_PREFIX + "*"); + String[] indices = indexNameExpressionResolver.concreteIndices(state, IndicesOptions.lenientExpandOpen(), INDEX_PREFIX + "*"); if (indices.length == 0) { logger.debug("no history indices exist, so we can load"); return true; diff --git a/src/main/java/org/elasticsearch/watcher/transport/actions/WatcherTransportAction.java b/src/main/java/org/elasticsearch/watcher/transport/actions/WatcherTransportAction.java index 2de414f225a..e38e901290b 100644 --- a/src/main/java/org/elasticsearch/watcher/transport/actions/WatcherTransportAction.java +++ b/src/main/java/org/elasticsearch/watcher/transport/actions/WatcherTransportAction.java @@ -11,6 +11,7 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.MasterNodeRequest; import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.cluster.ClusterService; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.plugin.core.LicenseUtils; import org.elasticsearch.threadpool.ThreadPool; @@ -24,8 +25,10 @@ public abstract class WatcherTransportAction request) { - super(settings, actionName, transportService, clusterService, threadPool, actionFilters, request); + public WatcherTransportAction(Settings settings, String actionName, TransportService transportService, + ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, + IndexNameExpressionResolver indexNameExpressionResolver, LicenseService licenseService, Class request) { + super(settings, actionName, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, request); this.licenseService = licenseService; } diff --git a/src/main/java/org/elasticsearch/watcher/transport/actions/ack/TransportAckWatchAction.java b/src/main/java/org/elasticsearch/watcher/transport/actions/ack/TransportAckWatchAction.java index 14e2c9605d3..a8657b3b27e 100644 --- a/src/main/java/org/elasticsearch/watcher/transport/actions/ack/TransportAckWatchAction.java +++ b/src/main/java/org/elasticsearch/watcher/transport/actions/ack/TransportAckWatchAction.java @@ -12,6 +12,7 @@ import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.block.ClusterBlockLevel; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -31,8 +32,9 @@ public class TransportAckWatchAction extends WatcherTransportAction matcher) { WatcherTestUtils.assertValue(source, path, matcher); } @@ -332,7 +337,7 @@ public abstract class AbstractWatcherIntegrationTests extends ElasticsearchInteg @Override public void run() { ClusterState state = client().admin().cluster().prepareState().get().getState(); - String[] watchHistoryIndices = state.metaData().concreteIndices(IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*"); + String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndices(state, IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*"); assertThat(watchHistoryIndices, not(emptyArray())); for (String index : watchHistoryIndices) { IndexRoutingTable routingTable = state.getRoutingTable().index(index); @@ -394,7 +399,7 @@ public abstract class AbstractWatcherIntegrationTests extends ElasticsearchInteg public void run() { // The watch_history index gets created in the background when the first watch is triggered, so we to check first is this index is created and shards are started ClusterState state = client().admin().cluster().prepareState().get().getState(); - String[] watchHistoryIndices = state.metaData().concreteIndices(IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*"); + String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndices(state, IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*"); assertThat(watchHistoryIndices, not(emptyArray())); for (String index : watchHistoryIndices) { IndexRoutingTable routingTable = state.getRoutingTable().index(index); @@ -417,7 +422,7 @@ public abstract class AbstractWatcherIntegrationTests extends ElasticsearchInteg @Override public void run() { ClusterState state = client().admin().cluster().prepareState().get().getState(); - String[] watchHistoryIndices = state.metaData().concreteIndices(IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*"); + String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndices(state, IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*"); assertThat(watchHistoryIndices, not(emptyArray())); for (String index : watchHistoryIndices) { IndexRoutingTable routingTable = state.getRoutingTable().index(index);