Example usage for org.apache.solr.client.solrj.response LukeResponse getIndexInfo

List of usage examples for org.apache.solr.client.solrj.response LukeResponse getIndexInfo

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.response LukeResponse getIndexInfo.

Prototype

public NamedList<Object> getIndexInfo() 

Source Link

Usage

From source file:net.yacy.cora.federate.solr.connector.SolrServerConnector.java

License:Open Source License

/**
 * get the number of segments.//  w  w  w. j a v a  2s  .c o  m
 * @return the number of segments, or 0 if unknown
 */
@Override
public int getSegmentCount() {
    if (this.server == null)
        return 0;
    try {
        LukeResponse lukeResponse = getIndexBrowser(false);
        NamedList<Object> info = lukeResponse.getIndexInfo();
        if (info == null)
            return 0;
        Integer segmentCount = (Integer) info.get("segmentCount");
        if (segmentCount == null)
            return 1;
        return segmentCount.intValue();
    } catch (final Throwable e) {
        clearCaches(); // prevent further OOM if this was caused by OOM
        log.warn(e);
        return 0;
    }
}