lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Development Team <dev.and...@gmail.com>
Subject Problem getting Solr statistics
Date Tue, 16 Jun 2009 18:42:25 GMT
Hi all,
     I am stumped trying to get statistics from the Solr server. It seems
that every time I get the correct SolrInfoMBean, when I look up the proper
value (by name) in the NamedList, I get the exact same number back each
time. For example, upon start-up the server reports that "2" queries have
been performed, and any time I pull the value out of the MBean after that it
says "2" even though the stats.jsp reports an increasing number of queries
over time. What am I doing wrong?
     Here is my sample code:

public class SolrUtil {

  protected static final CoreContainer coreContainer;
  protected static final String DEFAULT_CORE_NAME = "";

  static {
    CoreContainer.Initializer initializer = new CoreContainer.Initializer();
    try {
      coreContainer = initializer.initialize();
    }
    catch (Exception e) {
      throw new ExceptionInInitializerError("Can't initialize core
container: " + e.getMessage());
    }
    initialize();
  }

  private static SolrCore getCore() {
    return getCore(DEFAULT_CORE_NAME);
  }

  private static SolrCore getCore(String name) {
    try {
      return coreContainer.getCore(name);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }

  public static String getSolrInfoMBeanValue(SolrInfoMBean.Category
category, String entryName, String statName) {
    Map<String, SolrInfoMBean> registry = getCore().getInfoRegistry();
    for (Map.Entry<String, SolrInfoMBean> entry : registry.entrySet()) {
      String key = entry.getKey();
      SolrInfoMBean solrInfoMBean = entry.getValue();
      if ((solrInfoMBean.getCategory() != category) ||
          (!entryName.equals(key.trim()))) {
        continue;
      }
      NamedList<?> nl = solrInfoMBean.getStatistics();
      if ((nl != null) && (nl.size() > 0)) {
        for (int i = 0; i < nl.size(); i++) {
          if (nl.getName(i).equals(statName)) {
            return nl.getVal(i).toString();
          }
        }
      }
    }
    return null;
  }

  [...I have other methods, that also get the value as a long, etc....]

}



     This code is modeled after the SolrDispatchFilter.java, _info.jsp and
stats.jsp.
     I'd appreciate any help. (And yes, my core is named "".)

Sincerely,

     Daryl.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message