use of org.apache.solr.metrics.MetricsMap in project lucene-solr by apache.
the class SuggestComponent method initializeMetrics.
@Override
public void initializeMetrics(SolrMetricManager manager, String registryName, String scope) {
registry = manager.registry(registryName);
manager.registerGauge(this, registryName, () -> ramBytesUsed(), true, "totalSizeInBytes", getCategory().toString(), scope);
MetricsMap suggestersMap = new MetricsMap((detailed, map) -> {
for (Map.Entry<String, SolrSuggester> entry : suggesters.entrySet()) {
SolrSuggester suggester = entry.getValue();
map.put(entry.getKey(), suggester.toString());
}
});
manager.registerGauge(this, registryName, suggestersMap, true, "suggesters", getCategory().toString(), scope);
}
use of org.apache.solr.metrics.MetricsMap in project lucene-solr by apache.
the class SolrFieldCacheBean method initializeMetrics.
@Override
public void initializeMetrics(SolrMetricManager manager, String registryName, String scope) {
registry = manager.registry(registryName);
MetricsMap metricsMap = new MetricsMap((detailed, map) -> {
if (detailed && !disableEntryList && !disableJmxEntryList) {
UninvertingReader.FieldCacheStats fieldCacheStats = UninvertingReader.getUninvertedStats();
String[] entries = fieldCacheStats.info;
map.put("entries_count", entries.length);
map.put("total_size", fieldCacheStats.totalSize);
for (int i = 0; i < entries.length; i++) {
final String entry = entries[i];
map.put("entry#" + i, entry);
}
} else {
map.put("entries_count", UninvertingReader.getUninvertedStatsSize());
}
});
manager.register(this, registryName, metricsMap, true, "fieldCache", Category.CACHE.toString(), scope);
}
use of org.apache.solr.metrics.MetricsMap in project lucene-solr by apache.
the class SolrDispatchFilter method setupJvmMetrics.
private void setupJvmMetrics(CoreContainer coresInit) {
SolrMetricManager metricManager = coresInit.getMetricManager();
final Set<String> hiddenSysProps = coresInit.getConfig().getMetricsConfig().getHiddenSysProps();
try {
String registry = SolrMetricManager.getRegistryName(SolrInfoBean.Group.jvm);
metricManager.registerAll(registry, new AltBufferPoolMetricSet(), true, "buffers");
metricManager.registerAll(registry, new ClassLoadingGaugeSet(), true, "classes");
metricManager.registerAll(registry, new OperatingSystemMetricSet(), true, "os");
metricManager.registerAll(registry, new GarbageCollectorMetricSet(), true, "gc");
metricManager.registerAll(registry, new MemoryUsageGaugeSet(), true, "memory");
// todo should we use CachedThreadStatesGaugeSet instead?
metricManager.registerAll(registry, new ThreadStatesGaugeSet(), true, "threads");
MetricsMap sysprops = new MetricsMap((detailed, map) -> {
System.getProperties().forEach((k, v) -> {
if (!hiddenSysProps.contains(k)) {
map.put(String.valueOf(k), v);
}
});
});
metricManager.registerGauge(null, registry, sysprops, true, "properties", "system");
} catch (Exception e) {
log.warn("Error registering JVM metrics", e);
}
}
use of org.apache.solr.metrics.MetricsMap in project lucene-solr by apache.
the class TestSolr4Spatial2 method testRptWithGeometryField.
@Test
public void testRptWithGeometryField() throws Exception {
//note: fails with "srpt_geohash" because it's not as precise
String fieldName = "srptgeom";
assertU(adoc("id", "0", fieldName, "ENVELOPE(-10, 20, 15, 10)"));
//circle at top-left corner
assertU(adoc("id", "1", fieldName, "BUFFER(POINT(-10 15), 5)"));
// one segment.
assertU(optimize());
assertU(commit());
// Search to the edge but not quite touching the indexed envelope of id=0. It requires geom validation to
// eliminate id=0. id=1 is found and doesn't require validation. cache=false means no query cache.
final SolrQueryRequest sameReq = req("q", "{!cache=false field f=" + fieldName + "}Intersects(ENVELOPE(-20, -10.0001, 30, 15.0001))", "sort", "id asc");
assertJQ(sameReq, "/response/numFound==1", "/response/docs/[0]/id=='1'");
// The tricky thing is verifying the cache works correctly...
MetricsMap cacheMetrics = (MetricsMap) h.getCore().getCoreMetricManager().getRegistry().getMetrics().get("CACHE.searcher.perSegSpatialFieldCache_srptgeom");
assertEquals("1", cacheMetrics.getValue().get("cumulative_inserts").toString());
assertEquals("0", cacheMetrics.getValue().get("cumulative_hits").toString());
// Repeat the query earlier
assertJQ(sameReq, "/response/numFound==1", "/response/docs/[0]/id=='1'");
assertEquals("1", cacheMetrics.getValue().get("cumulative_hits").toString());
assertEquals("1 segment", 1, getSearcher().getRawReader().leaves().size());
// Get key of first leaf reader -- this one contains the match for sure.
Object leafKey1 = getFirstLeafReaderKey();
// add new segment
assertU(adoc("id", "3"));
// sometimes merges (to one seg), sometimes won't
assertU(commit());
// can still find the same document
assertJQ(sameReq, "/response/numFound==1", "/response/docs/[0]/id=='1'");
// When there are new segments, we accumulate another hit. This tests the cache was not blown away on commit.
// Checking equality for the first reader's cache key indicates wether the cache should still be valid.
Object leafKey2 = getFirstLeafReaderKey();
assertEquals(leafKey1.equals(leafKey2) ? "2" : "1", cacheMetrics.getValue().get("cumulative_hits").toString());
// Now try to see if heatmaps work:
assertJQ(req("q", "*:*", "facet", "true", FacetParams.FACET_HEATMAP, fieldName, "json.nl", "map"), "/facet_counts/facet_heatmaps/" + fieldName + "/minX==-180.0");
}
use of org.apache.solr.metrics.MetricsMap in project lucene-solr by apache.
the class ReplicationHandler method initializeMetrics.
@Override
public void initializeMetrics(SolrMetricManager manager, String registry, String scope) {
super.initializeMetrics(manager, registry, scope);
manager.registerGauge(this, registry, () -> core != null ? NumberUtils.readableSize(core.getIndexSize()) : "", true, "indexSize", getCategory().toString(), scope);
manager.registerGauge(this, registry, () -> (core != null && !core.isClosed() ? getIndexVersion().toString() : ""), true, "indexVersion", getCategory().toString(), scope);
manager.registerGauge(this, registry, () -> (core != null && !core.isClosed() ? getIndexVersion().generation : 0), true, GENERATION, getCategory().toString(), scope);
manager.registerGauge(this, registry, () -> core != null ? core.getIndexDir() : "", true, "indexPath", getCategory().toString(), scope);
manager.registerGauge(this, registry, () -> isMaster, true, "isMaster", getCategory().toString(), scope);
manager.registerGauge(this, registry, () -> isSlave, true, "isSlave", getCategory().toString(), scope);
final MetricsMap fetcherMap = new MetricsMap((detailed, map) -> {
IndexFetcher fetcher = currentIndexFetcher;
if (fetcher != null) {
map.put(MASTER_URL, fetcher.getMasterUrl());
if (getPollInterval() != null) {
map.put(POLL_INTERVAL, getPollInterval());
}
map.put("isPollingDisabled", isPollingDisabled());
map.put("isReplicating", isReplicating());
long elapsed = fetcher.getReplicationTimeElapsed();
long val = fetcher.getTotalBytesDownloaded();
if (elapsed > 0) {
map.put("timeElapsed", elapsed);
map.put("bytesDownloaded", val);
map.put("downloadSpeed", val / elapsed);
}
Properties props = loadReplicationProperties();
addVal(map, IndexFetcher.PREVIOUS_CYCLE_TIME_TAKEN, props, Long.class);
addVal(map, IndexFetcher.INDEX_REPLICATED_AT, props, Date.class);
addVal(map, IndexFetcher.CONF_FILES_REPLICATED_AT, props, Date.class);
addVal(map, IndexFetcher.REPLICATION_FAILED_AT, props, Date.class);
addVal(map, IndexFetcher.TIMES_FAILED, props, Integer.class);
addVal(map, IndexFetcher.TIMES_INDEX_REPLICATED, props, Integer.class);
addVal(map, IndexFetcher.LAST_CYCLE_BYTES_DOWNLOADED, props, Long.class);
addVal(map, IndexFetcher.TIMES_CONFIG_REPLICATED, props, Integer.class);
addVal(map, IndexFetcher.CONF_FILES_REPLICATED, props, String.class);
}
});
manager.registerGauge(this, registry, fetcherMap, true, "fetcher", getCategory().toString(), scope);
manager.registerGauge(this, registry, () -> isMaster && includeConfFiles != null ? includeConfFiles : "", true, "confFilesToReplicate", getCategory().toString(), scope);
manager.registerGauge(this, registry, () -> isMaster ? getReplicateAfterStrings() : Collections.<String>emptyList(), true, REPLICATE_AFTER, getCategory().toString(), scope);
manager.registerGauge(this, registry, () -> isMaster && replicationEnabled.get(), true, "replicationEnabled", getCategory().toString(), scope);
}
Aggregations