mirror of https://github.com/apache/lucene.git
SOLR-11061: Add a spins metric for data directory paths.
This commit is contained in:
parent
5a36775d65
commit
d4b4782943
|
@ -134,6 +134,8 @@ Other Changes
|
|||
|
||||
* SOLR-11090: Add Replica.getProperty accessor. (Christine Poerschke)
|
||||
|
||||
* SOLR-11061: Add a spins metric for data directory paths. (ab)
|
||||
|
||||
================== 7.0.0 ==================
|
||||
|
||||
Versions of Major Components
|
||||
|
|
|
@ -568,12 +568,30 @@ public class CoreContainer {
|
|||
true, "usableSpace", SolrInfoBean.Category.CONTAINER.toString(), "fs");
|
||||
metricManager.registerGauge(null, registryName, () -> dataHome.toAbsolutePath().toString(),
|
||||
true, "path", SolrInfoBean.Category.CONTAINER.toString(), "fs");
|
||||
metricManager.registerGauge(null, registryName, () -> {
|
||||
try {
|
||||
return org.apache.lucene.util.IOUtils.spins(dataHome.toAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
// default to spinning
|
||||
return true;
|
||||
}
|
||||
},
|
||||
true, "spins", SolrInfoBean.Category.CONTAINER.toString(), "fs");
|
||||
metricManager.registerGauge(null, registryName, () -> cfg.getCoreRootDirectory().toFile().getTotalSpace(),
|
||||
true, "totalSpace", SolrInfoBean.Category.CONTAINER.toString(), "fs", "coreRoot");
|
||||
metricManager.registerGauge(null, registryName, () -> cfg.getCoreRootDirectory().toFile().getUsableSpace(),
|
||||
true, "usableSpace", SolrInfoBean.Category.CONTAINER.toString(), "fs", "coreRoot");
|
||||
metricManager.registerGauge(null, registryName, () -> cfg.getCoreRootDirectory().toAbsolutePath().toString(),
|
||||
true, "path", SolrInfoBean.Category.CONTAINER.toString(), "fs", "coreRoot");
|
||||
metricManager.registerGauge(null, registryName, () -> {
|
||||
try {
|
||||
return org.apache.lucene.util.IOUtils.spins(cfg.getCoreRootDirectory().toAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
// default to spinning
|
||||
return true;
|
||||
}
|
||||
},
|
||||
true, "spins", SolrInfoBean.Category.CONTAINER.toString(), "fs", "coreRoot");
|
||||
// add version information
|
||||
metricManager.registerGauge(null, registryName, () -> this.getClass().getPackage().getSpecificationVersion(),
|
||||
true, "specification", SolrInfoBean.Category.CONTAINER.toString(), "version");
|
||||
|
|
|
@ -1162,6 +1162,15 @@ public final class SolrCore implements SolrInfoBean, SolrMetricProducer, Closeab
|
|||
File dataDirFile = dataDirPath.toFile();
|
||||
manager.registerGauge(this, registry, () -> dataDirFile.getTotalSpace(), true, "totalSpace", Category.CORE.toString(), "fs");
|
||||
manager.registerGauge(this, registry, () -> dataDirFile.getUsableSpace(), true, "usableSpace", Category.CORE.toString(), "fs");
|
||||
manager.registerGauge(this, registry, () -> dataDirPath.toAbsolutePath().toString(), true, "fs", "dataDir");
|
||||
manager.registerGauge(this, registry, () -> {
|
||||
try {
|
||||
return org.apache.lucene.util.IOUtils.spins(dataDirPath.toAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
// default to spinning
|
||||
return true;
|
||||
}
|
||||
}, true, "spins", Category.CORE.toString(), "fs", "dataDir");
|
||||
}
|
||||
|
||||
private void checkVersionFieldExistsInSchema(IndexSchema schema, CoreDescriptor coreDescriptor) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.codahale.metrics.Metric;
|
|||
import com.codahale.metrics.MetricRegistry;
|
||||
import com.codahale.metrics.Timer;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.core.CoreContainer;
|
||||
|
@ -166,12 +167,23 @@ public class SolrMetricsIntegrationTest extends SolrTestCaseJ4 {
|
|||
assertTrue(metrics.containsKey("CONTAINER.fs.totalSpace"));
|
||||
assertTrue(metrics.containsKey("CONTAINER.fs.usableSpace"));
|
||||
assertTrue(metrics.containsKey("CONTAINER.fs.path"));
|
||||
assertTrue(metrics.containsKey("CONTAINER.fs.spins"));
|
||||
assertTrue(metrics.containsKey("CONTAINER.fs.coreRoot.totalSpace"));
|
||||
assertTrue(metrics.containsKey("CONTAINER.fs.coreRoot.usableSpace"));
|
||||
assertTrue(metrics.containsKey("CONTAINER.fs.coreRoot.path"));
|
||||
assertTrue(metrics.containsKey("CONTAINER.fs.coreRoot.spins"));
|
||||
assertTrue(metrics.containsKey("CONTAINER.version.specification"));
|
||||
assertTrue(metrics.containsKey("CONTAINER.version.implementation"));
|
||||
Gauge<?> g = (Gauge<?>)metrics.get("CONTAINER.fs.path");
|
||||
assertEquals(g.getValue(), cc.getResourceLoader().getInstancePath().toAbsolutePath().toString());
|
||||
boolean spins = IOUtils.spins(cc.getCoreRootDirectory());
|
||||
g = (Gauge<?>)metrics.get("CONTAINER.fs.coreRoot.spins");
|
||||
g = (Gauge<?>)metrics.get("CONTAINER.fs.coreRoot.spins");
|
||||
assertEquals(spins, g.getValue());
|
||||
if (cc.getConfig().getSolrDataHome() != null) {
|
||||
spins = IOUtils.spins(cc.getConfig().getSolrDataHome());
|
||||
g = (Gauge<?>)metrics.get("CONTAINER.fs.spins");
|
||||
assertEquals(spins, g.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue