use of com.codahale.metrics.Metric 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.Metric in project lucene-solr by apache.
the class MetricUtils method convertMetrics.
/**
* Convert selected metrics from a registry into maps (when <code>compact==false</code>) or
* flattened objects.
* @param registry registry
* @param names metric names
* @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.
* @param skipAggregateValues discard internal values of {@link AggregateMetric}-s.
* @param compact use compact representation for counters and gauges.
* @param simple use simplified representation for complex metrics - instead of a (name, map)
* only the selected (name "." key, value) pairs will be produced.
* @param consumer consumer that accepts produced objects
*/
public static void convertMetrics(MetricRegistry registry, Collection<String> names, boolean skipHistograms, boolean skipAggregateValues, boolean compact, boolean simple, BiConsumer<String, Object> consumer) {
final Map<String, Metric> metrics = registry.getMetrics();
names.stream().forEach(n -> {
Metric metric = metrics.get(n);
convertMetric(n, metric, PropertyFilter.ALL, skipHistograms, skipAggregateValues, compact, simple, consumer);
});
}
use of com.codahale.metrics.Metric in project lucene-solr by apache.
the class OperatingSystemMetricSet method getMetrics.
@Override
public Map<String, Metric> getMetrics() {
final Map<String, Metric> metrics = new HashMap<>();
OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
MetricUtils.addMXBeanMetrics(os, MetricUtils.OS_MXBEAN_CLASSES, null, (k, v) -> {
if (!metrics.containsKey(k)) {
metrics.put(k, v);
}
});
return metrics;
}
Aggregations