Search in sources :

Example 21 with ClusterStateRequest

use of org.elasticsearch.action.admin.cluster.state.ClusterStateRequest in project graylog2-server by Graylog2.

the class Indices method getClosedIndices.

public Set<String> getClosedIndices(final IndexSet indexSet) {
    final Set<String> closedIndices = Sets.newHashSet();
    ClusterStateRequest csr = new ClusterStateRequest().nodes(false).routingTable(false).blocks(false).metaData(true);
    ClusterState state = c.admin().cluster().state(csr).actionGet().getState();
    UnmodifiableIterator<IndexMetaData> it = state.getMetaData().getIndices().valuesIt();
    while (it.hasNext()) {
        IndexMetaData indexMeta = it.next();
        // Only search in our indices.
        if (!indexMeta.getIndex().startsWith(indexSet.getIndexPrefix())) {
            continue;
        }
        if (indexMeta.getState().equals(IndexMetaData.State.CLOSE)) {
            closedIndices.add(indexMeta.getIndex());
        }
    }
    return closedIndices;
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData)

Aggregations

ClusterStateRequest (org.elasticsearch.action.admin.cluster.state.ClusterStateRequest)21 ClusterStateResponse (org.elasticsearch.action.admin.cluster.state.ClusterStateResponse)17 Settings (org.elasticsearch.common.settings.Settings)14 NodeClient (org.elasticsearch.client.node.NodeClient)12 RestController (org.elasticsearch.rest.RestController)12 RestRequest (org.elasticsearch.rest.RestRequest)12 RestResponse (org.elasticsearch.rest.RestResponse)12 Table (org.elasticsearch.common.Table)10 GET (org.elasticsearch.rest.RestRequest.Method.GET)10 RestResponseListener (org.elasticsearch.rest.action.RestResponseListener)10 ClusterState (org.elasticsearch.cluster.ClusterState)9 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)8 RestActionListener (org.elasticsearch.rest.action.RestActionListener)8 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)7 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)7 Strings (org.elasticsearch.common.Strings)7 Set (java.util.Set)5 Map (java.util.Map)4 NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)4 NodesInfoRequest (org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest)4