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());
}
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>");
}
Aggregations