lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [2/2] lucene-solr:jira/solr-9959: SOLR-9959 Fix assorted bugs and test compilation errors.
Date Wed, 22 Mar 2017 15:49:43 GMT
SOLR-9959 Fix assorted bugs and test compilation errors.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6e8a42b2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6e8a42b2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6e8a42b2

Branch: refs/heads/jira/solr-9959
Commit: 6e8a42b28fc1b9217c0cc8dc6f5b18b575b7f77e
Parents: b94db28
Author: Andrzej Bialecki <ab@apache.org>
Authored: Wed Mar 22 16:49:04 2017 +0100
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Wed Mar 22 16:49:04 2017 +0100

----------------------------------------------------------------------
 .../org/apache/solr/core/DirectoryFactory.java  |   7 --
 .../apache/solr/core/HdfsDirectoryFactory.java  |   9 +-
 .../src/java/org/apache/solr/core/SolrCore.java |  21 ++--
 .../java/org/apache/solr/core/SolrInfoBean.java |   3 +
 .../solr/highlight/DefaultSolrHighlighter.java  |  30 ++++--
 .../solr/highlight/HighlightingPluginBase.java  |   2 +-
 .../solr/metrics/SolrCoreMetricManager.java     |  12 +++
 .../org/apache/solr/search/FastLRUCache.java    |   7 +-
 .../java/org/apache/solr/search/LFUCache.java   |   7 +-
 .../java/org/apache/solr/search/LRUCache.java   |   7 +-
 .../java/org/apache/solr/search/SolrCache.java  |   1 +
 .../apache/solr/search/SolrIndexSearcher.java   |  12 ++-
 .../apache/solr/store/blockcache/Metrics.java   | 105 ++++++++++---------
 .../org/apache/solr/BasicFunctionalityTest.java |  15 ++-
 .../test/org/apache/solr/CursorPagingTest.java  |  21 ++--
 .../test/org/apache/solr/SolrInfoBeanTest.java  |   2 -
 .../solr/cloud/BasicDistributedZkTest.java      |  24 +++--
 .../test/org/apache/solr/cloud/BasicZkTest.java |  14 ++-
 .../cloud/TestRandomRequestDistribution.java    |  19 ++--
 .../solr/core/ExitableDirectoryReaderTest.java  |  25 ++---
 .../solr/core/HdfsDirectoryFactoryTest.java     |  28 ++---
 .../test/org/apache/solr/core/MockInfoBean.java |  35 ++++---
 .../core/MockQuerySenderListenerReqHandler.java |  15 ++-
 .../apache/solr/core/RequestHandlersTest.java   |  31 ++----
 .../apache/solr/search/TestFastLRUCache.java    |  32 ++++--
 .../apache/solr/search/TestIndexSearcher.java   |   9 +-
 .../org/apache/solr/search/TestLFUCache.java    |  20 +++-
 .../org/apache/solr/search/TestLRUCache.java    |  16 ++-
 .../solr/search/TestReRankQParserPlugin.java    |  13 +--
 .../apache/solr/search/TestSolr4Spatial2.java   |  11 +-
 .../apache/solr/search/TestSolrQueryParser.java |  37 +++----
 .../apache/solr/search/join/BJQParserTest.java  |  28 ++---
 .../solr/search/join/TestScoreJoinQPScore.java  |  52 +++++----
 .../solr/store/blockcache/BufferStoreTest.java  |  14 ++-
 34 files changed, 412 insertions(+), 272 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
index b4baefa..270a399 100644
--- a/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
+++ b/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
@@ -321,13 +321,6 @@ public abstract class DirectoryFactory implements NamedListInitializedPlugin,
     return cd.getInstanceDir().resolve(cd.getDataDir()).toAbsolutePath().toString();
   }
 
