Apache Solr open-source search software
SOLR-10182 Remove metrics collection at Directory level.
Andrzej Bialeckia248e6e3c080
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 546b484b9da..99a0a4225f7 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -270,9 +270,10 @@ Detailed Change ListBug Fixes-----------------------* SOLR-10130: Serious performance degradation in Solr 6.4.1 due to the new metrics collection.+* SOLR-10130, SOLR-10182: Serious performance degradation in Solr 6.4.1 due to the new metrics collection.Default settings in solrconfig.xml /config/indexConfig/metrics have been changed to turn off- IndexWriter and Directory level metrics collection. (ab, ishan)+ IndexWriter metrics collection. Directory level metrics collection has been completely removed until+ a better design is found. (ab, ishan)* SOLR-10138: Transaction log replay can hit an NPE due to new Metrics code. (ab)diff --git a/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/DirectoryFactory.javaindex e4f0c5eaf90..cc24e6c6ab3 100644--- a/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java+++ b/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java@@ -411,13 +411,6 @@ public abstract class DirectoryFactory implements NamedListInitializedPlugin,dirFactory = new NRTCachingDirectoryFactory();dirFactory.initCoreContainer(cc);}- if (config.indexConfig.metricsInfo != null && config.indexConfig.metricsInfo.isEnabled()) {- final DirectoryFactory factory = new MetricsDirectoryFactory(cc.getMetricManager(),- registryName, dirFactory);- factory.init(config.indexConfig.metricsInfo.initArgs);- return factory;- } else {- return dirFactory;- }+ return dirFactory;}}diff --git a/solr/core/src/java/org/apache/solr/core/MetricsDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/MetricsDirectoryFactory.javadeleted file mode 100644index b38c86f82d7..00000000000--- a/solr/core/src/java/org/apache/solr/core/MetricsDirectoryFactory.java+++ /dev/null@@ -1,537 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-package org.apache.solr.core;--import java.io.IOException;-import java.util.Collection;--import com.codahale.metrics.Histogram;-import com.codahale.metrics.Meter;-import org.apache.lucene.store.Directory;-import org.apache.lucene.store.FilterDirectory;-import org.apache.lucene.store.IOContext;-import org.apache.lucene.store.IndexInput;-import org.apache.lucene.store.IndexOutput;-import org.apache.lucene.store.LockFactory;-import org.apache.solr.common.util.NamedList;-import org.apache.solr.metrics.SolrMetricManager;-import org.apache.solr.util.plugin.SolrCoreAware;--/**- * An implementation of {@link DirectoryFactory} that decorates provided factory by- * adding metrics for directory IO operations.- */-public class MetricsDirectoryFactory extends DirectoryFactory implements SolrCoreAware {- private final SolrMetricManager metricManager;- private final String registry;- private final DirectoryFactory in;- private boolean directoryDetails = false;- private boolean directoryTotals = false;-- public MetricsDirectoryFactory(SolrMetricManager metricManager, String registry, DirectoryFactory in) {- this.metricManager = metricManager;- this.registry = registry;- this.in = in;- }-- public DirectoryFactory getDelegate() {- return in;- }-- /**- * Currently the following arguments are supported:- * <ul>- * <li><code>directory</code> - (optional bool, default false) when true then coarse-grained metrics will be collected.</li>- * <li><code>directoryDetails</code> - (optional bool, default false) when true then additional detailed metrics- * will be collected. These include eg. IO size histograms and per-file counters and histograms</li>- * </ul>- * NOTE: please be aware that collecting even coarse-grained metrics can have significant performance impact- * (see SOLR-10130).- * @param args init args- */- @Override- public void init(NamedList args) {- // should be already inited- // in.init(args);- if (args == null) {- return;- }- Boolean td = args.getBooleanArg("directory");- if (td != null) {- directoryTotals = td;- } else {- directoryTotals = false;- }- Boolean dd = args.getBooleanArg("directoryDetails");- if (dd != null) {- directoryDetails = dd;- } else {- directoryDetails = false;- }- if (directoryDetails) {- directoryTotals = true;- }- }-- /**- * Unwrap just one level if the argument is a {@link MetricsDirectory}- * @param dir directory- * @return delegate if the instance was a {@link MetricsDirectory}, otherwise unchanged.- */- private static Directory unwrap(Directory dir) {- if (dir instanceof MetricsDirectory) {- return ((MetricsDirectory)dir).getDelegate();- } else {- return dir;- }- }-- @Override- public void doneWithDirectory(Directory dir) throws IOException {- dir = unwrap(dir);- in.doneWithDirectory(dir);- }-- @Override- public void addCloseListener(Directory dir, CachingDirectoryFactory.CloseListener closeListener) {- dir = unwrap(dir);- in.addCloseListener(dir, closeListener);- }-- @Override- public void close() throws IOException {- in.close();- }-- @Override- protected Directory create(String path, LockFactory lockFactory, DirContext dirContext) throws IOException {- Directory dir = in.create(path, lockFactory, dirContext);- return new MetricsDirectory(metricManager, registry, dir, directoryTotals, directoryDetails);- }-- @Override- protected LockFactory createLockFactory(String rawLockType) throws IOException {- return in.createLockFactory(rawLockType);- }-- @Override- public boolean exists(String path) throws IOException {- return in.exists(path);- }-- @Override- public void remove(Directory dir) throws IOException {- dir = unwrap(dir);- in.remove(dir);- }-- @Override- public void remove(Directory dir, boolean afterCoreClose) throws IOException {- dir = unwrap(dir);- in.remove(dir, afterCoreClose);- }-- @Override- public boolean isSharedStorage() {- return in.isSharedStorage();- }-- @Override- public boolean isAbsolute(String path) {- return in.isAbsolute(path);- }-- @Override- public boolean searchersReserveCommitPoints() {- return in.searchersReserveCommitPoints();- }-- @Override- public String getDataHome(CoreDescriptor cd) throws IOException {- return in.getDataHome(cd);- }-- @Override- public long size(Directory dir) throws IOException {- dir = unwrap(dir);- return in.size(dir);- }-- @Override- public long size(String path) throws IOException {- return in.size(path);- }-- @Override- public Collection<SolrInfoMBean> offerMBeans() {- return in.offerMBeans();- }-- @Override- public void cleanupOldIndexDirectories(String dataDirPath, String currentIndexDirPath, boolean reload) {- in.cleanupOldIndexDirectories(dataDirPath, currentIndexDirPath, reload);- }-- @Override- public void remove(String path, boolean afterCoreClose) throws IOException {- in.remove(path, afterCoreClose);- }-- @Override- public void remove(String path) throws IOException {- in.remove(path);- }-- @Override- public void move(Directory fromDir, Directory toDir, String fileName, IOContext ioContext) throws IOException {- fromDir = unwrap(fromDir);- toDir = unwrap(toDir);- in.move(fromDir, toDir, fileName, ioContext);- }-- @Override- public Directory get(String path, DirContext dirContext, String rawLockType) throws IOException {- Directory dir = in.get(path, dirContext, rawLockType);- if (dir instanceof MetricsDirectory) {- return dir;- } else {- return new MetricsDirectory(metricManager, registry, dir, directoryTotals, directoryDetails);- }- }-- @Override- public void renameWithOverwrite(Directory dir, String fileName, String toName) throws IOException {- dir = unwrap(dir);- in.renameWithOverwrite(dir, fileName, toName);- }-- @Override- public String normalize(String path) throws IOException {- return in.normalize(path);- }-- @Override- protected boolean deleteOldIndexDirectory(String oldDirPath) throws IOException {- return in.deleteOldIndexDirectory(oldDirPath);- }-- @Override- public void initCoreContainer(CoreContainer cc) {- in.initCoreContainer(cc);- }-- @Override- public void incRef(Directory dir) {- dir = unwrap(dir);- in.incRef(dir);- }-- @Override- public boolean isPersistent() {- return in.isPersistent();- }-- @Override- public void inform(SolrCore core) {- if (in instanceof SolrCoreAware) {- ((SolrCoreAware)in).inform(core);- }- }-- @Override- public void release(Directory dir) throws IOException {- dir = unwrap(dir);- in.release(dir);- }---- private static final String SEGMENTS = "segments";- private static final String SEGMENTS_PREFIX = "segments_";- private static final String PENDING_SEGMENTS_PREFIX = "pending_segments_";- private static final String TEMP = "temp";- private static final String OTHER = "other";-- public static class MetricsDirectory extends FilterDirectory {-- private final Directory in;- private final String registry;- private final SolrMetricManager metricManager;- private final Meter totalReads;- private final Histogram totalReadSizes;- private final Meter totalWrites;- private final Histogram totalWriteSizes;- private final boolean directoryDetails;- private final boolean directoryTotals;-- private final String PREFIX = SolrInfoMBean.Category.DIRECTORY.toString() + ".";-- public MetricsDirectory(SolrMetricManager metricManager, String registry, Directory in, boolean directoryTotals,- boolean directoryDetails) throws IOException {- super(in);- this.metricManager = metricManager;- this.registry = registry;- this.in = in;- this.directoryDetails = directoryDetails;- this.directoryTotals = directoryTotals;- if (directoryTotals) {- this.totalReads = metricManager.meter(registry, "reads", SolrInfoMBean.Category.DIRECTORY.toString(), "total");- this.totalWrites = metricManager.meter(registry, "writes", SolrInfoMBean.Category.DIRECTORY.toString(), "total");- if (directoryDetails) {- this.totalReadSizes = metricManager.histogram(registry, "readSizes", SolrInfoMBean.Category.DIRECTORY.toString(), "total");- this.totalWriteSizes = metricManager.histogram(registry, "writeSizes", SolrInfoMBean.Category.DIRECTORY.toString(), "total");- } else {- this.totalReadSizes = null;- this.totalWriteSizes = null;- }- } else {- this.totalReads = null;- this.totalWrites = null;- this.totalReadSizes = null;- this.totalWriteSizes = null;- }- }-- private String getMetricName(String name, boolean output) {- if (!directoryDetails) {- return null;- }- String lastName;- if (name.startsWith(SEGMENTS_PREFIX) || name.startsWith(PENDING_SEGMENTS_PREFIX)) {- lastName = SEGMENTS;- } else {- int pos = name.lastIndexOf('.');- if (pos != -1 && name.length() > pos + 1) {- lastName = name.substring(pos + 1);- } else {- lastName = OTHER;- }- }- StringBuilder sb = new StringBuilder(PREFIX);- sb.append(lastName);- sb.append('.');- if (output) {- sb.append("write");- } else {- sb.append("read");- }- return sb.toString();- }-- @Override- public IndexOutput createOutput(String name, IOContext context) throws IOException {- IndexOutput output = in.createOutput(name, context);- if (!directoryTotals) {- return output;- }- if (output != null) {- return new MetricsOutput(totalWrites, totalWriteSizes, metricManager, registry, getMetricName(name, true), output);- } else {- return null;- }- }-- @Override- public IndexOutput createTempOutput(String prefix, String suffix, IOContext context) throws IOException {- IndexOutput output = in.createTempOutput(prefix, suffix, context);- if (!directoryTotals) {- return output;- }- if (output != null) {- return new MetricsOutput(totalWrites, totalWriteSizes, metricManager, registry, getMetricName(TEMP, true), output);- } else {- return null;- }- }-- @Override- public IndexInput openInput(String name, IOContext context) throws IOException {- IndexInput input = in.openInput(name, context);- if (!directoryTotals) {- return input;- }- if (input != null) {- return new MetricsInput(totalReads, totalReadSizes, metricManager, registry, getMetricName(name, false), input);- } else {- return null;- }- }- }-- public static class MetricsOutput extends IndexOutput {- private final IndexOutput in;- private final Histogram histogram;- private final Meter meter;- private final Meter totalMeter;- private final Histogram totalHistogram;- private final boolean withDetails;-- public MetricsOutput(Meter totalMeter, Histogram totalHistogram, SolrMetricManager metricManager,- String registry, String metricName, IndexOutput in) {- super(in.toString(), in.getName());- this.in = in;- this.totalMeter = totalMeter;- this.totalHistogram = totalHistogram;- if (metricName != null && totalHistogram != null) {- withDetails = true;- String histName = metricName + "Sizes";- String meterName = metricName + "s";- this.histogram = metricManager.histogram(registry, histName);- this.meter = metricManager.meter(registry, meterName);- } else {- withDetails = false;- this.histogram = null;- this.meter = null;- }- }-- @Override- public void writeByte(byte b) throws IOException {- in.writeByte(b);- totalMeter.mark();- if (withDetails) {- totalHistogram.update(1);- meter.mark();- histogram.update(1);- }- }-- @Override- public void writeBytes(byte[] b, int offset, int length) throws IOException {- in.writeBytes(b, offset, length);- totalMeter.mark(length);- if (withDetails) {- totalHistogram.update(length);- meter.mark(length);- histogram.update(length);- }- }-- @Override- public void close() throws IOException {- in.close();- }-- @Override- public long getFilePointer() {- return in.getFilePointer();- }-- @Override- public long getChecksum() throws IOException {- return in.getChecksum();- }- }-- public static class MetricsInput extends IndexInput {- private final IndexInput in;- private final Meter totalMeter;- private final Histogram totalHistogram;- private final Histogram histogram;- private final Meter meter;- private final boolean withDetails;-- public MetricsInput(Meter totalMeter, Histogram totalHistogram, SolrMetricManager metricManager, String registry, String metricName, IndexInput in) {- super(in.toString());- this.in = in;- this.totalMeter = totalMeter;- this.totalHistogram = totalHistogram;- if (metricName != null && totalHistogram != null) {- withDetails = true;- String histName = metricName + "Sizes";- String meterName = metricName + "s";- this.histogram = metricManager.histogram(registry, histName);- this.meter = metricManager.meter(registry, meterName);- } else {- withDetails = false;- this.histogram = null;- this.meter = null;- }- }-- public MetricsInput(Meter totalMeter, Histogram totalHistogram, Histogram histogram, Meter meter, IndexInput in) {- super(in.toString());- this.in = in;- this.totalMeter = totalMeter;- this.totalHistogram = totalHistogram;- this.histogram = histogram;- this.meter = meter;- if (totalHistogram != null && meter != null && histogram != null) {- withDetails = true;- } else {- withDetails = false;- }- }-- @Override- public void close() throws IOException {- in.close();- }-- @Override- public long getFilePointer() {- return in.getFilePointer();- }-- @Override- public void seek(long pos) throws IOException {- in.seek(pos);- }-- @Override- public long length() {- return in.length();- }-- @Override- public IndexInput clone() {- return new MetricsInput(totalMeter, totalHistogram, histogram, meter, in.clone());- }-- @Override- public IndexInput slice(String sliceDescription, long offset, long length) throws IOException {- IndexInput slice = in.slice(sliceDescription, offset, length);- if (slice != null) {- return new MetricsInput(totalMeter, totalHistogram, histogram, meter, slice);- } else {- return null;- }- }-- @Override- public byte readByte() throws IOException {- totalMeter.mark();- if (withDetails) {- totalHistogram.update(1);- meter.mark();- histogram.update(1);- }- return in.readByte();- }-- @Override- public void readBytes(byte[] b, int offset, int len) throws IOException {- totalMeter.mark(len);- if (withDetails) {- totalHistogram.update(len);- meter.mark(len);- histogram.update(len);- }- in.readBytes(b, offset, len);- }- }-}diff --git a/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java b/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.javaindex eba29646974..34482cd14d4 100644--- a/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java+++ b/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java@@ -114,9 +114,6 @@ public class SolrDeletionPolicy extends IndexDeletionPolicy implements NamedListprotected void appendDetails(StringBuilder sb, IndexCommit c) {Directory dir = c.getDirectory();- if (dir instanceof MetricsDirectoryFactory.MetricsDirectory) { // unwrap- dir = ((MetricsDirectoryFactory.MetricsDirectory) dir).getDelegate();- }if (dir instanceof FSDirectory) {FSDirectory fsd = (FSDirectory) dir;sb.append("dir=").append(fsd.getDirectory());@@ -197,9 +194,6 @@ public class SolrDeletionPolicy extends IndexDeletionPolicy implements NamedListprivate String getId(IndexCommit commit) {StringBuilder sb = new StringBuilder();Directory dir = commit.getDirectory();- if (dir instanceof MetricsDirectoryFactory.MetricsDirectory) { // unwrap- dir = ((MetricsDirectoryFactory.MetricsDirectory) dir).getDelegate();- }// For anything persistent, make something that will// be the same, regardless of the Directory instance.diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexmetrics.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexmetrics.xmlindex 188340d37ee..6cf54d5fcff 100644--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexmetrics.xml+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexmetrics.xml@@ -29,8 +29,6 @@<indexConfig><metrics>- <bool name="directory">${solr.tests.metrics.directory:false}</bool>- <bool name="directoryDetails">${solr.tests.metrics.directoryDetails:false}</bool><bool name="merge">${solr.tests.metrics.merge:false}</bool><bool name="mergeDetails">${solr.tests.metrics.mergeDetails:false}</bool></metrics>diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.javaindex b345342135b..ca85fe057cf 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.java@@ -41,7 +41,6 @@ import org.apache.solr.cloud.StoppableIndexingThread;import org.apache.solr.core.CoreContainer;import org.apache.solr.core.DirectoryFactory;import org.apache.solr.core.HdfsDirectoryFactory;-import org.apache.solr.core.MetricsDirectoryFactory;import org.apache.solr.core.SolrCore;import org.apache.solr.store.blockcache.BlockCache;import org.apache.solr.store.blockcache.BlockDirectory;@@ -137,9 +136,6 @@ public class HdfsWriteToMultipleCollectionsTest extends BasicDistributedZkTest {if (core.getCoreDescriptor().getCloudDescriptor().getCollectionName().startsWith(ACOLLECTION)) {DirectoryFactory factory = core.getDirectoryFactory();- if (factory instanceof MetricsDirectoryFactory) {- factory = ((MetricsDirectoryFactory) factory).getDelegate();- }assertTrue("Found: " + core.getDirectoryFactory().getClass().getName(), factory instanceof HdfsDirectoryFactory);Directory dir = factory.get(core.getDataDir(), null, null);try {@@ -159,8 +155,7 @@ public class HdfsWriteToMultipleCollectionsTest extends BasicDistributedZkTest {.getSolrCoreState().getIndexWriter(core);try {IndexWriter iw = iwRef.get();- NRTCachingDirectory directory = (NRTCachingDirectory) ((MetricsDirectoryFactory.MetricsDirectory)iw- .getDirectory()).getDelegate();+ NRTCachingDirectory directory = (NRTCachingDirectory) iw.getDirectory();BlockDirectory blockDirectory = (BlockDirectory) directory.getDelegate();assertTrue(blockDirectory.isBlockCacheReadEnabled());diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.javaindex 9deb51de825..8148b882d5a 100644--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java@@ -66,8 +66,6 @@ import org.apache.solr.common.params.SolrParams;import org.apache.solr.common.util.NamedList;import org.apache.solr.core.CachingDirectoryFactory;import org.apache.solr.core.CoreContainer;-import org.apache.solr.core.DirectoryFactory;-import org.apache.solr.core.MetricsDirectoryFactory;import org.apache.solr.core.SolrCore;import org.apache.solr.core.StandardDirectoryFactory;import org.apache.solr.core.snapshots.SolrSnapshotMetaDataManager;@@ -923,12 +921,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {}private CachingDirectoryFactory getCachingDirectoryFactory(SolrCore core) {- DirectoryFactory df = core.getDirectoryFactory();- if (df instanceof MetricsDirectoryFactory) {- return (CachingDirectoryFactory)((MetricsDirectoryFactory)df).getDelegate();- } else {- return (CachingDirectoryFactory)df;- }+ return (CachingDirectoryFactory) core.getDirectoryFactory();}private void checkForSingleIndex(JettySolrRunner jetty) {diff --git a/solr/core/src/test/org/apache/solr/handler/admin/CoreMergeIndexesAdminHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/CoreMergeIndexesAdminHandlerTest.javaindex 937cc860ae9..d026ecdeffe 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/CoreMergeIndexesAdminHandlerTest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/CoreMergeIndexesAdminHandlerTest.java@@ -25,7 +25,6 @@ import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.params.CoreAdminParams;import org.apache.solr.core.CoreContainer;import org.apache.solr.core.DirectoryFactory;-import org.apache.solr.core.MetricsDirectoryFactory;import org.apache.solr.core.MockFSDirectoryFactory;import org.apache.solr.core.SolrCore;import org.apache.solr.response.SolrQueryResponse;@@ -78,12 +77,7 @@ public class CoreMergeIndexesAdminHandlerTest extends SolrTestCaseJ4 {try (SolrCore core = cores.getCore("collection1")) {DirectoryFactory df = core.getDirectoryFactory();- FailingDirectoryFactory dirFactory;- if (df instanceof MetricsDirectoryFactory) {- dirFactory = (FailingDirectoryFactory)((MetricsDirectoryFactory)df).getDelegate();- } else {- dirFactory = (FailingDirectoryFactory)df;- }+ FailingDirectoryFactory dirFactory = (FailingDirectoryFactory) df;try {dirFactory.fail = true;diff --git a/solr/core/src/test/org/apache/solr/update/SolrIndexMetricsTest.java b/solr/core/src/test/org/apache/solr/update/SolrIndexMetricsTest.javaindex 39b511d48e7..c9935bb3830 100644--- a/solr/core/src/test/org/apache/solr/update/SolrIndexMetricsTest.java+++ b/solr/core/src/test/org/apache/solr/update/SolrIndexMetricsTest.java@@ -18,7 +18,6 @@ package org.apache.solr.update;import java.util.Map;-import com.codahale.metrics.Histogram;import com.codahale.metrics.Meter;import com.codahale.metrics.Metric;import com.codahale.metrics.MetricRegistry;@@ -59,8 +58,6 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {public void testIndexMetricsNoDetails() throws Exception {System.setProperty("solr.tests.metrics.merge", "true");System.setProperty("solr.tests.metrics.mergeDetails", "false");- System.setProperty("solr.tests.metrics.directory", "true");- System.setProperty("solr.tests.metrics.directoryDetails", "false");initCore("solrconfig-indexmetrics.xml", "schema.xml");addDocs();@@ -71,7 +68,6 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {Map<String, Metric> metrics = registry.getMetrics();assertEquals(10, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("INDEX")).count());- assertEquals(2, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("DIRECTORY")).count());// check basic index metersTimer timer = (Timer)metrics.get("INDEX.merge.minor");@@ -82,30 +78,12 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {assertNull((Meter)metrics.get("INDEX.merge.major.docs"));Meter meter = (Meter)metrics.get("INDEX.flush");assertTrue("flush: " + meter.getCount(), meter.getCount() > 10);-- // check basic directory meters- meter = (Meter)metrics.get("DIRECTORY.total.reads");- assertTrue("totalReads", meter.getCount() > 0);- meter = (Meter)metrics.get("DIRECTORY.total.writes");- assertTrue("totalWrites", meter.getCount() > 0);- // check detailed meters- Histogram histogram = (Histogram)metrics.get("DIRECTORY.total.readSizes");- assertNull("readSizes", histogram);- histogram = (Histogram)metrics.get("DIRECTORY.total.writeSizes");- assertNull("writeSizes", histogram);- meter = (Meter)metrics.get("DIRECTORY.segments.writes");- assertNull("segmentsWrites", meter);- histogram = (Histogram)metrics.get("DIRECTORY.segments.writeSizes");- assertNull("segmentsWriteSizes", histogram);-}@Testpublic void testIndexNoMetrics() throws Exception {System.setProperty("solr.tests.metrics.merge", "false");System.setProperty("solr.tests.metrics.mergeDetails", "false");- System.setProperty("solr.tests.metrics.directory", "false");- System.setProperty("solr.tests.metrics.directoryDetails", "false");initCore("solrconfig-indexmetrics.xml", "schema.xml");addDocs();@@ -115,16 +93,12 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {Map<String, Metric> metrics = registry.getMetrics();assertEquals(0, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("INDEX")).count());- // this is variable, depending on the codec and the number of created files- assertEquals(0, metrics.entrySet().stream().filter(e -> e.getKey().startsWith("DIRECTORY")).count());}@Testpublic void testIndexMetricsWithDetails() throws Exception {System.setProperty("solr.tests.metrics.merge", "false"); // test mergeDetails override tooSystem.setProperty("solr.tests.metrics.mergeDetails", "true");- System.setProperty("solr.tests.metrics.directory", "false");- System.setProperty("solr.tests.metrics.directoryDetails", "true");initCore("solrconfig-indexmetrics.xml", "schema.xml");addDocs();@@ -135,8 +109,6 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {Map<String, Metric> metrics = registry.getMetrics();assertTrue(metrics.entrySet().stream().filter(e -> e.getKey().startsWith("INDEX")).count() >= 12);- // this is variable, depending on the codec and the number of created files- assertTrue(metrics.entrySet().stream().filter(e -> e.getKey().startsWith("DIRECTORY")).count() > 20);// check basic index metersTimer timer = (Timer)metrics.get("INDEX.merge.minor");@@ -149,21 +121,5 @@ public class SolrIndexMetricsTest extends SolrTestCaseJ4 {meter = (Meter)metrics.get("INDEX.flush");assertTrue("flush: " + meter.getCount(), meter.getCount() > 10);-- // check basic directory meters- meter = (Meter)metrics.get("DIRECTORY.total.reads");- assertTrue("totalReads", meter.getCount() > 0);- meter = (Meter)metrics.get("DIRECTORY.total.writes");- assertTrue("totalWrites", meter.getCount() > 0);- // check detailed meters- Histogram histogram = (Histogram)metrics.get("DIRECTORY.total.readSizes");- assertTrue("readSizes", histogram.getCount() > 0);- histogram = (Histogram)metrics.get("DIRECTORY.total.writeSizes");- assertTrue("writeSizes", histogram.getCount() > 0);- meter = (Meter)metrics.get("DIRECTORY.segments.writes");- assertTrue("segmentsWrites", meter.getCount() > 0);- histogram = (Histogram)metrics.get("DIRECTORY.segments.writeSizes");- assertTrue("segmentsWriteSizes", histogram.getCount() > 0);-}}