Java Code Examples for org.elasticsearch.action.admin.cluster.state.ClusterStateAction#INSTANCE

The following examples show how to use org.elasticsearch.action.admin.cluster.state.ClusterStateAction#INSTANCE . 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: 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 2
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 3
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);
}