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

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

Introduction

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

Prototype

public synchronized void createClusterStateWatchersAndUpdate() throws KeeperException, InterruptedException 

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");
    }/*  w  w  w .  java 2s .com*/
    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();
    }
}