Search in sources :

Example 56 with Gauge

use of com.codahale.metrics.Gauge in project lucene-solr by apache.

the class BasicFunctionalityTest method testSomeStuff.

@Test
public void testSomeStuff() throws Exception {
    clearIndex();
    SolrCore core = h.getCore();
    // test that we got the expected config, not just hardcoded defaults
    assertNotNull(core.getRequestHandler("mock"));
    // test stats call
    SolrMetricManager manager = core.getCoreContainer().getMetricManager();
    String registry = core.getCoreMetricManager().getRegistryName();
    Map<String, Metric> metrics = manager.registry(registry).getMetrics();
    assertTrue(metrics.containsKey("CORE.coreName"));
    assertTrue(metrics.containsKey("CORE.refCount"));
    Gauge<Number> g = (Gauge<Number>) metrics.get("CORE.refCount");
    assertTrue(g.getValue().intValue() > 0);
    lrf.args.put(CommonParams.VERSION, "2.2");
    assertQ("test query on empty index", req("qlkciyopsbgzyvkylsjhchghjrdf"), "//result[@numFound='0']");
    // test escaping of ";"
    assertU("deleting 42 for no reason at all", delI("42"));
    assertU("adding doc#42", adoc("id", "42", "val_s", "aa;bb"));
    assertU("does commit work?", commit());
    assertQ("backslash escaping semicolon", req("id:42 AND val_s:aa\\;bb"), "//*[@numFound='1']", "//int[@name='id'][.='42']");
    assertQ("quote escaping semicolon", req("id:42 AND val_s:\"aa;bb\""), "//*[@numFound='1']", "//int[@name='id'][.='42']");
    assertQ("no escaping semicolon", req("id:42 AND val_s:aa"), "//*[@numFound='0']");
    assertU(delI("42"));
    assertU(commit());
    assertQ(req("id:42"), "//*[@numFound='0']");
    // test overwrite default of true
    assertU(adoc("id", "42", "val_s", "AAA"));
    assertU(adoc("id", "42", "val_s", "BBB"));
    assertU(commit());
    assertQ(req("id:42"), "//*[@numFound='1']", "//str[.='BBB']");
    assertU(adoc("id", "42", "val_s", "CCC"));
    assertU(adoc("id", "42", "val_s", "DDD"));
    assertU(commit());
    assertQ(req("id:42"), "//*[@numFound='1']", "//str[.='DDD']");
    // test deletes
    String[] adds = new String[] { add(doc("id", "101"), "overwrite", "true"), add(doc("id", "101"), "overwrite", "true"), add(doc("id", "105"), "overwrite", "false"), add(doc("id", "102"), "overwrite", "true"), add(doc("id", "103"), "overwrite", "false"), add(doc("id", "101"), "overwrite", "true") };
    for (String a : adds) {
        assertU(a, a);
    }
    assertU(commit());
    // test maxint
    assertQ(req("q", "id:[100 TO 110]", "rows", "2147483647"), "//*[@numFound='4']");
    // test big limit
    assertQ(req("q", "id:[100 TO 111]", "rows", "1147483647"), "//*[@numFound='4']");
    assertQ(req("id:[100 TO 110]"), "//*[@numFound='4']");
    assertU(delI("102"));
    assertU(commit());
    assertQ(req("id:[100 TO 110]"), "//*[@numFound='3']");
    assertU(delI("105"));
    assertU(commit());
    assertQ(req("id:[100 TO 110]"), "//*[@numFound='2']");
    assertU(delQ("id:[100 TO 110]"));
    assertU(commit());
    assertQ(req("id:[100 TO 110]"), "//*[@numFound='0']");
    assertU(h.simpleTag("rollback"));
    assertU(commit());
}
Also used : SolrCore(org.apache.solr.core.SolrCore) SolrMetricManager(org.apache.solr.metrics.SolrMetricManager) Metric(com.codahale.metrics.Metric) Gauge(com.codahale.metrics.Gauge) Test(org.junit.Test)

Example 57 with Gauge

use of com.codahale.metrics.Gauge in project sling by apache.

the class MetricWebConsolePlugin method addGaugeDetails.

private void addGaugeDetails(PrintWriter pw, SortedMap<String, Gauge> gauges) {
    if (gauges.isEmpty()) {
        return;
    }
    pw.println("<br>");
    pw.println("<div class='table'>");
    pw.println("<div class='ui-widget-header ui-corner-top buttonGroup'>Gauges</div>");
    pw.println("<table class='nicetable' id='data-gauges'>");
    pw.println("<thead>");
    pw.println("<tr>");
    pw.println("<th class='header'>Name</th>");
    pw.println("<th class='header'>Value</th>");
    pw.println("</tr>");
    pw.println("</thead>");
    pw.println("<tbody>");
    String rowClass = "odd";
    for (Map.Entry<String, Gauge> e : gauges.entrySet()) {
        Gauge g = e.getValue();
        String name = e.getKey();
        pw.printf("<tr class='%s ui-state-default'>%n", rowClass);
        pw.printf("<td>%s</td>", name);
        pw.printf("<td>%s</td>", g.getValue());
        pw.println("</tr>");
        rowClass = "odd".equals(rowClass) ? "even" : "odd";
    }
    pw.println("</tbody>");
    pw.println("</table>");
    pw.println("</div>");
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SortedMap(java.util.SortedMap) Gauge(com.codahale.metrics.Gauge)

Aggregations

Gauge (com.codahale.metrics.Gauge)57 Test (org.junit.Test)38 Counter (com.codahale.metrics.Counter)10 Meter (com.codahale.metrics.Meter)8 Metric (com.codahale.metrics.Metric)8 Timer (com.codahale.metrics.Timer)7 SortedMap (java.util.SortedMap)7 Histogram (com.codahale.metrics.Histogram)6 MetricRegistry (com.codahale.metrics.MetricRegistry)6 Map (java.util.Map)6 Matchers.anyString (org.mockito.Matchers.anyString)3 Snapshot (com.codahale.metrics.Snapshot)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 Semaphore (java.util.concurrent.Semaphore)2 SolrMetricManager (org.apache.solr.metrics.SolrMetricManager)2 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)2 AsmGauge (com.alibaba.jstorm.common.metric.AsmGauge)1 MetricSet (com.codahale.metrics.MetricSet)1