diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 20dd46939ca..bb3af3ceaa1 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -219,6 +219,8 @@ Bug Fixes * SOLR-8104: Config API does not work for spellchecker (noble) +* SOLR-8095: Allow disabling HDFS Locality Metrics and disable by default as it may have performance + implications on rapidly changing indexes. (Mike Drob via Mark Miller) Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java index 64213552aba..a67338b0a1a 100644 --- a/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java +++ b/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java @@ -81,7 +81,9 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory implements Sol public static final String NRTCACHINGDIRECTORY_MAXMERGESIZEMB = "solr.hdfs.nrtcachingdirectory.maxmergesizemb"; public static final String NRTCACHINGDIRECTORY_MAXCACHEMB = "solr.hdfs.nrtcachingdirectory.maxcachedmb"; public static final String NUMBEROFBLOCKSPERBANK = "solr.hdfs.blockcache.blocksperbank"; - + + public static final String LOCALITYMETRICS_ENABLED = "solr.hdfs.locality.metrics.enabled"; + public static final String KERBEROS_ENABLED = "solr.hdfs.security.kerberos.enabled"; public static final String KERBEROS_KEYTAB = "solr.hdfs.security.kerberos.keytabfile"; public static final String KERBEROS_PRINCIPAL = "solr.hdfs.security.kerberos.principal"; @@ -219,8 +221,9 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory implements Sol hdfsDir = new HdfsDirectory(new Path(path), lockFactory, conf); dir = hdfsDir; } - - LocalityHolder.reporter.registerDirectory(hdfsDir); + if (params.getBool(LOCALITYMETRICS_ENABLED, false)) { + LocalityHolder.reporter.registerDirectory(hdfsDir); + } boolean nrtCachingDirectory = getConfig(NRTCACHINGDIRECTORY_ENABLE, true); if (nrtCachingDirectory) { diff --git a/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java b/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java index 443f775aa89..b44eb9b0421 100644 --- a/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java +++ b/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java @@ -187,6 +187,7 @@ public class HdfsDirectoryFactoryTest extends SolrTestCaseJ4 { props.put(HdfsDirectoryFactory.HDFS_HOME, HdfsTestUtil.getURI(dfsCluster) + "/solr"); props.put(HdfsDirectoryFactory.BLOCKCACHE_ENABLED, "false"); props.put(HdfsDirectoryFactory.NRTCACHINGDIRECTORY_ENABLE, "false"); + props.put(HdfsDirectoryFactory.LOCALITYMETRICS_ENABLED, "true"); factory.init(new NamedList<>(props)); Iterator it = factory.offerMBeans().iterator();