Example usage for org.apache.solr.common.cloud ZkStateReader ZkStateReader

List of usage examples for org.apache.solr.common.cloud ZkStateReader ZkStateReader

Introduction

In this page you can find the example usage for org.apache.solr.common.cloud ZkStateReader ZkStateReader.

Prototype

public ZkStateReader(SolrZkClient zkClient) 

Source Link

Usage

From source file:uk.bl.wa.apache.solr.hadoop.ZooKeeperInspector.java

License:Apache License

public DocCollection extractDocCollection(String zkHost, String collection) {
    if (collection == null) {
        throw new IllegalArgumentException("collection must not be null");
    }/*ww w  .j a v a  2 s .co m*/
    SolrZkClient zkClient = getZkClient(zkHost);

    try {
        ZkStateReader zkStateReader = new ZkStateReader(zkClient);
        try {
            // first check for alias
            collection = checkForAlias(zkClient, collection);
            zkStateReader.createClusterStateWatchersAndUpdate();
        } catch (Exception e) {
            throw new IllegalArgumentException(
                    "Cannot find expected information for SolrCloud in ZooKeeper: " + zkHost, e);
        }

        try {
            return zkStateReader.getClusterState().getCollection(collection);
        } catch (SolrException e) {
            throw new IllegalArgumentException(
                    "Cannot find collection '" + collection + "' in ZooKeeper: " + zkHost, e);
        }
    } finally {
        zkClient.close();
    }
}