-  /**
-   * Optionally allow the DirectoryFactory to request registration of some MBeans.
-   */
-  public Collection<SolrInfoBean> offerMBeans() {
-    return Collections.emptySet();
-  }
-
   public void cleanupOldIndexDirectories(final String dataDirPath, final String currentIndexDirPath, boolean afterCoreReload) {
     File dataDir = new File(dataDirPath);
     if (!dataDir.isDirectory()) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java
----------------------------------------------------------------------
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 eb8d41e..63a5b93 100644
--- a/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java
+++ b/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java
@@ -51,6 +51,8 @@ import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.IOUtils;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.metrics.SolrMetricManager;
+import org.apache.solr.metrics.SolrMetricProducer;
 import org.apache.solr.store.blockcache.BlockCache;
 import org.apache.solr.store.blockcache.BlockDirectory;
 import org.apache.solr.store.blockcache.BlockDirectoryCache;
@@ -70,7 +72,7 @@ import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.RemovalListener;
 import com.google.common.cache.RemovalNotification;
 
-public class HdfsDirectoryFactory extends CachingDirectoryFactory implements SolrCoreAware {
+public class HdfsDirectoryFactory extends CachingDirectoryFactory implements SolrCoreAware, SolrMetricProducer {
   private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
   
   public static final String BLOCKCACHE_SLAB_COUNT = "solr.hdfs.blockcache.slab.count";
@@ -493,8 +495,9 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory implements Sol
   }
 
   @Override
-  public Collection<SolrInfoBean> offerMBeans() {
-    return Arrays.<SolrInfoBean>asList(MetricsHolder.metrics, LocalityHolder.reporter);
+  public void initializeMetrics(SolrMetricManager manager, String registry, String scope) {
+    MetricsHolder.metrics.initializeMetrics(manager, registry, scope);
+    LocalityHolder.reporter.initializeMetrics(manager, registry, scope);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/core/SolrCore.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 7f8f98a..0121d9e 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -998,15 +998,9 @@ public final class SolrCore implements SolrInfoBean, SolrMetricProducer, Closeab
     // from the core.
     resourceLoader.inform(infoRegistry);
 
-    // Allow the directory factory to register MBeans as well
-    for (SolrInfoBean bean : directoryFactory.offerMBeans()) {
-      log.debug("Registering JMX bean [{}] from directory factory.", bean.getName());
-      // Not worried about concurrency, so no reason to use putIfAbsent
-      if (infoRegistry.containsKey(bean.getName())){
-        log.debug("Ignoring JMX bean [{}] due to name conflict.", bean.getName());
-      } else {
-        infoRegistry.put(bean.getName(), bean);
-      }
+    // Allow the directory factory to report metrics
+    if (directoryFactory instanceof SolrMetricProducer) {
+      ((SolrMetricProducer)directoryFactory).initializeMetrics(metricManager, coreMetricManager.getRegistryName(), "directoryFactory");
     }
 
     // seed version buckets with max from index during core initialization ... requires a searcher!
@@ -2697,6 +2691,9 @@ public final class SolrCore implements SolrInfoBean, SolrMetricProducer, Closeab
     for (PluginInfo info : pluginInfos) {
       T o = createInitInstance(info,type, type.getSimpleName(), defClassName);
       registry.put(info.name, o);
+      if (o instanceof SolrMetricProducer) {
+        coreMetricManager.registerMetricProducer(type.getSimpleName() + "." + info.name, (SolrMetricProducer)o);
+      }
       if(info.isDefault()){
         def = o;
       }
@@ -2704,6 +2701,12 @@ public final class SolrCore implements SolrInfoBean, SolrMetricProducer, Closeab
     return def;
   }
 
+  public void initDefaultPlugin(Object plugin, Class type) {
+    if (plugin instanceof SolrMetricProducer) {
+      coreMetricManager.registerMetricProducer(type.getSimpleName() + ".default", (SolrMetricProducer)plugin);
+    }
+  }
+
   /**For a given List of PluginInfo return the instances as a List
    * @param defClassName The default classname if PluginInfo#className == null
    * @return The instances initialized

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/core/SolrInfoBean.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrInfoBean.java b/solr/core/src/java/org/apache/solr/core/SolrInfoBean.java
index cd18d62..9ee4c51 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrInfoBean.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrInfoBean.java
@@ -45,4 +45,7 @@ public interface SolrInfoBean {
   String getDescription();
   /** Category of this component */
   Category getCategory();
+
+  // nocommit
+  //default NamedList getStatistics() { return null;}
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java b/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
index e4ada59..3115746 100644
--- a/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
+++ b/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
@@ -128,40 +128,58 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
 
     // Load the fragmenters
     SolrFragmenter frag = solrCore.initPlugins(info.getChildren("fragmenter") , fragmenters,SolrFragmenter.class,null);
-    if (frag == null) frag = new GapFragmenter();
+    if (frag == null) {
+      frag = new GapFragmenter();
+      solrCore.initDefaultPlugin(frag, SolrFragmenter.class);
+    }
     fragmenters.put("", frag);
     fragmenters.put(null, frag);
 
     // Load the formatters
     SolrFormatter fmt = solrCore.initPlugins(info.getChildren("formatter"), formatters,SolrFormatter.class,null);
-    if (fmt == null) fmt = new HtmlFormatter();
+    if (fmt == null) {
+      fmt = new HtmlFormatter();
+      solrCore.initDefaultPlugin(fmt, SolrFormatter.class);
+    }
     formatters.put("", fmt);
     formatters.put(null, fmt);
 
     // Load the encoders
     SolrEncoder enc = solrCore.initPlugins(info.getChildren("encoder"), encoders,SolrEncoder.class,null);
-    if (enc == null) enc = new DefaultEncoder();
+    if (enc == null) {
+      enc = new DefaultEncoder();
+      solrCore.initDefaultPlugin(enc, SolrEncoder.class);
+    }
     encoders.put("", enc);
     encoders.put(null, enc);
 
     // Load the FragListBuilders
     SolrFragListBuilder fragListBuilder = solrCore.initPlugins(info.getChildren("fragListBuilder"),
         fragListBuilders, SolrFragListBuilder.class, null );
-    if( fragListBuilder == null ) fragListBuilder = new SimpleFragListBuilder();
+    if( fragListBuilder == null ) {
+      fragListBuilder = new SimpleFragListBuilder();
+      solrCore.initDefaultPlugin(fragListBuilder, SolrFragListBuilder.class);
+    }
     fragListBuilders.put( "", fragListBuilder );
     fragListBuilders.put( null, fragListBuilder );
 
     // Load the FragmentsBuilders
     SolrFragmentsBuilder fragsBuilder = solrCore.initPlugins(info.getChildren("fragmentsBuilder"),
         fragmentsBuilders, SolrFragmentsBuilder.class, null);
-    if( fragsBuilder == null ) fragsBuilder = new ScoreOrderFragmentsBuilder();
+    if( fragsBuilder == null ) {
+      fragsBuilder = new ScoreOrderFragmentsBuilder();
+      solrCore.initDefaultPlugin(fragsBuilder, SolrFragmentsBuilder.class);
+    }
     fragmentsBuilders.put( "", fragsBuilder );
     fragmentsBuilders.put( null, fragsBuilder );
 
     // Load the BoundaryScanners
     SolrBoundaryScanner boundaryScanner = solrCore.initPlugins(info.getChildren("boundaryScanner"),
         boundaryScanners, SolrBoundaryScanner.class, null);
-    if(boundaryScanner == null) boundaryScanner = new SimpleBoundaryScanner();
+    if(boundaryScanner == null) {
+      boundaryScanner = new SimpleBoundaryScanner();
+      solrCore.initDefaultPlugin(boundaryScanner, SolrBoundaryScanner.class);
+    }
     boundaryScanners.put("", boundaryScanner);
     boundaryScanners.put(null, boundaryScanner);
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/highlight/HighlightingPluginBase.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/highlight/HighlightingPluginBase.java b/solr/core/src/java/org/apache/solr/highlight/HighlightingPluginBase.java
index 9f90b6d..99984f8 100644
--- a/solr/core/src/java/org/apache/solr/highlight/HighlightingPluginBase.java
+++ b/solr/core/src/java/org/apache/solr/highlight/HighlightingPluginBase.java
@@ -60,7 +60,7 @@ public abstract class HighlightingPluginBase implements SolrInfoBean, SolrMetric
 
   @Override
   public void initializeMetrics(SolrMetricManager manager, String registry, String scope) {
-    manager.counter(registry, "requests", getCategory().toString(), scope);
+   numRequests = manager.counter(registry, "requests", getCategory().toString(), scope);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java b/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
index 52aa1f2..630d75d 100644
--- a/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
+++ b/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
@@ -20,6 +20,7 @@ import java.io.Closeable;
 import java.io.IOException;
 import java.lang.invoke.MethodHandles;
 
+import com.codahale.metrics.MetricRegistry;
 import org.apache.solr.cloud.CloudDescriptor;
 import org.apache.solr.core.NodeConfig;
 import org.apache.solr.core.PluginInfo;
@@ -127,6 +128,17 @@ public class SolrCoreMetricManager implements Closeable {
   }
 
   /**
+   * Return the registry used by this SolrCore.
+   */
+  public MetricRegistry getRegistry() {
+    if (registryName != null) {
+      return metricManager.registry(registryName);
+    } else {
+      return null;
+    }
+  }
+
+  /**
    * Closes reporters specific to this core.
    */
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/search/FastLRUCache.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/FastLRUCache.java b/solr/core/src/java/org/apache/solr/search/FastLRUCache.java
index 35c5860..1a69368 100644
--- a/solr/core/src/java/org/apache/solr/search/FastLRUCache.java
+++ b/solr/core/src/java/org/apache/solr/search/FastLRUCache.java
@@ -272,7 +272,12 @@ public class FastLRUCache<K, V> extends SolrCacheBase implements SolrCache<K,V>
       }
       return map;
     };
-    manager.registerGauge(registry, cacheMap, true, getClass().getSimpleName(), getCategory().toString(), scope);
+    manager.registerGauge(registry, cacheMap, true, scope, getCategory().toString());
+  }
+
+  // for unit tests only
+  MetricsMap getMetrics() {
+    return cacheMap;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/search/LFUCache.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/LFUCache.java b/solr/core/src/java/org/apache/solr/search/LFUCache.java
index 3841d0d..18c9c71 100644
--- a/solr/core/src/java/org/apache/solr/search/LFUCache.java
+++ b/solr/core/src/java/org/apache/solr/search/LFUCache.java
@@ -290,7 +290,12 @@ public class LFUCache<K, V> implements SolrCache<K, V> {
       }
       return map;
     };
-    manager.registerGauge(registry, cacheMap, true, getClass().getSimpleName(), getCategory().toString(), scope);
+    manager.registerGauge(registry, cacheMap, true, scope, getCategory().toString());
+  }
+
+  // for unit tests only
+  MetricsMap getMetrics() {
+    return cacheMap;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/search/LRUCache.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/LRUCache.java b/solr/core/src/java/org/apache/solr/search/LRUCache.java
index f6762b6..e020a1c 100644
--- a/solr/core/src/java/org/apache/solr/search/LRUCache.java
+++ b/solr/core/src/java/org/apache/solr/search/LRUCache.java
@@ -355,7 +355,12 @@ public class LRUCache<K,V> extends SolrCacheBase implements SolrCache<K,V>, Acco
 
       return res;
     };
-    manager.registerGauge(registry, cacheMap, true, getClass().getSimpleName(), getCategory().toString(), scope);
+    manager.registerGauge(registry, cacheMap, true, scope, getCategory().toString());
+  }
+
+  // for unit tests only
+  MetricsMap getMetrics() {
+    return cacheMap;
   }
   
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/search/SolrCache.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/SolrCache.java b/solr/core/src/java/org/apache/solr/search/SolrCache.java
index caa5c2c..277ce19 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrCache.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrCache.java
@@ -16,6 +16,7 @@
  */
 package org.apache.solr.search;
 
+import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrInfoBean;
 import org.apache.solr.metrics.SolrMetricProducer;
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index e13769f..e68de08 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -475,7 +475,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
   }
 
   /**
-   * Register sub-objects such as caches
+   * Register sub-objects such as caches and our own metrics
    */
   public void register() {
     final Map<String,SolrInfoBean> infoRegistry = core.getInfoRegistry();
@@ -486,6 +486,12 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
       cache.setState(SolrCache.State.LIVE);
       infoRegistry.put(cache.name(), cache);
     }
+    SolrMetricManager manager = core.getCoreDescriptor().getCoreContainer().getMetricManager();
+    String registry = core.getCoreMetricManager().getRegistryName();
+    for (SolrCache cache : cacheList) {
+      cache.initializeMetrics(manager, registry, SolrMetricManager.mkName(cache.name(), STATISTICS_KEY));
+    }
+    initializeMetrics(manager, registry, STATISTICS_KEY);
     registerTime = new Date();
   }
 
@@ -2608,9 +2614,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
     manager.registerGauge(registry, () -> cachingEnabled, true, "caching", Category.SEARCHER.toString(), scope);
     manager.registerGauge(registry, () -> openTime, true, "openedAt", Category.SEARCHER.toString(), scope);
     manager.registerGauge(registry, () -> warmupTime, true, "warmupTime", Category.SEARCHER.toString(), scope);
-    if (registerTime != null) {
-      manager.registerGauge(registry, () -> registerTime, true, "registeredAt", Category.SEARCHER.toString(), scope);
-    }
+    manager.registerGauge(registry, () -> registerTime, true, "registeredAt", Category.SEARCHER.toString(), scope);
     // reader stats
     manager.registerGauge(registry, () -> reader.numDocs(), true, "numDocs", Category.SEARCHER.toString(), scope);
     manager.registerGauge(registry, () -> reader.maxDoc(), true, "maxDoc", Category.SEARCHER.toString(), scope);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/java/org/apache/solr/store/blockcache/Metrics.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/store/blockcache/Metrics.java b/solr/core/src/java/org/apache/solr/store/blockcache/Metrics.java
index 04c0aa3..30cd54c 100644
--- a/solr/core/src/java/org/apache/solr/store/blockcache/Metrics.java
+++ b/solr/core/src/java/org/apache/solr/store/blockcache/Metrics.java
@@ -16,11 +16,16 @@
  */
 package org.apache.solr.store.blockcache;
 
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.SimpleOrderedMap;
 import org.apache.solr.core.SolrInfoBean;
+import org.apache.solr.metrics.MetricsMap;
+import org.apache.solr.metrics.SolrMetricManager;
+import org.apache.solr.metrics.SolrMetricProducer;
 import org.apache.solr.search.SolrCacheBase;
 
 /**
@@ -28,7 +33,7 @@ import org.apache.solr.search.SolrCacheBase;
  *
  * @lucene.experimental
  */
