org.elasticsearch.action.admin.cluster.state.ClusterStateRequestBuilder Java Examples

The following examples show how to use org.elasticsearch.action.admin.cluster.state.ClusterStateRequestBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListSfsIndexes.java    From sfs with Apache License 2.0 6 votes vote down vote up
@Override
public Observable<String> call(Void aVoid) {
    Elasticsearch elasticsearch = vertxContext.verticle().elasticsearch();

    ClusterStateRequestBuilder request =
            elasticsearch.get()
                    .admin()
                    .cluster()
                    .prepareState();
    return elasticsearch.execute(vertxContext, request, elasticsearch.getDefaultAdminTimeout())
            .map(Optional::get)
            .flatMap(clusterStateResponse -> {
                ClusterState state = clusterStateResponse.getState();
                MetaData metadata = state.getMetaData();
                return from(toArray(metadata.getIndices().keysIt(), String.class));
            })
            .filter(s -> s.startsWith(elasticsearch.indexPrefix()));
}
 
Example #2
Source File: BaseTransportClient.java    From elasticsearch-helper with Apache License 2.0 6 votes vote down vote up
protected boolean connect(Collection<InetSocketTransportAddress> addresses, boolean autodiscover) {
    logger.info("trying to connect to {}", addresses);
    client.addTransportAddresses(addresses);
    if (client.connectedNodes() != null) {
        List<DiscoveryNode> nodes = client.connectedNodes();
        if (!nodes.isEmpty()) {
            logger.info("connected to {}", nodes);
            if (autodiscover) {
                logger.info("trying to auto-discover all cluster nodes...");
                ClusterStateRequestBuilder clusterStateRequestBuilder =
                        new ClusterStateRequestBuilder(client, ClusterStateAction.INSTANCE);
                ClusterStateResponse clusterStateResponse = clusterStateRequestBuilder.execute().actionGet();
                DiscoveryNodes discoveryNodes = clusterStateResponse.getState().getNodes();
                client.addDiscoveryNodes(discoveryNodes);
                logger.info("after auto-discovery connected to {}", client.connectedNodes());
            }
            return true;
        }
        return false;
    }
    return false;
}
 
Example #3
Source File: EsUpdateSettingsTest.java    From io with Apache License 2.0 5 votes vote down vote up
private String getNumberOfReplicas(TransportClient client, String key) {
    ClusterStateRequestBuilder request = client.admin().cluster().prepareState();
    ClusterStateResponse response = request.setIndices(index.getName()).execute().actionGet();
    Settings retrievedSettings = response.getState().getMetaData().index(index.getName()).getSettings();
    String numberOfReplicas = retrievedSettings.get(key);
    return numberOfReplicas;
}
 
Example #4
Source File: EsUpdateSettingsTest.java    From io with Apache License 2.0 5 votes vote down vote up
private String getNumberOfReplicas(TransportClient client, String key) {
    ClusterStateRequestBuilder request = client.admin().cluster().prepareState();
    ClusterStateResponse response = request.setIndices(index.getName()).execute().actionGet();
    Settings retrievedSettings = response.getState().getMetaData().index(index.getName()).getSettings();
    String numberOfReplicas = retrievedSettings.get(key);
    return numberOfReplicas;
}
 
Example #5
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public ClusterStateRequestBuilder prepareState() {
    return new ClusterStateRequestBuilder(this, ClusterStateAction.INSTANCE);
}
 
Example #6
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public ClusterStateRequestBuilder prepareState() {
    return new ClusterStateRequestBuilder(this, ClusterStateAction.INSTANCE);
}
 
Example #7
Source File: ClusterAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * The state of the cluster.
 */
ClusterStateRequestBuilder prepareState();
 
Example #8
Source File: ClusterAdminClient.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * The state of the cluster.
 */
ClusterStateRequestBuilder prepareState();