Search in sources :

Example 1 with IndicesStatusRequestBuilder

use of org.elasticsearch.action.admin.indices.status.IndicesStatusRequestBuilder in project bw-calendar-engine by Bedework.

the class BwIndexEsImpl method getIndexInfo.

@Override
public Set<IndexInfo> getIndexInfo() throws CalFacadeException {
    final Set<IndexInfo> res = new TreeSet<>();
    try {
        final IndicesAdminClient idx = getAdminIdx();
        final IndicesStatusRequestBuilder isrb = idx.prepareStatus(Strings.EMPTY_ARRAY);
        final ActionFuture<IndicesStatusResponse> sr = idx.status(isrb.request());
        final IndicesStatusResponse sresp = sr.actionGet();
        for (final String inm : sresp.getIndices().keySet()) {
            final IndexInfo ii = new IndexInfo(inm);
            res.add(ii);
            final ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest().routingTable(true).nodes(true).indices(inm);
            final Iterator<String> it = getAdminCluster().state(clusterStateRequest).actionGet().getState().getMetaData().aliases().keysIt();
            while (it.hasNext()) {
                ii.addAlias(it.next());
            }
        }
        return res;
    } catch (final Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : IndicesStatusRequestBuilder(org.elasticsearch.action.admin.indices.status.IndicesStatusRequestBuilder) TreeSet(java.util.TreeSet) ClusterStateRequest(org.elasticsearch.action.admin.cluster.state.ClusterStateRequest) IndicesStatusResponse(org.elasticsearch.action.admin.indices.status.IndicesStatusResponse) IndicesAdminClient(org.elasticsearch.client.IndicesAdminClient) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

TreeSet (java.util.TreeSet)1 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)1 ClusterStateRequest (org.elasticsearch.action.admin.cluster.state.ClusterStateRequest)1 IndicesStatusRequestBuilder (org.elasticsearch.action.admin.indices.status.IndicesStatusRequestBuilder)1 IndicesStatusResponse (org.elasticsearch.action.admin.indices.status.IndicesStatusResponse)1 IndicesAdminClient (org.elasticsearch.client.IndicesAdminClient)1