Example usage for org.apache.solr.client.solrj.impl CloudSolrClient getClusterStateProvider

List of usage examples for org.apache.solr.client.solrj.impl CloudSolrClient getClusterStateProvider

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.impl CloudSolrClient getClusterStateProvider.

Prototype

public ClusterStateProvider getClusterStateProvider() 

Source Link

Usage

From source file:com.nridge.ds.solr.SolrDS.java

License:Open Source License

/**
 * Convenience method that provides access to the Zookeeper client cluster state
 * instance managed by the CloudSolrClient.
 *
 * <b>NOTE:</b> This method will fail if the SolrClient is not based on a SolrCloud cluster.
 *
 * @return ZkClientClusterStateProvider Zookeeper client cluster state provider.
 *
 * @throws DSException Data source exception.
 *//*w  ww  .  j  a va 2 s.c  o m*/
public ZkClientClusterStateProvider getZkClusterStateProvider() throws DSException {
    initialize();

    if (mSolrClient instanceof CloudSolrClient) {
        CloudSolrClient cloudSolrClient = (CloudSolrClient) mSolrClient;
        ClusterStateProvider clusterStateProvider = cloudSolrClient.getClusterStateProvider();
        if (clusterStateProvider instanceof ZkClientClusterStateProvider) {
            ZkClientClusterStateProvider zkClientClusterStateProvider = (ZkClientClusterStateProvider) clusterStateProvider;
            return zkClientClusterStateProvider;
        }
    }

    return null;
}