-public class Metrics extends SolrCacheBase implements SolrInfoBean {
+public class Metrics extends SolrCacheBase implements SolrInfoBean, SolrMetricProducer {
 
 
   public AtomicLong blockCacheSize = new AtomicLong(0);
@@ -49,55 +54,58 @@ public class Metrics extends SolrCacheBase implements SolrInfoBean {
   public AtomicLong shardBuffercacheAllocate = new AtomicLong(0);
   public AtomicLong shardBuffercacheLost = new AtomicLong(0);
 
+  private MetricsMap metricsMap;
 
   private long previous = System.nanoTime();
 
-
-  public NamedList<Number> getStatistics() {
-    NamedList<Number> stats = new SimpleOrderedMap<>(21); // room for one method call before growing
-
-    long now = System.nanoTime();
-    long delta = Math.max(now - previous, 1);
-    double seconds = delta / 1000000000.0;
-
-    long hits_total = blockCacheHit.get();
-    long hits_delta = hits_total - blockCacheHit_last.get();
-    blockCacheHit_last.set(hits_total);
-
-    long miss_total = blockCacheMiss.get();
-    long miss_delta = miss_total - blockCacheMiss_last.get();
-    blockCacheMiss_last.set(miss_total);
-
-    long evict_total = blockCacheEviction.get();
-    long evict_delta = evict_total - blockCacheEviction_last.get();
-    blockCacheEviction_last.set(evict_total);
-
-    long storeFail_total = blockCacheStoreFail.get();
-    long storeFail_delta = storeFail_total - blockCacheStoreFail_last.get();
-    blockCacheStoreFail_last.set(storeFail_total);
-
-    long lookups_delta = hits_delta + miss_delta;
-    long lookups_total = hits_total + miss_total;
-
-    stats.add("size", blockCacheSize.get());
-    stats.add("lookups", lookups_total);
-    stats.add("hits", hits_total);
-    stats.add("evictions", evict_total);
-    stats.add("storeFails", storeFail_total);
-    stats.add("hitratio_current", calcHitRatio(lookups_delta, hits_delta));  // hit ratio since the last call
-    stats.add("lookups_persec", getPerSecond(lookups_delta, seconds)); // lookups per second since the last call
-    stats.add("hits_persec", getPerSecond(hits_delta, seconds));       // hits per second since the last call
-    stats.add("evictions_persec", getPerSecond(evict_delta, seconds));  // evictions per second since the last call
-    stats.add("storeFails_persec", getPerSecond(storeFail_delta, seconds));  // evictions per second since the last call
-    stats.add("time_delta", seconds);  // seconds since last call
-
-    // TODO: these aren't really related to the BlockCache
-    stats.add("buffercache.allocations", getPerSecond(shardBuffercacheAllocate.getAndSet(0), seconds));
-    stats.add("buffercache.lost", getPerSecond(shardBuffercacheLost.getAndSet(0), seconds));
-
-    previous = now;
-
-    return stats;
+  @Override
+  public void initializeMetrics(SolrMetricManager manager, String registry, String scope) {
+    metricsMap = detailed -> {
+      Map<String,Object> map = new ConcurrentHashMap<>();
+      long now = System.nanoTime();
+      long delta = Math.max(now - previous, 1);
+      double seconds = delta / 1000000000.0;
+
+      long hits_total = blockCacheHit.get();
+      long hits_delta = hits_total - blockCacheHit_last.get();
+      blockCacheHit_last.set(hits_total);
+
+      long miss_total = blockCacheMiss.get();
+      long miss_delta = miss_total - blockCacheMiss_last.get();
+      blockCacheMiss_last.set(miss_total);
+
+      long evict_total = blockCacheEviction.get();
+      long evict_delta = evict_total - blockCacheEviction_last.get();
+      blockCacheEviction_last.set(evict_total);
+
+      long storeFail_total = blockCacheStoreFail.get();
+      long storeFail_delta = storeFail_total - blockCacheStoreFail_last.get();
+      blockCacheStoreFail_last.set(storeFail_total);
+
+      long lookups_delta = hits_delta + miss_delta;
+      long lookups_total = hits_total + miss_total;
+
+      map.put("size", blockCacheSize.get());
+      map.put("lookups", lookups_total);
+      map.put("hits", hits_total);
+      map.put("evictions", evict_total);
+      map.put("storeFails", storeFail_total);
+      map.put("hitratio_current", calcHitRatio(lookups_delta, hits_delta));  // hit ratio since the last call
+      map.put("lookups_persec", getPerSecond(lookups_delta, seconds)); // lookups per second since the last call
+      map.put("hits_persec", getPerSecond(hits_delta, seconds));       // hits per second since the last call
+      map.put("evictions_persec", getPerSecond(evict_delta, seconds));  // evictions per second since the last call
+      map.put("storeFails_persec", getPerSecond(storeFail_delta, seconds));  // evictions per second since the last call
+      map.put("time_delta", seconds);  // seconds since last call
+
+      // TODO: these aren't really related to the BlockCache
+      map.put("buffercache.allocations", getPerSecond(shardBuffercacheAllocate.getAndSet(0), seconds));
+      map.put("buffercache.lost", getPerSecond(shardBuffercacheLost.getAndSet(0), seconds));
+
+      previous = now;
+
+      return map;
+    };
+    manager.registerGauge(registry, metricsMap, true, getName(), getCategory().toString(), scope);
   }
 
   private float getPerSecond(long value, double seconds) {
@@ -108,11 +116,12 @@ public class Metrics extends SolrCacheBase implements SolrInfoBean {
 
   @Override
   public String getName() {
-    return "HdfsBlockCache";
+    return "hdfsBlockCache";
   }
 
   @Override
   public String getDescription() {
     return "Provides metrics for the HdfsDirectoryFactory BlockCache.";
   }
+
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java b/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
index 2bd93cd..199f682 100644
--- a/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
+++ b/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
@@ -27,6 +27,8 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import com.codahale.metrics.Gauge;
+import com.codahale.metrics.Metric;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.LazyDocument;
@@ -38,6 +40,7 @@ import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.handler.RequestHandlerBase;
+import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrRequestHandler;
@@ -122,10 +125,14 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
     assertNotNull(core.getRequestHandler("mock"));
 
     // test stats call
-    NamedList stats = core.getStatistics();
-    assertEquals("collection1", stats.get("coreName"));
-    assertTrue(stats.get("refCount") != null);
-    
+    SolrMetricManager manager = core.getCoreDescriptor().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")

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/CursorPagingTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/CursorPagingTest.java b/solr/core/src/test/org/apache/solr/CursorPagingTest.java
index 101dc1a..6d28b00 100644
--- a/solr/core/src/test/org/apache/solr/CursorPagingTest.java
+++ b/solr/core/src/test/org/apache/solr/CursorPagingTest.java
@@ -32,6 +32,7 @@ import static org.apache.solr.common.params.CursorMarkParams.CURSOR_MARK_START;
 
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.metrics.MetricsMap;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.search.CursorMark; //jdoc
 import org.noggit.ObjectBuilder;
@@ -521,16 +522,16 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
 
     final Collection<String> allFieldNames = getAllSortFieldNames();
 
-    final SolrInfoBean filterCacheStats
-      = h.getCore().getInfoRegistry().get("filterCache");
+    final MetricsMap filterCacheStats =
+        (MetricsMap)h.getCore().getCoreMetricManager().getRegistry().getMetrics().get("CACHE.searcher.filterCache");
     assertNotNull(filterCacheStats);
-    final SolrInfoBean queryCacheStats
-      = h.getCore().getInfoRegistry().get("queryResultCache");
+    final MetricsMap queryCacheStats =
+        (MetricsMap)h.getCore().getCoreMetricManager().getRegistry().getMetrics().get("CACHE.searcher.queryResultCache");
     assertNotNull(queryCacheStats);
 
-    final long preQcIn = (Long) queryCacheStats.getStatistics().get("inserts");
-    final long preFcIn = (Long) filterCacheStats.getStatistics().get("inserts");
-    final long preFcHits = (Long) filterCacheStats.getStatistics().get("hits");
+    final long preQcIn = (Long) queryCacheStats.getValue().get("inserts");
+    final long preFcIn = (Long) filterCacheStats.getValue().get("inserts");
+    final long preFcHits = (Long) filterCacheStats.getValue().get("hits");
 
     SentinelIntSet ids = assertFullWalkNoDups
       (10, params("q", "*:*",
@@ -542,9 +543,9 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
     
     assertEquals(6, ids.size());
 
-    final long postQcIn = (Long) queryCacheStats.getStatistics().get("inserts");
-    final long postFcIn = (Long) filterCacheStats.getStatistics().get("inserts");
-    final long postFcHits = (Long) filterCacheStats.getStatistics().get("hits");
+    final long postQcIn = (Long) queryCacheStats.getValue().get("inserts");
+    final long postFcIn = (Long) filterCacheStats.getValue().get("inserts");
+    final long postFcHits = (Long) filterCacheStats.getValue().get("hits");
     
     assertEquals("query cache inserts changed", preQcIn, postQcIn);
     // NOTE: use of pure negative filters causees "*:* to be tracked in filterCache

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/SolrInfoBeanTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/SolrInfoBeanTest.java b/solr/core/src/test/org/apache/solr/SolrInfoBeanTest.java
index 5acb086..f2f35ed 100644
--- a/solr/core/src/test/org/apache/solr/SolrInfoBeanTest.java
+++ b/solr/core/src/test/org/apache/solr/SolrInfoBeanTest.java
@@ -76,8 +76,6 @@ public class SolrInfoBeanTest extends SolrTestCaseJ4
           }
           
           assertNotNull( info.toString() );
-          // increase code coverage...
-          assertNotNull( info.getStatistics()+"" );
           checked++;
         }
         catch( InstantiationException ex ) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
index d1dbe9c..1c23c9c 100644
--- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
@@ -59,6 +59,7 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.lang.invoke.MethodHandles;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -752,19 +753,28 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
 
   private Long getNumCommits(HttpSolrClient sourceClient) throws
       SolrServerException, IOException {
-    try (HttpSolrClient client = getHttpSolrClient(sourceClient.getBaseURL())) {
+    // construct the /admin/metrics URL
+    URL url = new URL(sourceClient.getBaseURL());
+    String path = url.getPath().substring(1);
+    String[] elements = path.split("/");
+    String collection = elements[elements.length - 1];
+    String urlString = url.toString();
+    urlString = urlString.substring(0, urlString.length() - collection.length() - 1);
+    try (HttpSolrClient client = getHttpSolrClient(urlString)) {
       client.setConnectionTimeout(15000);
       client.setSoTimeout(60000);
       ModifiableSolrParams params = new ModifiableSolrParams();
-      params.set("qt", "/admin/mbeans?key=updateHandler&stats=true");
+      //params.set("qt", "/admin/metrics?prefix=UPDATE.updateHandler&registry=solr.core." + collection);
+      params.set("qt", "/admin/metrics");
+      params.set("prefix", "UPDATE.updateHandler");
+      params.set("registry", "solr.core." + collection);
       // use generic request to avoid extra processing of queries
       QueryRequest req = new QueryRequest(params);
       NamedList<Object> resp = client.request(req);
-      NamedList mbeans = (NamedList) resp.get("solr-mbeans");
-      NamedList uhandlerCat = (NamedList) mbeans.get("UPDATE");
-      NamedList uhandler = (NamedList) uhandlerCat.get("updateHandler");
-      NamedList stats = (NamedList) uhandler.get("stats");
-      return (Long) stats.get("commits");
+      NamedList metrics = (NamedList) resp.get("metrics");
+      NamedList uhandlerCat = (NamedList) metrics.getVal(0);
+      Map<String,Object> commits = (Map<String,Object>) uhandlerCat.get("UPDATE.updateHandler.commits");
+      return (Long) commits.get("count");
     }
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java b/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java
index 26fa325..2311bd0 100644
--- a/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java
@@ -16,6 +16,10 @@
  */
 package org.apache.solr.cloud;
 
+import java.util.Map;
+
+import com.codahale.metrics.Gauge;
+import com.codahale.metrics.Metric;
 import org.apache.lucene.util.LuceneTestCase.Slow;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.CommonParams;
@@ -158,11 +162,11 @@ public class BasicZkTest extends AbstractZkTestCase {
     }
     
     // test stats call
-    NamedList stats = core.getStatistics();
-    assertEquals("collection1", stats.get("coreName"));
-    assertEquals("collection1", stats.get("collection"));
-    assertEquals("shard1", stats.get("shard"));
-    assertTrue(stats.get("refCount") != null);
+    Map<String, Metric> metrics = h.getCore().getCoreMetricManager().getRegistry().getMetrics();
+    assertEquals("collection1", ((Gauge)metrics.get("CORE.coreName")).getValue());
+    assertEquals("collection1", ((Gauge)metrics.get("CORE.collection")).getValue());
+    assertEquals("shard1", ((Gauge)metrics.get("CORE.shard")).getValue());
+    assertTrue(metrics.get("CORE.refCount") != null);
 
     //zkController.getZkClient().printLayoutToStdOut();
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/cloud/TestRandomRequestDistribution.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRandomRequestDistribution.java b/solr/core/src/test/org/apache/solr/cloud/TestRandomRequestDistribution.java
index 1c1c5c1..1d9bc1b 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestRandomRequestDistribution.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestRandomRequestDistribution.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.codahale.metrics.Counter;
 import org.apache.lucene.util.TestUtil;
 import org.apache.solr.BaseDistributedSearchTestCase;
 import org.apache.solr.SolrTestCaseJ4;
@@ -39,6 +40,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.request.SolrRequestHandler;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -109,10 +111,13 @@ public class TestRandomRequestDistribution extends AbstractFullDistribZkTestBase
     Map<String, Integer> shardVsCount = new HashMap<>();
     for (JettySolrRunner runner : jettys) {
       CoreContainer container = runner.getCoreContainer();
+      SolrMetricManager metricManager = container.getMetricManager();
       for (SolrCore core : container.getCores()) {
+        String registry = core.getCoreMetricManager().getRegistryName();
+        Counter cnt = metricManager.counter(registry, "requests", "QUERY.standard");
         SolrRequestHandler select = core.getRequestHandler("");
-        long c = (long) select.getStatistics().get("requests");
-        shardVsCount.put(core.getName(), (int) c);
+//        long c = (long) select.getStatistics().get("requests");
+        shardVsCount.put(core.getName(), (int) cnt.getCount());
       }
     }
 
@@ -190,6 +195,10 @@ public class TestRandomRequestDistribution extends AbstractFullDistribZkTestBase
       }
       assertNotNull(leaderCore);
 
+      SolrMetricManager leaderMetricManager = leaderCore.getCoreDescriptor().getCoreContainer().getMetricManager();
+      String leaderRegistry = leaderCore.getCoreMetricManager().getRegistryName();
+      Counter cnt = leaderMetricManager.counter(leaderRegistry, "requests", "QUERY.standard");
+
       // All queries should be served by the active replica
       // To make sure that's true we keep querying the down replica
       // If queries are getting processed by the down replica then the cluster state hasn't updated for that replica
@@ -200,8 +209,7 @@ public class TestRandomRequestDistribution extends AbstractFullDistribZkTestBase
         count++;
         client.query(new SolrQuery("*:*"));
 
-        SolrRequestHandler select = leaderCore.getRequestHandler("");
-        long c = (long) select.getStatistics().get("requests");
+        long c = cnt.getCount();
 
         if (c == 1) {
           break; // cluster state has got update locally
@@ -222,8 +230,7 @@ public class TestRandomRequestDistribution extends AbstractFullDistribZkTestBase
         client.query(new SolrQuery("*:*"));
         count++;
 
-        SolrRequestHandler select = leaderCore.getRequestHandler("");
-        long c = (long) select.getStatistics().get("requests");
+        long c = cnt.getCount();
 
         assertEquals("Query wasn't served by leader", count, c);
       }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java b/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
index 0556405..38fc897 100644
--- a/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
+++ b/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
@@ -20,6 +20,7 @@ import java.util.Map;
 
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.metrics.MetricsMap;
 import org.apache.solr.response.SolrQueryResponse;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -88,11 +89,11 @@ public class ExitableDirectoryReaderTest extends SolrTestCaseJ4 {
   public void testCacheAssumptions() throws Exception {
     String fq= "name:d*";
     SolrCore core = h.getCore();
-    SolrInfoBean filterCacheStats = core.getInfoRegistry().get("filterCache");
-    long fqInserts = (long) filterCacheStats.getStatistics().get("inserts");
+    MetricsMap filterCacheStats = (MetricsMap)core.getCoreMetricManager().getRegistry().getMetrics().get("CACHE.searcher.filterCache");
+    long fqInserts = (long) filterCacheStats.getValue().get("inserts");
 
-    SolrInfoBean queryCacheStats = core.getInfoRegistry().get("queryResultCache");
-    long qrInserts = (long) queryCacheStats.getStatistics().get("inserts");
+    MetricsMap queryCacheStats = (MetricsMap)core.getCoreMetricManager().getRegistry().getMetrics().get("CACHE.searcher.queryResultCache");
+    long qrInserts = (long) queryCacheStats.getValue().get("inserts");
 
     // This gets 0 docs back. Use 10000 instead of 1 for timeAllowed and it gets 100 back and the for loop below
     // succeeds.
@@ -105,16 +106,16 @@ public class ExitableDirectoryReaderTest extends SolrTestCaseJ4 {
     assertTrue("Should have partial results", (Boolean) (header.get(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY)));
 
     assertEquals("Should NOT have inserted partial results in the cache!",
-        (long) queryCacheStats.getStatistics().get("inserts"), qrInserts);
+        (long) queryCacheStats.getValue().get("inserts"), qrInserts);
 
-    assertEquals("Should NOT have another insert", fqInserts, (long) filterCacheStats.getStatistics().get("inserts"));
+    assertEquals("Should NOT have another insert", fqInserts, (long) filterCacheStats.getValue().get("inserts"));
 
     // At the end of all this, we should have no hits in the queryResultCache.
     response = JQ(req("q", "*:*", "fq", fq, "indent", "true", "timeAllowed", longTimeout));
 
     // Check that we did insert this one.
-    assertEquals("Hits should still be 0", (long) filterCacheStats.getStatistics().get("hits"), 0L);
-    assertEquals("Inserts should be bumped", (long) filterCacheStats.getStatistics().get("inserts"), fqInserts + 1);
+    assertEquals("Hits should still be 0", (long) filterCacheStats.getValue().get("hits"), 0L);
+    assertEquals("Inserts should be bumped", (long) filterCacheStats.getValue().get("inserts"), fqInserts + 1);
 
     res = (Map) ObjectBuilder.fromJSON(response);
     body = (Map) (res.get("response"));
@@ -130,14 +131,14 @@ public class ExitableDirectoryReaderTest extends SolrTestCaseJ4 {
   public void testQueryResults() throws Exception {
     String q = "name:e*";
     SolrCore core = h.getCore();
-    SolrInfoBean queryCacheStats = core.getInfoRegistry().get("queryResultCache");
-    NamedList nl = queryCacheStats.getStatistics();
+    MetricsMap queryCacheStats = (MetricsMap)core.getCoreMetricManager().getRegistry().getMetrics().get("CACHE.searcher.queryResultCache");
+    Map<String,Object> nl = queryCacheStats.getValue();
     long inserts = (long) nl.get("inserts");
 
     String response = JQ(req("q", q, "indent", "true", "timeAllowed", "1", "sleep", sleep));
 
     // The queryResultCache should NOT get an entry here.
-    nl = queryCacheStats.getStatistics();
+    nl = queryCacheStats.getValue();
     assertEquals("Should NOT have inserted partial results!", inserts, (long) nl.get("inserts"));
 
     Map res = (Map) ObjectBuilder.fromJSON(response);
@@ -150,7 +151,7 @@ public class ExitableDirectoryReaderTest extends SolrTestCaseJ4 {
     response = JQ(req("q", q, "indent", "true", "timeAllowed", longTimeout));
 
     // Check that we did insert this one.
-    NamedList nl2 = queryCacheStats.getStatistics();
+    Map<String,Object> nl2 = queryCacheStats.getValue();
     assertEquals("Hits should still be 0", (long) nl.get("hits"), (long) nl2.get("hits"));
     assertTrue("Inserts should be bumped", inserts < (long) nl2.get("inserts"));
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java
----------------------------------------------------------------------
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 90d8fda..f6d101b 100644
--- a/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java
+++ b/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Random;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
@@ -30,11 +31,14 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexOutput;
 import org.apache.lucene.store.NoLockFactory;
+import org.apache.lucene.util.TestUtil;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.cloud.hdfs.HdfsTestUtil;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.DirectoryFactory.DirContext;
 import org.apache.solr.handler.SnapShooter;
+import org.apache.solr.metrics.MetricsMap;
+import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.store.hdfs.HdfsLocalityReporter;
 import org.apache.solr.util.BadHdfsThreadsFilter;
 import org.apache.solr.util.MockCoreContainer.MockCoreDescriptor;
@@ -175,24 +179,24 @@ public class HdfsDirectoryFactoryTest extends SolrTestCaseJ4 {
   public void testLocalityReporter() throws Exception {
     Configuration conf = HdfsTestUtil.getClientConfiguration(dfsCluster);
     conf.set("dfs.permissions.enabled", "false");
-    
+
+    Random r = random();
     HdfsDirectoryFactory factory = new HdfsDirectoryFactory();
+    SolrMetricManager metricManager = new SolrMetricManager();
+    String registry = TestUtil.randomSimpleString(r, 2, 10);
+    String scope = TestUtil.randomSimpleString(r,2, 10);
     Map<String,String> props = new HashMap<String,String>();
     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<SolrInfoBean> it = factory.offerMBeans().iterator();
-    it.next(); // skip
-    SolrInfoBean localityBean = it.next(); // brittle, but it's ok
-    
-    // Make sure we have the right bean.
-    assertEquals("Got the wrong bean: " + localityBean.getName(), "hdfs-locality", localityBean.getName());
-    
+    factory.initializeMetrics(metricManager, registry, scope);
+
+    // get the metrics map for the locality bean
+    MetricsMap metrics = (MetricsMap)metricManager.registry(registry).getMetrics().get("OTHER." + scope + ".hdfsLocality");
     // We haven't done anything, so there should be no data
-    NamedList<?> statistics = localityBean.getStatistics();
+    Map<String,Object> statistics = metrics.getValue();
     assertEquals("Saw bytes that were not written: " + statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_TOTAL), 0l,
         statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_TOTAL));
     assertEquals(
@@ -210,7 +214,7 @@ public class HdfsDirectoryFactoryTest extends SolrTestCaseJ4 {
     
     // no locality because hostname not set
     factory.setHost("bogus");
-    statistics = localityBean.getStatistics();
+    statistics = metrics.getValue();
     assertEquals("Wrong number of total bytes counted: " + statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_TOTAL),
         long_bytes, statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_TOTAL));
     assertEquals("Wrong number of total blocks counted: " + statistics.get(HdfsLocalityReporter.LOCALITY_BLOCKS_TOTAL),
@@ -221,7 +225,7 @@ public class HdfsDirectoryFactoryTest extends SolrTestCaseJ4 {
         
     // set hostname and check again
     factory.setHost("127.0.0.1");
-    statistics = localityBean.getStatistics();
+    statistics = metrics.getValue();
     assertEquals(
         "Did not count block as local after setting hostname: "
             + statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_LOCAL),

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/core/MockInfoBean.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/MockInfoBean.java b/solr/core/src/test/org/apache/solr/core/MockInfoBean.java
index da7ad8a..00f120e 100644
--- a/solr/core/src/test/org/apache/solr/core/MockInfoBean.java
+++ b/solr/core/src/test/org/apache/solr/core/MockInfoBean.java
@@ -16,9 +16,14 @@
  */
 package org.apache.solr.core;
 
-import org.apache.solr.common.util.NamedList;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
-class MockInfoBean implements SolrInfoBean {
+import org.apache.solr.metrics.MetricsMap;
+import org.apache.solr.metrics.SolrMetricManager;
+import org.apache.solr.metrics.SolrMetricProducer;
+
+class MockInfoBean implements SolrInfoBean, SolrMetricProducer {
   @Override
   public String getName() {
     return "mock";
@@ -35,17 +40,19 @@ class MockInfoBean implements SolrInfoBean {
   }
 
   @Override
-  @SuppressWarnings("unchecked")
-  public NamedList getStatistics() {
-    NamedList myList = new NamedList<Integer>();
-    myList.add("Integer", 123);
-    myList.add("Double",567.534);
-    myList.add("Long", 32352463l);
-    myList.add("Short", (short) 32768);
-    myList.add("Byte", (byte) 254);
-    myList.add("Float", 3.456f);
-    myList.add("String","testing");
-    myList.add("Object", new Object());
-    return myList;
+  public void initializeMetrics(SolrMetricManager manager, String registry, String scope) {
+    MetricsMap metricsMap = detailed -> {
+      Map<String, Object> map = new ConcurrentHashMap<>();
+      map.put("Integer", 123);
+      map.put("Double",567.534);
+      map.put("Long", 32352463l);
+      map.put("Short", (short) 32768);
+      map.put("Byte", (byte) 254);
+      map.put("Float", 3.456f);
+      map.put("String","testing");
+      map.put("Object", new Object());
+      return map;
+    };
+    manager.registerGauge(registry, metricsMap, true, getClass().getSimpleName(), getCategory().toString(), scope);
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/core/MockQuerySenderListenerReqHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/MockQuerySenderListenerReqHandler.java b/solr/core/src/test/org/apache/solr/core/MockQuerySenderListenerReqHandler.java
index 367870a..50afbb1 100644
--- a/solr/core/src/test/org/apache/solr/core/MockQuerySenderListenerReqHandler.java
+++ b/solr/core/src/test/org/apache/solr/core/MockQuerySenderListenerReqHandler.java
@@ -17,6 +17,7 @@
 package org.apache.solr.core;
 
 import org.apache.solr.handler.RequestHandlerBase;
+import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.common.util.NamedList;
@@ -41,6 +42,12 @@ public class MockQuerySenderListenerReqHandler extends RequestHandlerBase {
   }
 
   @Override
+  public void initializeMetrics(SolrMetricManager manager, String registryName, String scope) {
+    super.initializeMetrics(manager, registryName, scope);
+    manager.registerGauge(registryName, () -> initCounter.intValue(), true, "initCount", getCategory().toString(), scope);
+  }
+
+  @Override
   public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
     this.req = req;
     this.rsp = rsp;
@@ -51,12 +58,4 @@ public class MockQuerySenderListenerReqHandler extends RequestHandlerBase {
     String result = null;
     return result;
   }
-
-  @Override
-  public NamedList<Object> getStatistics() {
-    NamedList<Object> lst = super.getStatistics();
-    lst.add("initCount", initCounter.intValue());
-    return lst;
-  }
- 
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java b/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java
index 9a953e1..f887374 100644
--- a/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java
+++ b/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java
@@ -16,8 +16,13 @@
  */
 package org.apache.solr.core;
 
+import java.util.Map;
+
+import com.codahale.metrics.Gauge;
+import com.codahale.metrics.Metric;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.request.SolrRequestHandler;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -30,10 +35,11 @@ public class RequestHandlersTest extends SolrTestCaseJ4 {
 
   @Test
   public void testInitCount() {
-    SolrCore core = h.getCore();
-    SolrRequestHandler handler = core.getRequestHandler( "mock" );
+    String registry = h.getCore().getCoreMetricManager().getRegistryName();
+    SolrMetricManager manager = h.getCoreContainer().getMetricManager();
+    Gauge<Number> g = (Gauge<Number>)manager.registry(registry).getMetrics().get("QUERY.mock.initCount");
     assertEquals("Incorrect init count",
-                 1, handler.getStatistics().get("initCount"));
+                 1, g.getValue().intValue());
   }
 
   @Test
@@ -94,23 +100,4 @@ public class RequestHandlersTest extends SolrTestCaseJ4 {
     
     assertNull( core.getRequestHandler("/update/asdgadsgas" ) ); // prefix
   }
-
-  @Test
-  public void testStatistics() {
-    SolrCore core = h.getCore();
-    SolrRequestHandler updateHandler = core.getRequestHandler("/update");
-    SolrRequestHandler termHandler = core.getRequestHandler("/terms");
-
-    assertU(adoc("id", "47",
-        "text", "line up and fly directly at the enemy death cannons, clogging them with wreckage!"));
-    assertU(commit());
-
-    NamedList updateStats = updateHandler.getStatistics();
-    NamedList termStats = termHandler.getStatistics();
-
-    Double updateTime = (Double) updateStats.get("avgTimePerRequest");
-    Double termTime = (Double) termStats.get("avgTimePerRequest");
-
-    assertFalse("RequestHandlers should not share statistics!", updateTime.equals(termTime));
-  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/search/TestFastLRUCache.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestFastLRUCache.java b/solr/core/src/test/org/apache/solr/search/TestFastLRUCache.java
index 0034b13..e5e7a83 100644
--- a/solr/core/src/test/org/apache/solr/search/TestFastLRUCache.java
+++ b/solr/core/src/test/org/apache/solr/search/TestFastLRUCache.java
@@ -17,12 +17,13 @@
 package org.apache.solr.search;
 
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.solr.common.util.NamedList;
+import org.apache.lucene.util.TestUtil;
+import org.apache.solr.metrics.MetricsMap;
+import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.util.ConcurrentLRUCache;
 import org.apache.solr.util.RTimer;
 
 import java.io.IOException;
-import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Random;
@@ -37,9 +38,14 @@ import java.util.concurrent.atomic.AtomicInteger;
  * @since solr 1.4
  */
 public class TestFastLRUCache extends LuceneTestCase {
-  
+  SolrMetricManager metricManager = new SolrMetricManager();
+  String registry = TestUtil.randomSimpleString(random(), 2, 10);
+  String scope = TestUtil.randomSimpleString(random(), 2, 10);
+
   public void testPercentageAutowarm() throws IOException {
     FastLRUCache<Object, Object> fastCache = new FastLRUCache<>();
+    fastCache.initializeMetrics(metricManager, registry, scope);
+    MetricsMap metrics = fastCache.getMetrics();
     Map<String, String> params = new HashMap<>();
     params.put("size", "100");
     params.put("initialSize", "10");
@@ -52,12 +58,14 @@ public class TestFastLRUCache extends LuceneTestCase {
     }
     assertEquals("25", fastCache.get(25));
     assertEquals(null, fastCache.get(110));
-    NamedList<Serializable> nl = fastCache.getStatistics();
+    Map<String,Object> nl = metrics.getValue();
     assertEquals(2L, nl.get("lookups"));
     assertEquals(1L, nl.get("hits"));
     assertEquals(101L, nl.get("inserts"));
     assertEquals(null, fastCache.get(1));  // first item put in should be the first out
     FastLRUCache<Object, Object> fastCacheNew = new FastLRUCache<>();
+    fastCacheNew.initializeMetrics(metricManager, registry, scope);
+    metrics = fastCacheNew.getMetrics();
     fastCacheNew.init(params, o, cr);
     fastCacheNew.warm(null, fastCache);
     fastCacheNew.setState(SolrCache.State.LIVE);
@@ -65,7 +73,7 @@ public class TestFastLRUCache extends LuceneTestCase {
     fastCacheNew.put(103, "103");
     assertEquals("90", fastCacheNew.get(90));
     assertEquals("50", fastCacheNew.get(50));
-    nl = fastCacheNew.getStatistics();
+    nl = metrics.getValue();
     assertEquals(2L, nl.get("lookups"));
     assertEquals(2L, nl.get("hits"));
     assertEquals(1L, nl.get("inserts"));
@@ -86,6 +94,7 @@ public class TestFastLRUCache extends LuceneTestCase {
   
   private void doTestPercentageAutowarm(int limit, int percentage, int[] hits, int[]misses) {
     FastLRUCache<Object, Object> fastCache = new FastLRUCache<>();
+    fastCache.initializeMetrics(metricManager, registry, scope);
     Map<String, String> params = new HashMap<>();
     params.put("size", String.valueOf(limit));
     params.put("initialSize", "10");
@@ -98,6 +107,7 @@ public class TestFastLRUCache extends LuceneTestCase {
     }
 
     FastLRUCache<Object, Object> fastCacheNew = new FastLRUCache<>();
+    fastCacheNew.initializeMetrics(metricManager, registry, scope);
     fastCacheNew.init(params, o, cr);
     fastCacheNew.warm(null, fastCache);
     fastCacheNew.setState(SolrCache.State.LIVE);
@@ -110,7 +120,7 @@ public class TestFastLRUCache extends LuceneTestCase {
     for(int miss:misses) {
       assertEquals("The value " + miss + " should NOT be on new cache", null, fastCacheNew.get(miss));
     }
-    NamedList<Serializable> nl = fastCacheNew.getStatistics();
+    Map<String,Object> nl = fastCacheNew.getMetrics().getValue();
     assertEquals(Long.valueOf(hits.length + misses.length), nl.get("lookups"));
     assertEquals(Long.valueOf(hits.length), nl.get("hits"));
     fastCacheNew.close();
@@ -118,6 +128,7 @@ public class TestFastLRUCache extends LuceneTestCase {
   
   public void testNoAutowarm() throws IOException {
     FastLRUCache<Object, Object> fastCache = new FastLRUCache<>();
+    fastCache.initializeMetrics(metricManager, registry, scope);
     Map<String, String> params = new HashMap<>();
     params.put("size", "100");
     params.put("initialSize", "10");
@@ -129,7 +140,7 @@ public class TestFastLRUCache extends LuceneTestCase {
     }
     assertEquals("25", fastCache.get(25));
     assertEquals(null, fastCache.get(110));
-    NamedList<Serializable> nl = fastCache.getStatistics();
+    Map<String,Object> nl = fastCache.getMetrics().getValue();
     assertEquals(2L, nl.get("lookups"));
     assertEquals(1L, nl.get("hits"));
     assertEquals(101L, nl.get("inserts"));
@@ -177,6 +188,7 @@ public class TestFastLRUCache extends LuceneTestCase {
   
   public void testSimple() throws IOException {
     FastLRUCache sc = new FastLRUCache();
+    sc.initializeMetrics(metricManager, registry, scope);
     Map l = new HashMap();
     l.put("size", "100");
     l.put("initialSize", "10");
@@ -189,7 +201,8 @@ public class TestFastLRUCache extends LuceneTestCase {
     }
     assertEquals("25", sc.get(25));
     assertEquals(null, sc.get(110));
-    NamedList nl = sc.getStatistics();
+    MetricsMap metrics = sc.getMetrics();
+    Map<String,Object> nl = metrics.getValue();
     assertEquals(2L, nl.get("lookups"));
     assertEquals(1L, nl.get("hits"));
     assertEquals(101L, nl.get("inserts"));
@@ -198,6 +211,7 @@ public class TestFastLRUCache extends LuceneTestCase {
 
 
     FastLRUCache scNew = new FastLRUCache();
+    scNew.initializeMetrics(metricManager, registry, scope);
     scNew.init(l, o, cr);
     scNew.warm(null, sc);
     scNew.setState(SolrCache.State.LIVE);
@@ -205,7 +219,7 @@ public class TestFastLRUCache extends LuceneTestCase {
     scNew.put(103, "103");
     assertEquals("90", scNew.get(90));
     assertEquals(null, scNew.get(50));
-    nl = scNew.getStatistics();
+    nl = scNew.getMetrics().getValue();
     assertEquals(2L, nl.get("lookups"));
     assertEquals(1L, nl.get("hits"));
     assertEquals(1L, nl.get("inserts"));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java b/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java
index 8fe3f97..c36066a 100644
--- a/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java
+++ b/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java
@@ -17,6 +17,7 @@
 package org.apache.solr.search;
 
 import java.io.IOException;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CountDownLatch;
@@ -25,6 +26,8 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import com.codahale.metrics.Gauge;
+import com.codahale.metrics.Metric;
 import com.google.common.collect.ImmutableMap;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexReaderContext;
@@ -137,13 +140,15 @@ public class TestIndexSearcher extends SolrTestCaseJ4 {
     int baseRefCount = r3.getRefCount();
     assertEquals(1, baseRefCount);
 
-    Object sr3SearcherRegAt = sr3.getSearcher().getStatistics().get("registeredAt");
+    Map<String, Metric> metrics = h.getCore().getCoreMetricManager().getRegistry().getMetrics();
+    Gauge<Date> g = (Gauge<Date>)metrics.get("SEARCHER.searcher.registeredAt");
+    Date sr3SearcherRegAt = g.getValue();
     assertU(commit()); // nothing has changed
     SolrQueryRequest sr4 = req("q","foo");
     assertSame("nothing changed, searcher should be the same",
                sr3.getSearcher(), sr4.getSearcher());
     assertEquals("nothing changed, searcher should not have been re-registered",
-                 sr3SearcherRegAt, sr4.getSearcher().getStatistics().get("registeredAt"));
+                 sr3SearcherRegAt, g.getValue());
     IndexReader r4 = sr4.getSearcher().getRawReader();
 
     // force an index change so the registered searcher won't be the one we are testing (and

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/search/TestLFUCache.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestLFUCache.java b/solr/core/src/test/org/apache/solr/search/TestLFUCache.java
index d137875..d4f86fe 100644
--- a/solr/core/src/test/org/apache/solr/search/TestLFUCache.java
+++ b/solr/core/src/test/org/apache/solr/search/TestLFUCache.java
@@ -16,9 +16,11 @@
  */
 package org.apache.solr.search;
 
+import org.apache.lucene.util.TestUtil;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.util.ExecutorUtil;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.util.ConcurrentLFUCache;
 import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.apache.solr.util.RefCounted;
@@ -32,6 +34,7 @@ import java.lang.invoke.MethodHandles;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Random;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
@@ -59,7 +62,7 @@ public class TestLFUCache extends SolrTestCaseJ4 {
       SolrIndexSearcher searcher = holder.get();
       LFUCache cacheDecayTrue = (LFUCache) searcher.getCache("lfuCacheDecayTrue");
       assertNotNull(cacheDecayTrue);
-      NamedList stats = cacheDecayTrue.getStatistics();
+      Map<String,Object> stats = cacheDecayTrue.getMetrics().getValue();
       assertTrue((Boolean) stats.get("timeDecay"));
       addCache(cacheDecayTrue, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
       for (int idx = 0; idx < 64; ++idx) {
@@ -70,7 +73,7 @@ public class TestLFUCache extends SolrTestCaseJ4 {
 
       LFUCache cacheDecayDefault = (LFUCache) searcher.getCache("lfuCacheDecayDefault");
       assertNotNull(cacheDecayDefault);
-      stats = cacheDecayDefault.getStatistics();
+      stats = cacheDecayDefault.getMetrics().getValue();
       assertTrue((Boolean) stats.get("timeDecay"));
       addCache(cacheDecayDefault, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
       assertCache(cacheDecayDefault, 1, 2, 3, 4, 5);
@@ -84,7 +87,7 @@ public class TestLFUCache extends SolrTestCaseJ4 {
 
       LFUCache cacheDecayFalse = (LFUCache) searcher.getCache("lfuCacheDecayFalse");
       assertNotNull(cacheDecayFalse);
-      stats = cacheDecayFalse.getStatistics();
+      stats = cacheDecayFalse.getMetrics().getValue();
       assertFalse((Boolean) stats.get("timeDecay"));
       addCache(cacheDecayFalse, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
       assertCache(cacheDecayFalse, 1, 2, 3, 4, 5);
@@ -131,9 +134,16 @@ public class TestLFUCache extends SolrTestCaseJ4 {
 
   @Test
   public void testSimple() throws IOException {
+    SolrMetricManager metricManager = new SolrMetricManager();
+    Random r = random();
+    String registry = TestUtil.randomSimpleString(r, 2, 10);
+    String scope = TestUtil.randomSimpleString(r, 2, 10);
     LFUCache lfuCache = new LFUCache();
     LFUCache newLFUCache = new LFUCache();
     LFUCache noWarmLFUCache = new LFUCache();
+    lfuCache.initializeMetrics(metricManager, registry, scope + ".lfuCache");
+    newLFUCache.initializeMetrics(metricManager, registry, scope + ".newLFUCache");
+    noWarmLFUCache.initializeMetrics(metricManager, registry, scope + ".noWarmLFUCache");
     try {
       Map params = new HashMap();
       params.put("size", "100");
@@ -148,7 +158,7 @@ public class TestLFUCache extends SolrTestCaseJ4 {
       assertEquals("15", lfuCache.get(15));
       assertEquals("75", lfuCache.get(75));
       assertEquals(null, lfuCache.get(110));
-      NamedList nl = lfuCache.getStatistics();
+      Map<String,Object> nl = lfuCache.getMetrics().getValue();
       assertEquals(3L, nl.get("lookups"));
       assertEquals(2L, nl.get("hits"));
       assertEquals(101L, nl.get("inserts"));
@@ -164,7 +174,7 @@ public class TestLFUCache extends SolrTestCaseJ4 {
       assertEquals("15", newLFUCache.get(15));
       assertEquals("75", newLFUCache.get(75));
       assertEquals(null, newLFUCache.get(50));
-      nl = newLFUCache.getStatistics();
+      nl = newLFUCache.getMetrics().getValue();
       assertEquals(3L, nl.get("lookups"));
       assertEquals(2L, nl.get("hits"));
       assertEquals(1L, nl.get("inserts"));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/search/TestLRUCache.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestLRUCache.java b/solr/core/src/test/org/apache/solr/search/TestLRUCache.java
index d2f74de..b1b6deb 100644
--- a/solr/core/src/test/org/apache/solr/search/TestLRUCache.java
+++ b/solr/core/src/test/org/apache/solr/search/TestLRUCache.java
@@ -17,21 +17,25 @@
 package org.apache.solr.search;
 
 import java.io.IOException;
-import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.RamUsageEstimator;
+import org.apache.lucene.util.TestUtil;
 import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.NamedList;
+import org.apache.solr.metrics.SolrMetricManager;
 
 /**
  * Test for <code>org.apache.solr.search.LRUCache</code>
  */
 public class TestLRUCache extends LuceneTestCase {
 
+  SolrMetricManager metricManager = new SolrMetricManager();
+  String registry = TestUtil.randomSimpleString(random(), 2, 10);
+  String scope = TestUtil.randomSimpleString(random(), 2, 10);
+
   public void testFullAutowarm() throws IOException {
     LRUCache<Object, Object> lruCache = new LRUCache<>();
     Map<String, String> params = new HashMap<>();
@@ -97,6 +101,7 @@ public class TestLRUCache extends LuceneTestCase {
   @SuppressWarnings("unchecked")
   public void testNoAutowarm() throws IOException {
     LRUCache<Object, Object> lruCache = new LRUCache<>();
+    lruCache.initializeMetrics(metricManager, registry, scope);
     Map<String, String> params = new HashMap<>();
     params.put("size", "100");
     params.put("initialSize", "10");
@@ -108,7 +113,7 @@ public class TestLRUCache extends LuceneTestCase {
     }
     assertEquals("25", lruCache.get(25));
     assertEquals(null, lruCache.get(110));
-    NamedList<Serializable> nl = lruCache.getStatistics();
+    Map<String,Object> nl = lruCache.getMetrics().getValue();
     assertEquals(2L, nl.get("lookups"));
     assertEquals(1L, nl.get("hits"));
     assertEquals(101L, nl.get("inserts"));
@@ -126,6 +131,7 @@ public class TestLRUCache extends LuceneTestCase {
 
   public void testMaxRamSize() throws Exception {
     LRUCache<String, Accountable> accountableLRUCache = new LRUCache<>();
+    accountableLRUCache.initializeMetrics(metricManager, registry, scope);
     Map<String, String> params = new HashMap<>();
     params.put("size", "5");
     params.put("maxRamMB", "1");
@@ -149,7 +155,7 @@ public class TestLRUCache extends LuceneTestCase {
     });
     assertEquals(1, accountableLRUCache.size());
     assertEquals(baseSize + 512 * 1024 + LRUCache.LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY + LRUCache.DEFAULT_RAM_BYTES_USED, accountableLRUCache.ramBytesUsed());
-    NamedList<Serializable> nl = accountableLRUCache.getStatistics();
+    Map<String,Object> nl = accountableLRUCache.getMetrics().getValue();
     assertEquals(1L, nl.get("evictions"));
     assertEquals(1L, nl.get("evictionsRamUsage"));
     accountableLRUCache.put("3", new Accountable() {
@@ -158,7 +164,7 @@ public class TestLRUCache extends LuceneTestCase {
         return 1024;
       }
     });
-    nl = accountableLRUCache.getStatistics();
+    nl = accountableLRUCache.getMetrics().getValue();
     assertEquals(1L, nl.get("evictions"));
     assertEquals(1L, nl.get("evictionsRamUsage"));
     assertEquals(2L, accountableLRUCache.size());

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
index e1620e1..9afcc6b 100644
--- a/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
@@ -16,11 +16,14 @@
  */
 package org.apache.solr.search;
 
+import java.util.Map;
+
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrInfoBean;
+import org.apache.solr.metrics.MetricsMap;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -376,8 +379,8 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
         "//result/doc[5]/float[@name='id'][.='2.0']"
     );
 
-    SolrInfoBean info  = h.getCore().getInfoRegistry().get("queryResultCache");
-    NamedList stats = info.getStatistics();
+    MetricsMap metrics = (MetricsMap)h.getCore().getCoreMetricManager().getRegistry().getMetrics().get("CACHE.searcher.queryResultCache");
+    Map<String,Object> stats = metrics.getValue();
 
     long inserts = (Long) stats.get("inserts");
 
@@ -401,8 +404,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
     );
 
 
-    info  = h.getCore().getInfoRegistry().get("queryResultCache");
-    stats = info.getStatistics();
+    stats = metrics.getValue();
 
     long inserts1 = (Long) stats.get("inserts");
 
@@ -426,8 +428,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
         "//result/doc[5]/float[@name='id'][.='1.0']"
     );
 
-    info  = h.getCore().getInfoRegistry().get("queryResultCache");
-    stats = info.getStatistics();
+    stats = metrics.getValue();
     long inserts2 = (Long) stats.get("inserts");
     //Last query was NOT added to the cache
     assertTrue(inserts1 == inserts2);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
index 1fcfe9a..b909f15 100644
--- a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
@@ -20,6 +20,7 @@ import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.FacetParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.metrics.MetricsMap;
 import org.apache.solr.request.SolrQueryRequest;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -117,13 +118,13 @@ public class TestSolr4Spatial2 extends SolrTestCaseJ4 {
 
     // The tricky thing is verifying the cache works correctly...
 
-    SolrCache cache = (SolrCache) h.getCore().getInfoRegistry().get("perSegSpatialFieldCache_srptgeom");
-    assertEquals("1", cache.getStatistics().get("cumulative_inserts").toString());
-    assertEquals("0", cache.getStatistics().get("cumulative_hits").toString());
+    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", cache.getStatistics().get("cumulative_hits").toString());
+    assertEquals("1", cacheMetrics.getValue().get("cumulative_hits").toString());
 
     assertEquals("1 segment",
         1, getSearcher().getRawReader().leaves().size());
@@ -141,7 +142,7 @@ public class TestSolr4Spatial2 extends SolrTestCaseJ4 {
     // 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", cache.getStatistics().get("cumulative_hits").toString());
+    assertEquals(leafKey1.equals(leafKey2) ? "2" : "1", cacheMetrics.getValue().get("cumulative_hits").toString());
 
 
     // Now try to see if heatmaps work:

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java b/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java
index 315f802..c86d7f7 100644
--- a/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java
@@ -29,6 +29,7 @@ import org.apache.lucene.search.TermInSetQuery;
 import org.apache.lucene.search.TermQuery;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.core.SolrInfoBean;
+import org.apache.solr.metrics.MetricsMap;
 import org.apache.solr.parser.QueryParser;
 import org.apache.solr.query.FilterQuery;
 import org.apache.solr.request.SolrQueryRequest;
@@ -353,33 +354,33 @@ public class TestSolrQueryParser extends SolrTestCaseJ4 {
     assertU(commit());  // arg... commit no longer "commits" unless there has been a change.
 
 
-    final SolrInfoBean filterCacheStats
-        = h.getCore().getInfoRegistry().get("filterCache");
+    final MetricsMap filterCacheStats = (MetricsMap)h.getCore().getCoreMetricManager().getRegistry()
+        .getMetrics().get("CACHE.searcher.filterCache");
     assertNotNull(filterCacheStats);
-    final SolrInfoBean queryCacheStats
-        = h.getCore().getInfoRegistry().get("queryResultCache");
+    final MetricsMap queryCacheStats = (MetricsMap)h.getCore().getCoreMetricManager().getRegistry()
+        .getMetrics().get("CACHE.searcher.queryResultCache");
 
     assertNotNull(queryCacheStats);
 
 
-    long inserts = (Long) filterCacheStats.getStatistics().get("inserts");
-    long hits = (Long) filterCacheStats.getStatistics().get("hits");
+    long inserts = (Long) filterCacheStats.getValue().get("inserts");
+    long hits = (Long) filterCacheStats.getValue().get("hits");
 
     assertJQ(req("q", "doesnotexist filter(id:1) filter(qqq_s:X) filter(abcdefg)")
         , "/response/numFound==2"
     );
 
     inserts += 3;
-    assertEquals(inserts, ((Long) filterCacheStats.getStatistics().get("inserts")).longValue());
-    assertEquals(hits, ((Long) filterCacheStats.getStatistics().get("hits")).longValue());
+    assertEquals(inserts, ((Long) filterCacheStats.getValue().get("inserts")).longValue());
+    assertEquals(hits, ((Long) filterCacheStats.getValue().get("hits")).longValue());
 
     assertJQ(req("q", "doesnotexist2 filter(id:1) filter(qqq_s:X) filter(abcdefg)")
         , "/response/numFound==2"
     );
 
     hits += 3;
-    assertEquals(inserts, ((Long) filterCacheStats.getStatistics().get("inserts")).longValue());
-    assertEquals(hits, ((Long) filterCacheStats.getStatistics().get("hits")).longValue());
+    assertEquals(inserts, ((Long) filterCacheStats.getValue().get("inserts")).longValue());
+    assertEquals(hits, ((Long) filterCacheStats.getValue().get("hits")).longValue());
 
     // make sure normal "fq" parameters also hit the cache the same way
     assertJQ(req("q", "doesnotexist3", "fq", "id:1", "fq", "qqq_s:X", "fq", "abcdefg")
@@ -387,8 +388,8 @@ public class TestSolrQueryParser extends SolrTestCaseJ4 {
     );
 
     hits += 3;
-    assertEquals(inserts, ((Long) filterCacheStats.getStatistics().get("inserts")).longValue());
-    assertEquals(hits, ((Long) filterCacheStats.getStatistics().get("hits")).longValue());
+    assertEquals(inserts, ((Long) filterCacheStats.getValue().get("inserts")).longValue());
+    assertEquals(hits, ((Long) filterCacheStats.getValue().get("hits")).longValue());
 
     // try a query deeply nested in a FQ
     assertJQ(req("q", "*:* doesnotexist4", "fq", "(id:* +(filter(id:1) filter(qqq_s:X) filter(abcdefg)) )")
@@ -397,8 +398,8 @@ public class TestSolrQueryParser extends SolrTestCaseJ4 {
 
     inserts += 1;  // +1 for top level fq
     hits += 3;
-    assertEquals(inserts, ((Long) filterCacheStats.getStatistics().get("inserts")).longValue());
-    assertEquals(hits, ((Long) filterCacheStats.getStatistics().get("hits")).longValue());
+    assertEquals(inserts, ((Long) filterCacheStats.getValue().get("inserts")).longValue());
+    assertEquals(hits, ((Long) filterCacheStats.getValue().get("hits")).longValue());
 
     // retry the complex FQ and make sure hashCode/equals works as expected w/ filter queries
     assertJQ(req("q", "*:* doesnotexist5", "fq", "(id:* +(filter(id:1) filter(qqq_s:X) filter(abcdefg)) )")
@@ -406,8 +407,8 @@ public class TestSolrQueryParser extends SolrTestCaseJ4 {
     );
 
     hits += 1;  // top-level fq should have been found.
-    assertEquals(inserts, ((Long) filterCacheStats.getStatistics().get("inserts")).longValue());
-    assertEquals(hits, ((Long) filterCacheStats.getStatistics().get("hits")).longValue());
+    assertEquals(inserts, ((Long) filterCacheStats.getValue().get("inserts")).longValue());
+    assertEquals(hits, ((Long) filterCacheStats.getValue().get("hits")).longValue());
 
 
     // try nested filter with multiple top-level args (i.e. a boolean query)
@@ -417,8 +418,8 @@ public class TestSolrQueryParser extends SolrTestCaseJ4 {
 
     hits += 1;  // the inner filter
     inserts += 1; // the outer filter
-    assertEquals(inserts, ((Long) filterCacheStats.getStatistics().get("inserts")).longValue());
-    assertEquals(hits, ((Long) filterCacheStats.getStatistics().get("hits")).longValue());
+    assertEquals(inserts, ((Long) filterCacheStats.getValue().get("inserts")).longValue());
+    assertEquals(hits, ((Long) filterCacheStats.getValue().get("hits")).longValue());
 
     // test the score for a filter, and that default score is 0
     assertJQ(req("q", "+filter(*:*) +filter(id:1)", "fl", "id,score", "sort", "id asc")

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e8a42b2/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java b/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java
index 39fa791..8c2cec3 100644
--- a/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java
+++ b/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java
@@ -19,8 +19,7 @@ package org.apache.solr.search.join;
 import org.apache.lucene.search.join.ScoreMode;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.search.SolrCache;
+import org.apache.solr.metrics.MetricsMap;
 import org.apache.solr.util.BaseTestHarness;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -32,6 +31,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Locale;
+import java.util.Map;
 
 import javax.xml.xpath.XPathConstants;
 
@@ -276,15 +276,15 @@ public class BJQParserTest extends SolrTestCaseJ4 {
   @Test
   public void testCacheHit() throws IOException {
 
-    SolrCache parentFilterCache = (SolrCache) h.getCore().getInfoRegistry()
-        .get("perSegFilter");
+    MetricsMap parentFilterCache = (MetricsMap)h.getCore().getCoreMetricManager().getRegistry()
+        .getMetrics().get("CACHE.searcher.perSegFilter");
+    MetricsMap filterCache = (MetricsMap)h.getCore().getCoreMetricManager().getRegistry()
+        .getMetrics().get("CACHE.searcher.filterCache");
 
-    SolrCache filterCache = (SolrCache) h.getCore().getInfoRegistry()
-        .get("filterCache");
 
-    NamedList parentsBefore = parentFilterCache.getStatistics();
+    Map<String,Object> parentsBefore = parentFilterCache.getValue();
 
-    NamedList filtersBefore = filterCache.getStatistics();
+    Map<String,Object> filtersBefore = filterCache.getValue();
 
     // it should be weird enough to be uniq
     String parentFilter = "parent_s:([a TO c] [d TO f])";
@@ -298,7 +298,7 @@ public class BJQParserTest extends SolrTestCaseJ4 {
         "//*[@numFound='6']");
 
     assertEquals("didn't hit fqCache yet ", 0L,
-        delta("hits", filterCache.getStatistics(), filtersBefore));
+        delta("hits", filterCache.getValue(), filtersBefore));
 
     assertQ(
         "filter by join",
@@ -306,18 +306,18 @@ public class BJQParserTest extends SolrTestCaseJ4 {
             + "\"}child_s:l"), "//*[@numFound='6']");
 
     assertEquals("in cache mode every request lookups", 3,
-        delta("lookups", parentFilterCache.getStatistics(), parentsBefore));
+        delta("lookups", parentFilterCache.getValue(), parentsBefore));
     assertEquals("last two lookups causes hits", 2,
-        delta("hits", parentFilterCache.getStatistics(), parentsBefore));
+        delta("hits", parentFilterCache.getValue(), parentsBefore));
     assertEquals("the first lookup gets insert", 1,
-        delta("inserts", parentFilterCache.getStatistics(), parentsBefore));
+        delta("inserts", parentFilterCache.getValue(), parentsBefore));
 
 
     assertEquals("true join query is cached in fqCache", 1L,
-        delta("lookups", filterCache.getStatistics(), filtersBefore));
+        delta("lookups", filterCache.getValue(), filtersBefore));
   }
   
-  private long delta(String key, NamedList a, NamedList b) {
+  private long delta(String key, Map<String,Object> a, Map<String,Object> b) {
     return (Long) a.get(key) - (Long) b.get(key);
   }
 


Mime
View raw message