Example usage for org.apache.solr.common.cloud ClusterState getCollectionOrNull

List of usage examples for org.apache.solr.common.cloud ClusterState getCollectionOrNull

Introduction

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

Prototype

public DocCollection getCollectionOrNull(String collectionName) 

Source Link

Document

Returns the corresponding DocCollection object for the given collection name if such a collection exists.

Usage

From source file:com.thinkaurelius.titan.diskstorage.solr.Solr5Index.java

License:Apache License

/**
 * Checks if the collection has already been created in Solr.
 *//*from   w w w.j  a  v a  2s . c  o m*/
private static boolean checkIfCollectionExists(CloudSolrClient server, String collection)
        throws KeeperException, InterruptedException {
    ZkStateReader zkStateReader = server.getZkStateReader();
    zkStateReader.updateClusterState(true);
    ClusterState clusterState = zkStateReader.getClusterState();
    return clusterState.getCollectionOrNull(collection) != null;
}

From source file:org.janusgraph.diskstorage.solr.SolrIndex.java

License:Apache License

/**
 * Checks if the collection has already been created in Solr.
 *///from w  w  w .ja va2s  .co m
private static boolean checkIfCollectionExists(CloudSolrClient server, String collection)
        throws KeeperException, InterruptedException {
    final ZkStateReader zkStateReader = server.getZkStateReader();
    zkStateReader.forceUpdateCollection(collection);
    final ClusterState clusterState = zkStateReader.getClusterState();
    return clusterState.getCollectionOrNull(collection) != null;
}