lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [37/44] lucene-solr:jira/solr-9854: SOLR-4735 Un-staticize SolrMetricManager and other fixes: * static methods and SharedMetricsRegistries caused issues when multiple CoreContainers were present under the same classloader. * However, use SharedMetricsReg
Date Tue, 20 Dec 2016 10:48:42 GMT
SOLR-4735 Un-staticize SolrMetricManager and other fixes:
* static methods and SharedMetricsRegistries caused issues
when multiple CoreContainers were present under the same classloader.
* However, use SharedMetricsRegistries for solr.jetty and solr.jvm registries.
* fix JVM metrics registration to use a prefix.


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

Branch: refs/heads/jira/solr-9854
Commit: adfb4a5052afc0885905702d4858a303b2f710ae
Parents: 67dc760
Author: Andrzej Bialecki <ab@apache.org>
Authored: Mon Dec 19 21:29:29 2016 +0100
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Mon Dec 19 21:29:29 2016 +0100

----------------------------------------------------------------------
 .../org/apache/solr/core/CoreContainer.java     |  29 +++--
 .../src/java/org/apache/solr/core/SolrCore.java |  36 +++---
 .../apache/solr/handler/RequestHandlerBase.java |  14 +--
 .../solr/handler/admin/MetricsHandler.java      |   9 +-
 .../solr/metrics/SolrCoreMetricManager.java     |  14 ++-
 .../apache/solr/metrics/SolrMetricManager.java  | 114 +++++++++++++------
 .../apache/solr/metrics/SolrMetricProducer.java |   4 +-
 .../apache/solr/metrics/SolrMetricReporter.java |   5 +-
 .../solr/metrics/reporters/SolrJmxReporter.java |   6 +-
 .../apache/solr/servlet/SolrDispatchFilter.java |  16 +--
 .../solr/metrics/SolrCoreMetricManagerTest.java |  42 +++----
 .../solr/metrics/SolrMetricManagerTest.java     |  83 ++++++++------
 .../solr/metrics/SolrMetricReporterTest.java    |   4 +-
 .../solr/metrics/SolrMetricTestUtils.java       |   6 +-
 .../metrics/SolrMetricsIntegrationTest.java     |  16 +--
 .../metrics/reporters/MockMetricReporter.java   |   6 +-
 .../metrics/reporters/SolrJmxReporterTest.java  |  26 +++--
 .../java/org/apache/solr/util/TestHarness.java  |  10 +-
 18 files changed, 260 insertions(+), 180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/java/org/apache/solr/core/CoreContainer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 0703212..6e640bc 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -161,6 +161,8 @@ public class CoreContainer {
 
   private BackupRepositoryFactory backupRepoFactory;
 
+  protected SolrMetricManager metricManager;
+
   protected MetricsHandler metricsHandler;
 
   /**
@@ -430,6 +432,10 @@ public class CoreContainer {
     return pkiAuthenticationPlugin;
   }
 
+  public SolrMetricManager getMetricManager() {
+    return metricManager;
+  }
+
   //-------------------------------------------------------------------
   // Initialization / Cleanup
   //-------------------------------------------------------------------
@@ -470,6 +476,8 @@ public class CoreContainer {
 
     MDCLoggingContext.setNode(this);
 
+    metricManager = new SolrMetricManager();
+
     securityConfHandler = isZooKeeperAware() ? new SecurityConfHandlerZk(this) : new SecurityConfHandlerLocal(this);
     reloadSecurityProperties();
     this.backupRepoFactory = new BackupRepositoryFactory(cfg.getBackupRepositoryPlugins());
@@ -481,12 +489,15 @@ public class CoreContainer {
     configSetsHandler = createHandler(CONFIGSETS_HANDLER_PATH, cfg.getConfigSetsHandlerClass(), ConfigSetsHandler.class);
     metricsHandler = createHandler(METRICS_PATH, MetricsHandler.class.getName(), MetricsHandler.class);
     containerHandlers.put(AUTHZ_PATH, securityConfHandler);
-    securityConfHandler.initializeMetrics(SolrInfoMBean.Group.node.toString(), AUTHZ_PATH);
+    securityConfHandler.initializeMetrics(metricManager, SolrInfoMBean.Group.node.toString(), AUTHZ_PATH);
     containerHandlers.put(AUTHC_PATH, securityConfHandler);
     if(pkiAuthenticationPlugin != null)
       containerHandlers.put(PKIAuthenticationPlugin.PATH, pkiAuthenticationPlugin.getRequestHandler());
 
-    SolrMetricManager.loadReporters(cfg.getMetricReporterPlugins(), loader, SolrInfoMBean.Group.node);
+    metricManager.loadReporters(cfg.getMetricReporterPlugins(), loader, SolrInfoMBean.Group.node);
+    metricManager.loadReporters(cfg.getMetricReporterPlugins(), loader, SolrInfoMBean.Group.jvm);
+    metricManager.loadReporters(cfg.getMetricReporterPlugins(), loader, SolrInfoMBean.Group.jetty);
+    metricManager.loadReporters(cfg.getMetricReporterPlugins(), loader, SolrInfoMBean.Group.http);
 
     coreConfigService = ConfigSetService.createConfigSetService(cfg, loader, zkSys.zkController);
 
@@ -497,11 +508,11 @@ public class CoreContainer {
     Gauge<Integer> lazyCores = () -> solrCores.getCoreNames().size() - solrCores.getCores().size();
     Gauge<Integer> unloadedCores = () -> solrCores.getAllCoreNames().size() - solrCores.getCoreNames().size();
 
-    SolrMetricManager.register(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node),
+    metricManager.register(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node),
         loadedCores, true, "loaded", "cores");
-    SolrMetricManager.register(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node),
+    metricManager.register(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node),
         lazyCores, true, "lazy", "cores");
-    SolrMetricManager.register(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node),
+    metricManager.register(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node),
         unloadedCores, true, "unloaded", "cores");
 
     // setup executor to load cores in parallel
@@ -677,7 +688,9 @@ public class CoreContainer {
       }
     }
 
-    SolrMetricManager.closeReporters(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node));
+    if (metricManager != null) {
+      metricManager.closeReporters(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node));
+    }
 
     // It should be safe to close the authorization plugin at this point.
     try {
@@ -1056,7 +1069,7 @@ public class CoreContainer {
     coresLocator.delete(this, cd);
 
     // delete metrics specific to this core
-    SolrMetricManager.removeRegistry(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.core, name));
+    metricManager.removeRegistry(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.core, name));
 
     if (core == null) {
       // transient core
@@ -1197,7 +1210,7 @@ public class CoreContainer {
       containerHandlers.put(path, (SolrRequestHandler)handler);
     }
     if (handler instanceof SolrMetricProducer) {
-      ((SolrMetricProducer)handler).initializeMetrics(SolrInfoMBean.Group.node.toString(), path);
+      ((SolrMetricProducer)handler).initializeMetrics(metricManager, SolrInfoMBean.Group.node.toString(), path);
     }
     return handler;
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/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 4a63686..3d78c40 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -192,7 +192,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
   private final PluginBag<SearchComponent> searchComponents = new PluginBag<>(SearchComponent.class, this);
   private final PluginBag<UpdateRequestProcessorFactory> updateProcessors = new PluginBag<>(UpdateRequestProcessorFactory.class, this, true);
   private final Map<String,UpdateRequestProcessorChain> updateProcessorChains;
-  private final SolrCoreMetricManager metricManager;
+  private final SolrCoreMetricManager coreMetricManager;
   private final Map<String, SolrInfoMBean> infoRegistry;
   private final IndexDeletionPolicyWrapper solrDelPolicy;
   private final SolrSnapshotMetaDataManager snapshotMgr;
@@ -402,8 +402,8 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
     this.name = v;
     this.logid = (v==null)?"":("["+v+"] ");
     this.coreDescriptor = new CoreDescriptor(v, this.coreDescriptor);
-    if (metricManager != null) {
-      metricManager.afterCoreSetName();
+    if (coreMetricManager != null) {
+      coreMetricManager.afterCoreSetName();
     }
   }
 
@@ -417,8 +417,8 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
    *
    * @return the {@link SolrCoreMetricManager} for this core
    */
-  public SolrCoreMetricManager getMetricManager() {
-    return metricManager;
+  public SolrCoreMetricManager getCoreMetricManager() {
+    return coreMetricManager;
   }
 
   /**
@@ -864,14 +864,16 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
     checkVersionFieldExistsInSchema(schema, coreDescriptor);
 
     // Initialize the metrics manager
-    this.metricManager = initMetricManager(config);
+    this.coreMetricManager = initCoreMetricManager(config);
+
+    SolrMetricManager metricManager = this.coreDescriptor.getCoreContainer().getMetricManager();
 
     // initialize searcher-related metrics
-    newSearcherCounter = SolrMetricManager.counter(metricManager.getRegistryName(), "newSearcher");
-    newSearcherTimer = SolrMetricManager.timer(metricManager.getRegistryName(), "newSearcherTime");
-    newSearcherWarmupTimer = SolrMetricManager.timer(metricManager.getRegistryName(), "newSearcherWarmup");
-    newSearcherMaxReachedCounter = SolrMetricManager.counter(metricManager.getRegistryName(), "newSearcherMaxReached");
-    newSearcherOtherErrorsCounter = SolrMetricManager.counter(metricManager.getRegistryName(), "newSearcherErrors");
+    newSearcherCounter = metricManager.counter(coreMetricManager.getRegistryName(), "newSearcher");
+    newSearcherTimer = metricManager.timer(coreMetricManager.getRegistryName(), "newSearcherTime");
+    newSearcherWarmupTimer = metricManager.timer(coreMetricManager.getRegistryName(), "newSearcherWarmup");
+    newSearcherMaxReachedCounter = metricManager.counter(coreMetricManager.getRegistryName(), "newSearcherMaxReached");
+    newSearcherOtherErrorsCounter = metricManager.counter(coreMetricManager.getRegistryName(), "newSearcherErrors");
 
     // Initialize JMX
     this.infoRegistry = initInfoRegistry(name, config);
@@ -1083,10 +1085,10 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
    * @param config the given configuration
    * @return an instance of {@link SolrCoreMetricManager}
    */
-  private SolrCoreMetricManager initMetricManager(SolrConfig config) {
-    SolrCoreMetricManager metricManager = new SolrCoreMetricManager(this);
-    metricManager.loadReporters();
-    return metricManager;
+  private SolrCoreMetricManager initCoreMetricManager(SolrConfig config) {
+    SolrCoreMetricManager coreMetricManager = new SolrCoreMetricManager(this);
+    coreMetricManager.loadReporters();
+    return coreMetricManager;
   }
 
   private Map<String,SolrInfoMBean> initInfoRegistry(String name, SolrConfig config) {
@@ -1410,7 +1412,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
     }
 
     try {
-      metricManager.close();
+      coreMetricManager.close();
     } catch (Throwable e) {
       SolrException.log(log, e);
       if (e instanceof  Error) {
@@ -2819,7 +2821,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
 
     if (solrInfoMBean instanceof SolrMetricProducer) {
       SolrMetricProducer producer = (SolrMetricProducer) solrInfoMBean;
-      metricManager.registerMetricProducer(name, producer);
+      coreMetricManager.registerMetricProducer(name, producer);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java
index 7d9d464..85597dc 100644
--- a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java
+++ b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java
@@ -133,13 +133,13 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo
   }
 
   @Override
-  public Collection<String> initializeMetrics(String registryName, String scope) {
-    numErrors = SolrMetricManager.meter(registryName, "errors", getCategory().toString(), scope);
-    numServerErrors = SolrMetricManager.meter(registryName, "serverErrors", getCategory().toString(), scope);
-    numClientErrors = SolrMetricManager.meter(registryName, "clientErrors", getCategory().toString(), scope);
-    numTimeouts = SolrMetricManager.meter(registryName, "timeouts", getCategory().toString(), scope);
-    requests = SolrMetricManager.counter(registryName, "requests", getCategory().toString(), scope);
-    requestTimes = SolrMetricManager.timer(registryName, "requestTimes", getCategory().toString(), scope);
+  public Collection<String> initializeMetrics(SolrMetricManager manager, String registryName, String scope) {
+    numErrors = manager.meter(registryName, "errors", getCategory().toString(), scope);
+    numServerErrors = manager.meter(registryName, "serverErrors", getCategory().toString(), scope);
+    numClientErrors = manager.meter(registryName, "clientErrors", getCategory().toString(), scope);
+    numTimeouts = manager.meter(registryName, "timeouts", getCategory().toString(), scope);
+    requests = manager.counter(registryName, "requests", getCategory().toString(), scope);
+    requestTimes = manager.timer(registryName, "requestTimes", getCategory().toString(), scope);
     return Arrays.asList("errors", "serverErrors", "clientErrors", "timeouts", "requestTimes", "requests");
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
index 1adc480..78b2045 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
@@ -48,13 +48,16 @@ import org.apache.solr.util.stats.MetricUtils;
  */
 public class MetricsHandler extends RequestHandlerBase implements PermissionNameProvider {
   final CoreContainer container;
+  final SolrMetricManager metricManager;
 
   public MetricsHandler() {
     this.container = null;
+    this.metricManager = null;
   }
 
   public MetricsHandler(CoreContainer container) {
     this.container = container;
+    this.metricManager = this.container.getMetricManager();
   }
 
   @Override
@@ -80,13 +83,13 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionName
         container.getAllCoreNames().forEach(s -> {
           String coreRegistryName;
           try (SolrCore core = container.getCore(s)) {
-            coreRegistryName = core.getMetricManager().getRegistryName();
+            coreRegistryName = core.getCoreMetricManager().getRegistryName();
           }
-          MetricRegistry registry = SolrMetricManager.registry(coreRegistryName);
+          MetricRegistry registry = metricManager.registry(coreRegistryName);
           response.add(coreRegistryName, MetricUtils.toNamedList(registry, metricFilters));
         });
       } else {
-        MetricRegistry registry = SolrMetricManager.registry(registryName);
+        MetricRegistry registry = metricManager.registry(registryName);
         response.add(registryName, MetricUtils.toNamedList(registry, metricFilters));
       }
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/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 18307ee..0e5403b 100644
--- a/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
+++ b/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
@@ -37,6 +37,7 @@ public class SolrCoreMetricManager implements Closeable {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   private final SolrCore core;
+  private final SolrMetricManager metricManager;
   private String registryName;
 
   /**
@@ -46,6 +47,7 @@ public class SolrCoreMetricManager implements Closeable {
    */
   public SolrCoreMetricManager(SolrCore core) {
     this.core = core;
+    this.metricManager = core.getCoreDescriptor().getCoreContainer().getMetricManager();
     registryName = createRegistryName(core.getCoreDescriptor().getCollectionName(), core.getName());
   }
 
@@ -56,7 +58,7 @@ public class SolrCoreMetricManager implements Closeable {
   public void loadReporters() {
     NodeConfig nodeConfig = core.getCoreDescriptor().getCoreContainer().getConfig();
     PluginInfo[] pluginInfos = nodeConfig.getMetricReporterPlugins();
-    SolrMetricManager.loadReporters(pluginInfos, core.getResourceLoader(), SolrInfoMBean.Group.core, registryName);
+    metricManager.loadReporters(pluginInfos, core.getResourceLoader(), SolrInfoMBean.Group.core, registryName);
   }
 
   /**
@@ -71,10 +73,10 @@ public class SolrCoreMetricManager implements Closeable {
       return;
     }
     // close old reporters
-    SolrMetricManager.closeReporters(oldRegistryName);
-    SolrMetricManager.moveMetrics(oldRegistryName, registryName, null);
+    metricManager.closeReporters(oldRegistryName);
+    metricManager.moveMetrics(oldRegistryName, registryName, null);
     // old registry is no longer used - we have moved the metrics
-    SolrMetricManager.removeRegistry(oldRegistryName);
+    metricManager.removeRegistry(oldRegistryName);
     // load reporters again, using the new core name
     loadReporters();
   }
@@ -90,7 +92,7 @@ public class SolrCoreMetricManager implements Closeable {
       throw new IllegalArgumentException("registerMetricProducer() called with illegal arguments: " +
           "scope = " + scope + ", producer = " + producer);
     }
-    Collection<String> registered = producer.initializeMetrics(getRegistryName(), scope);
+    Collection<String> registered = producer.initializeMetrics(metricManager, getRegistryName(), scope);
     if (registered == null || registered.isEmpty()) {
       throw new IllegalArgumentException("registerMetricProducer() did not register any metrics " +
       "for scope = " + scope + ", producer = " + producer);
@@ -102,7 +104,7 @@ public class SolrCoreMetricManager implements Closeable {
    */
   @Override
   public void close() throws IOException {
-    SolrMetricManager.closeReporters(getRegistryName());
+    metricManager.closeReporters(getRegistryName());
   }
 
   public SolrCore getCore() {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
index b700782..3f51aef 100644
--- a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
+++ b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
@@ -24,6 +24,8 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
@@ -59,7 +61,9 @@ import org.slf4j.LoggerFactory;
  * names.</p>
  * <p>Solr uses several different registries for collecting metrics belonging to different groups, using
  * {@link org.apache.solr.core.SolrInfoMBean.Group} as the main name of the registry (plus the
- * above-mentioned prefix).</p>
+ * above-mentioned prefix). Instances of {@link SolrMetricManager} are created for each {@link org.apache.solr.core.CoreContainer},
+ * and most registries are local to each instance, with the exception of two global registries:
+ * <code>solr.jetty</code> and <code>solr.jvm</code>, which are shared between all {@link org.apache.solr.core.CoreContainer}-s</p>
  */
 public class SolrMetricManager {
 
@@ -67,12 +71,21 @@ public class SolrMetricManager {
 
   public static final String REGISTRY_NAME_PREFIX = "solr.";
 
-  private static final Map<String, Map<String, SolrMetricReporter>> reporters = new HashMap<>();
+  public static final String JETTY_REGISTRY = REGISTRY_NAME_PREFIX + SolrInfoMBean.Group.jetty.toString();
 
-  private static final Lock reportersLock = new ReentrantLock();
+  public static final String JVM_REGISTRY = REGISTRY_NAME_PREFIX + SolrInfoMBean.Group.jvm.toString();
 
-  // don't create instances of this class
-  private SolrMetricManager() { }
+  private final ConcurrentMap<String, MetricRegistry> registries = new ConcurrentHashMap<>();
+
+  // these reporters are per CoreContainer
+  private final Map<String, Map<String, SolrMetricReporter>> reporters = new HashMap<>();
+
+  // these reporters are per JVM
+  private static final Map<String, Map<String, SolrMetricReporter>> sharedReporters = new HashMap<>();
+
+  private final Lock reportersLock = new ReentrantLock();
+
+  public SolrMetricManager() { }
 
   /**
    * An implementation of {@link MetricFilter} that selects metrics
@@ -125,8 +138,11 @@ public class SolrMetricManager {
   /**
    * Return a set of existing registry names.
    */
-  public static Set<String> registryNames() {
-    return SharedMetricRegistries.names();
+  public Set<String> registryNames() {
+    Set<String> set = new HashSet<>();
+    set.addAll(registries.keySet());
+    set.addAll(SharedMetricRegistries.names());
+    return Collections.unmodifiableSet(set);
   }
 
   /**
@@ -134,20 +150,40 @@ public class SolrMetricManager {
    * @param registry name of the registry
    * @return existing or newly created registry
    */
-  public static MetricRegistry registry(String registry) {
-    return SharedMetricRegistries.getOrCreate(overridableRegistryName(registry));
+  public MetricRegistry registry(String registry) {
+    registry = overridableRegistryName(registry);
+    if (JETTY_REGISTRY.equals(registry) || JVM_REGISTRY.equals(registry)) {
+      return SharedMetricRegistries.getOrCreate(registry);
+    } else {
+      final MetricRegistry existing = registries.get(registry);
+      if (existing == null) {
+        final MetricRegistry created = new MetricRegistry();
+        final MetricRegistry raced = registries.putIfAbsent(registry, created);
+        if (raced == null) {
+          return created;
+        } else {
+          return raced;
+        }
+      } else {
+        return existing;
+      }
+    }
   }
 
   /**
    * Remove a named registry.
    * @param registry name of the registry to remove
    */
-  public static void removeRegistry(String registry) {
+  public void removeRegistry(String registry) {
     // close any reporters for this registry first
     closeReporters(registry);
     // make sure we use a name with prefix, with overrides
     registry = overridableRegistryName(registry);
-    SharedMetricRegistries.remove(registry);
+    if (JETTY_REGISTRY.equals(registry) || JVM_REGISTRY.equals(registry)) {
+      SharedMetricRegistries.remove(registry);
+    } else {
+      registries.remove(registry);
+    }
   }
 
   /**
@@ -158,7 +194,7 @@ public class SolrMetricManager {
    * @param filter optional {@link MetricFilter} to select what metrics to move. If null
    *               then all metrics will be moved.
    */
-  public static void moveMetrics(String fromRegistry, String toRegistry, MetricFilter filter) {
+  public void moveMetrics(String fromRegistry, String toRegistry, MetricFilter filter) {
     MetricRegistry from = registry(fromRegistry);
     MetricRegistry to = registry(toRegistry);
     if (from == to) {
@@ -182,19 +218,23 @@ public class SolrMetricManager {
    * already exist.
    * @param registry registry name
    * @param metrics metric set to register
-   * @param skipExisting if true then already existing metrics with the same name will be kept.
+   * @param force if true then already existing metrics with the same name will be replaced.
    *                     When false and a metric with the same name already exists an exception
    *                     will be thrown.
+   * @param metricPath (optional) additional top-most metric name path elements
    * @throws Exception if a metric with this name already exists.
    */
-  public static void registerAll(String registry, MetricSet metrics, boolean skipExisting) throws Exception {
+  public void registerAll(String registry, MetricSet metrics, boolean force, String... metricPath) throws Exception {
     MetricRegistry metricRegistry = registry(registry);
-    Map<String, Metric> existingMetrics = metricRegistry.getMetrics();
-    for (Map.Entry<String, Metric> entry : metrics.getMetrics().entrySet()) {
-      if (skipExisting && existingMetrics.containsKey(entry.getKey())) {
-        continue;
+    synchronized (metricRegistry) {
+      Map<String, Metric> existingMetrics = metricRegistry.getMetrics();
+      for (Map.Entry<String, Metric> entry : metrics.getMetrics().entrySet()) {
+        String fullName = mkName(entry.getKey(), metricPath);
+        if (force && existingMetrics.containsKey(fullName)) {
+          metricRegistry.remove(fullName);
+        }
+        metricRegistry.register(fullName, entry.getValue());
       }
-      metricRegistry.register(entry.getKey(), entry.getValue());
     }
   }
 
@@ -202,7 +242,7 @@ public class SolrMetricManager {
    * Remove all metrics from a specified registry.
    * @param registry registry name
    */
-  public static void clearRegistry(String registry) {
+  public void clearRegistry(String registry) {
     registry(registry).removeMatching(MetricFilter.ALL);
   }
 
@@ -216,7 +256,7 @@ public class SolrMetricManager {
    *        with the prefix will be removed.
    * @return set of metrics names that have been removed.
    */
-  public static Set<String> clearMetrics(String registry, String... metricPath) {
+  public Set<String> clearMetrics(String registry, String... metricPath) {
     PrefixFilter filter;
     if (metricPath == null || metricPath.length == 0) {
       filter = new PrefixFilter("");
@@ -236,7 +276,7 @@ public class SolrMetricManager {
    * @param metricPath (optional) additional top-most metric name path elements
    * @return existing or a newly created {@link Meter}
    */
-  public static Meter meter(String registry, String metricName, String... metricPath) {
+  public Meter meter(String registry, String metricName, String... metricPath) {
     return registry(registry).meter(mkName(metricName, metricPath));
   }
 
@@ -248,7 +288,7 @@ public class SolrMetricManager {
    * @param metricPath (optional) additional top-most metric name path elements
    * @return existing or a newly created {@link Timer}
    */
-  public static Timer timer(String registry, String metricName, String... metricPath) {
+  public Timer timer(String registry, String metricName, String... metricPath) {
     return registry(registry).timer(mkName(metricName, metricPath));
   }
 
@@ -260,7 +300,7 @@ public class SolrMetricManager {
    * @param metricPath (optional) additional top-most metric name path elements
    * @return existing or a newly created {@link Counter}
    */
-  public static Counter counter(String registry, String metricName, String... metricPath) {
+  public Counter counter(String registry, String metricName, String... metricPath) {
     return registry(registry).counter(mkName(metricName, metricPath));
   }
 
@@ -272,7 +312,7 @@ public class SolrMetricManager {
    * @param metricPath (optional) additional top-most metric name path elements
    * @return existing or a newly created {@link Histogram}
    */
-  public static Histogram histogram(String registry, String metricName, String... metricPath) {
+  public Histogram histogram(String registry, String metricName, String... metricPath) {
     return registry(registry).histogram(mkName(metricName, metricPath));
   }
 
@@ -287,13 +327,15 @@ public class SolrMetricManager {
    *                   using dotted notation
    * @param metricPath (optional) additional top-most metric name path elements
    */
-  public static void register(String registry, Metric metric, boolean force, String metricName, String... metricPath) {
+  public void register(String registry, Metric metric, boolean force, String metricName, String... metricPath) {
     MetricRegistry metricRegistry = registry(registry);
     String fullName = mkName(metricName, metricPath);
-    if (force && metricRegistry.getMetrics().containsKey(fullName)) {
-      metricRegistry.remove(fullName);
+    synchronized (metricRegistry) {
+      if (force && metricRegistry.getMetrics().containsKey(fullName)) {
+        metricRegistry.remove(fullName);
+      }
+      metricRegistry.register(fullName, metric);
     }
-    metricRegistry.register(fullName, metric);
   }
 
 
@@ -405,7 +447,7 @@ public class SolrMetricManager {
    * @param group selected group, not null
    * @param registryNames optional child registry name elements
    */
-  public static void loadReporters(PluginInfo[] pluginInfos, SolrResourceLoader loader, SolrInfoMBean.Group group, String... registryNames) {
+  public void loadReporters(PluginInfo[] pluginInfos, SolrResourceLoader loader, SolrInfoMBean.Group group, String... registryNames) {
     if (pluginInfos == null || pluginInfos.length == 0) {
       return;
     }
@@ -459,7 +501,7 @@ public class SolrMetricManager {
    * @param pluginInfo plugin configuration. Plugin "name" and "class" attributes are required.
    * @throws Exception if any argument is missing or invalid
    */
-  public static void loadReporter(String registry, SolrResourceLoader loader, PluginInfo pluginInfo) throws Exception {
+  public void loadReporter(String registry, SolrResourceLoader loader, PluginInfo pluginInfo) throws Exception {
     if (registry == null || pluginInfo == null || pluginInfo.name == null || pluginInfo.className == null) {
       throw new IllegalArgumentException("loadReporter called with missing arguments: " +
           "registry=" + registry + ", loader=" + loader + ", pluginInfo=" + pluginInfo);
@@ -470,8 +512,8 @@ public class SolrMetricManager {
         pluginInfo.className,
         SolrMetricReporter.class,
         new String[0],
-        new Class[] { String.class },
-        new Object[] { registry }
+        new Class[] { SolrMetricManager.class, String.class },
+        new Object[] { this, registry }
     );
     try {
       reporter.init(pluginInfo);
@@ -509,7 +551,7 @@ public class SolrMetricManager {
    * @param name reporter name
    * @return true if a named reporter existed and was closed.
    */
-  public static boolean closeReporter(String registry, String name) {
+  public boolean closeReporter(String registry, String name) {
     // make sure we use a name with prefix, with overrides
     registry = overridableRegistryName(registry);
     try {
@@ -546,7 +588,7 @@ public class SolrMetricManager {
    * @param registry registry name
    * @return names of closed reporters
    */
-  public static Set<String> closeReporters(String registry) {
+  public Set<String> closeReporters(String registry) {
     // make sure we use a name with prefix, with overrides
     registry = overridableRegistryName(registry);
     try {
@@ -583,7 +625,7 @@ public class SolrMetricManager {
    * @param registry registry name
    * @return map of reporters and their names, may be empty but never null
    */
-  public static Map<String, SolrMetricReporter> getReporters(String registry) {
+  public Map<String, SolrMetricReporter> getReporters(String registry) {
     // make sure we use a name with prefix, with overrides
     registry = overridableRegistryName(registry);
     try {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/java/org/apache/solr/metrics/SolrMetricProducer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrMetricProducer.java b/solr/core/src/java/org/apache/solr/metrics/SolrMetricProducer.java
index 929e6a2..b09a90a 100644
--- a/solr/core/src/java/org/apache/solr/metrics/SolrMetricProducer.java
+++ b/solr/core/src/java/org/apache/solr/metrics/SolrMetricProducer.java
@@ -18,6 +18,7 @@ package org.apache.solr.metrics;
 
 import java.util.Collection;
 
+import com.codahale.metrics.MetricRegistry;
 import org.apache.solr.core.SolrInfoMBean;
 
 /**
@@ -28,10 +29,11 @@ public interface SolrMetricProducer extends SolrInfoMBean {
 
   /**
    * Initializes metrics specific to this producer
+   * @param manager an instance of {@link SolrMetricManager}
    * @param registry registry name where metrics are registered
    * @param scope scope of the metrics (eg. handler name) to separate metrics of
    *              instances of the same component executing in different contexts
    * @return registered (or existing) unqualified names of metrics specific to this producer.
    */
-  Collection<String> initializeMetrics(String registry, String scope);
+  Collection<String> initializeMetrics(SolrMetricManager manager, String registry, String scope);
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/java/org/apache/solr/metrics/SolrMetricReporter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrMetricReporter.java b/solr/core/src/java/org/apache/solr/metrics/SolrMetricReporter.java
index cfe5d67..a36a1c3 100644
--- a/solr/core/src/java/org/apache/solr/metrics/SolrMetricReporter.java
+++ b/solr/core/src/java/org/apache/solr/metrics/SolrMetricReporter.java
@@ -18,6 +18,7 @@ package org.apache.solr.metrics;
 
 import java.io.Closeable;
 
+import com.codahale.metrics.MetricRegistry;
 import org.apache.solr.core.PluginInfo;
 import org.apache.solr.util.SolrPluginUtils;
 import org.apache.solr.util.plugin.PluginInfoInitialized;
@@ -28,6 +29,7 @@ import org.apache.solr.util.plugin.PluginInfoInitialized;
 public abstract class SolrMetricReporter implements Closeable, PluginInfoInitialized {
 
   protected final String registryName;
+  protected final SolrMetricManager metricManager;
   protected PluginInfo pluginInfo;
 
   /**
@@ -35,8 +37,9 @@ public abstract class SolrMetricReporter implements Closeable, PluginInfoInitial
    * @param registryName registry to use, one of registries managed by
    *                     {@link SolrMetricManager}
    */
-  protected SolrMetricReporter(String registryName) {
+  protected SolrMetricReporter(SolrMetricManager metricManager, String registryName) {
     this.registryName = registryName;
+    this.metricManager = metricManager;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/java/org/apache/solr/metrics/reporters/SolrJmxReporter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/SolrJmxReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/SolrJmxReporter.java
index 380bbaa..47fbf11 100644
--- a/solr/core/src/java/org/apache/solr/metrics/reporters/SolrJmxReporter.java
+++ b/solr/core/src/java/org/apache/solr/metrics/reporters/SolrJmxReporter.java
@@ -55,8 +55,8 @@ public class SolrJmxReporter extends SolrMetricReporter {
    *
    * @param registryName name of the registry to report
    */
-  public SolrJmxReporter(String registryName) {
-    super(registryName);
+  public SolrJmxReporter(SolrMetricManager metricManager, String registryName) {
+    super(metricManager, registryName);
     setDomain(registryName);
   }
 
@@ -99,7 +99,7 @@ public class SolrJmxReporter extends SolrMetricReporter {
 
     JmxObjectNameFactory jmxObjectNameFactory = new JmxObjectNameFactory(pluginInfo.name, domain);
 
-    reporter = JmxReporter.forRegistry(SolrMetricManager.registry(registryName))
+    reporter = JmxReporter.forRegistry(metricManager.registry(registryName))
                           .registerWith(mBeanServer)
                           .inDomain(domain)
                           .createsObjectNamesWith(jmxObjectNameFactory)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
index 2852041..dbc4b35 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -156,7 +156,6 @@ public class SolrDispatchFilter extends BaseSolrFilter {
         excludePatterns.add(Pattern.compile(element));
       }
     }
-    setupJvmMetrics();
     try {
       Properties extraProperties = (Properties) config.getServletContext().getAttribute(PROPERTIES_ATTRIBUTE);
       if (extraProperties == null)
@@ -168,6 +167,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
       this.cores = createCoreContainer(solrHome == null ? SolrResourceLoader.locateSolrHome() : Paths.get(solrHome),
                                        extraProperties);
       this.httpClient = cores.getUpdateShardHandler().getHttpClient();
+      setupJvmMetrics();
       log.debug("user.dir=" + System.getProperty("user.dir"));
     }
     catch( Throwable t ) {
@@ -184,15 +184,15 @@ public class SolrDispatchFilter extends BaseSolrFilter {
 
   private void setupJvmMetrics()  {
     MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
+    SolrMetricManager metricManager = cores.getMetricManager();
     try {
       String registry = SolrMetricManager.getRegistryName(SolrInfoMBean.Group.jvm);
-      SolrMetricManager.registerAll(registry, new BufferPoolMetricSet(platformMBeanServer), true);
-      SolrMetricManager.registerAll(registry, new BufferPoolMetricSet(platformMBeanServer), true);
-      SolrMetricManager.registerAll(registry, new ClassLoadingGaugeSet(), true);
-      SolrMetricManager.register(registry, new FileDescriptorRatioGauge(), true, "fileDescriptorRatio");
-      SolrMetricManager.registerAll(registry, new GarbageCollectorMetricSet(), true);
-      SolrMetricManager.registerAll(registry, new MemoryUsageGaugeSet(), true);
-      SolrMetricManager.registerAll(registry, new ThreadStatesGaugeSet(), true); // todo should we use CachedThreadStatesGaugeSet instead?
+      metricManager.registerAll(registry, new BufferPoolMetricSet(platformMBeanServer), true, "bufferPools");
+      metricManager.registerAll(registry, new ClassLoadingGaugeSet(), true, "classLoading");
+      metricManager.register(registry, new FileDescriptorRatioGauge(), true, "fileDescriptorRatio");
+      metricManager.registerAll(registry, new GarbageCollectorMetricSet(), true, "gc");
+      metricManager.registerAll(registry, new MemoryUsageGaugeSet(), true, "memory");
+      metricManager.registerAll(registry, new ThreadStatesGaugeSet(), true, "threads"); // todo should we use CachedThreadStatesGaugeSet instead?
     } catch (Exception e) {
       log.warn("Error registering JVM metrics", e);
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/test/org/apache/solr/metrics/SolrCoreMetricManagerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/metrics/SolrCoreMetricManagerTest.java b/solr/core/src/test/org/apache/solr/metrics/SolrCoreMetricManagerTest.java
index f532d54..65ffb93 100644
--- a/solr/core/src/test/org/apache/solr/metrics/SolrCoreMetricManagerTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/SolrCoreMetricManagerTest.java
@@ -39,18 +39,20 @@ import org.junit.Test;
 public class SolrCoreMetricManagerTest extends SolrTestCaseJ4 {
   private static final int MAX_ITERATIONS = 100;
 
-  private SolrCoreMetricManager metricManager;
+  private SolrCoreMetricManager coreMetricManager;
+  private SolrMetricManager metricManager;
 
   @Before
   public void beforeTest() throws Exception {
     initCore("solrconfig-basic.xml", "schema.xml");
-    metricManager = new SolrCoreMetricManager(h.getCore());
+    coreMetricManager = h.getCore().getCoreMetricManager();
+    metricManager = h.getCore().getCoreDescriptor().getCoreContainer().getMetricManager();
   }
 
   @After
   public void afterTest() throws IOException {
-    metricManager.close();
-    assertTrue(SolrMetricManager.getReporters(metricManager.getRegistryName()).isEmpty());
+    coreMetricManager.close();
+    assertTrue(metricManager.getReporters(coreMetricManager.getRegistryName()).isEmpty());
     deleteCore();
   }
 
@@ -61,17 +63,17 @@ public class SolrCoreMetricManagerTest extends SolrTestCaseJ4 {
     String scope = SolrMetricTestUtils.getRandomScope(random);
     SolrInfoMBean.Category category = SolrMetricTestUtils.getRandomCategory(random);
     Map<String, Counter> metrics = SolrMetricTestUtils.getRandomMetrics(random);
-    SolrMetricProducer producer = SolrMetricTestUtils.getProducerOf(category, scope, metrics);
+    SolrMetricProducer producer = SolrMetricTestUtils.getProducerOf(metricManager, category, scope, metrics);
     try {
-      metricManager.registerMetricProducer(scope, producer);
+      coreMetricManager.registerMetricProducer(scope, producer);
       assertNotNull(scope);
       assertNotNull(category);
       assertNotNull(metrics);
-      assertRegistered(scope, metrics, metricManager);
+      assertRegistered(scope, metrics, coreMetricManager);
     } catch (final IllegalArgumentException e) {
       assertTrue("expected at least one null but got: scope="+scope+" category="+category+" metrics="+metrics,
           (scope == null || category == null || metrics == null));
-      assertRegistered(scope, new HashMap<>(), metricManager);
+      assertRegistered(scope, new HashMap<>(), coreMetricManager);
     }
   }
 
@@ -89,10 +91,10 @@ public class SolrCoreMetricManagerTest extends SolrTestCaseJ4 {
       if (metrics.isEmpty()) {
         continue;
       }
-      SolrMetricProducer producer = SolrMetricTestUtils.getProducerOf(category, scope, metrics);
-      metricManager.registerMetricProducer(scope, producer);
+      SolrMetricProducer producer = SolrMetricTestUtils.getProducerOf(metricManager, category, scope, metrics);
+      coreMetricManager.registerMetricProducer(scope, producer);
       registered.putAll(metrics);
-      assertRegistered(scope, registered, metricManager);
+      assertRegistered(scope, registered, coreMetricManager);
     }
   }
 
@@ -115,24 +117,24 @@ public class SolrCoreMetricManagerTest extends SolrTestCaseJ4 {
     PluginInfo pluginInfo = shouldDefinePlugin ? new PluginInfo(TestUtil.randomUnicodeString(random), attrs) : null;
 
     try {
-      SolrMetricManager.loadReporter(metricManager.getRegistryName(), metricManager.getCore().getResourceLoader(), pluginInfo);
+      metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore().getResourceLoader(), pluginInfo);
       assertNotNull(pluginInfo);
-      Map<String, SolrMetricReporter> reporters = SolrMetricManager.getReporters(metricManager.getRegistryName());
+      Map<String, SolrMetricReporter> reporters = metricManager.getReporters(coreMetricManager.getRegistryName());
       assertTrue("reporters.size should be > 0, but was + " + reporters.size(), reporters.size() > 0);
       assertNotNull("reporter " + reporterName + " not present among " + reporters, reporters.get(reporterName));
       assertTrue("wrong reporter class: " + reporters.get(reporterName), reporters.get(reporterName) instanceof MockMetricReporter);
     } catch (IllegalArgumentException e) {
       assertTrue(pluginInfo == null || attrs.get("configurable") == null);
-      assertNull(SolrMetricManager.getReporters(metricManager.getRegistryName()).get(reporterName));
+      assertNull(metricManager.getReporters(coreMetricManager.getRegistryName()).get(reporterName));
     }
   }
 
-  private static void assertRegistered(String scope, Map<String, Counter> newMetrics, SolrCoreMetricManager metricManager) {
+  private void assertRegistered(String scope, Map<String, Counter> newMetrics, SolrCoreMetricManager coreMetricManager) {
     if (scope == null) {
       return;
     }
     String filter = "." + scope + ".";
-    MetricRegistry registry = SolrMetricManager.registry(metricManager.getRegistryName());
+    MetricRegistry registry = metricManager.registry(coreMetricManager.getRegistryName());
     assertEquals(newMetrics.size(), registry.getMetrics().
         keySet().stream().filter(s -> s.contains(filter)).count());
 
@@ -159,12 +161,12 @@ public class SolrCoreMetricManagerTest extends SolrTestCaseJ4 {
     String cloudRegistryName = "solr.core." + cloudCoreName;
     String nestedRegistryName = "solr.core.my_collection_.shard1_0.replica0";
     // pass through
-    assertEquals(cloudRegistryName, metricManager.createRegistryName(null, cloudCoreName));
-    assertEquals(simpleRegistryName, metricManager.createRegistryName(null, simpleCoreName));
+    assertEquals(cloudRegistryName, coreMetricManager.createRegistryName(null, cloudCoreName));
+    assertEquals(simpleRegistryName, coreMetricManager.createRegistryName(null, simpleCoreName));
     // unknown naming scheme -> pass through
-    assertEquals(simpleRegistryName, metricManager.createRegistryName(collectionName, simpleCoreName));
+    assertEquals(simpleRegistryName, coreMetricManager.createRegistryName(collectionName, simpleCoreName));
     // cloud collection
-    assertEquals(nestedRegistryName, metricManager.createRegistryName(collectionName, cloudCoreName));
+    assertEquals(nestedRegistryName, coreMetricManager.createRegistryName(collectionName, cloudCoreName));
 
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/test/org/apache/solr/metrics/SolrMetricManagerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/metrics/SolrMetricManagerTest.java b/solr/core/src/test/org/apache/solr/metrics/SolrMetricManagerTest.java
index 2886016..ecddfba 100644
--- a/solr/core/src/test/org/apache/solr/metrics/SolrMetricManagerTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/SolrMetricManagerTest.java
@@ -54,23 +54,25 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
   public void testMoveMetrics() throws Exception {
     Random r = random();
 
+    SolrMetricManager metricManager = new SolrMetricManager();
+
     Map<String, Counter> metrics1 = SolrMetricTestUtils.getRandomMetrics(r, true);
     Map<String, Counter> metrics2 = SolrMetricTestUtils.getRandomMetrics(r, true);
     String fromName = TestUtil.randomSimpleString(r, 1, 10);
     String toName = TestUtil.randomSimpleString(r, 1, 10);
     // register test metrics
     for (Map.Entry<String, Counter> entry : metrics1.entrySet()) {
-      SolrMetricManager.register(fromName, entry.getValue(), false, entry.getKey(), "metrics1");
+      metricManager.register(fromName, entry.getValue(), false, entry.getKey(), "metrics1");
     }
     for (Map.Entry<String, Counter> entry : metrics2.entrySet()) {
-      SolrMetricManager.register(fromName, entry.getValue(), false, entry.getKey(), "metrics2");
+      metricManager.register(fromName, entry.getValue(), false, entry.getKey(), "metrics2");
     }
-    assertEquals(metrics1.size() + metrics2.size(), SolrMetricManager.registry(fromName).getMetrics().size());
+    assertEquals(metrics1.size() + metrics2.size(), metricManager.registry(fromName).getMetrics().size());
 
     // move metrics1
-    SolrMetricManager.moveMetrics(fromName, toName, new SolrMetricManager.PrefixFilter("metrics1"));
+    metricManager.moveMetrics(fromName, toName, new SolrMetricManager.PrefixFilter("metrics1"));
     // check the remaining metrics
-    Map<String, Metric> fromMetrics = SolrMetricManager.registry(fromName).getMetrics();
+    Map<String, Metric> fromMetrics = metricManager.registry(fromName).getMetrics();
     assertEquals(metrics2.size(), fromMetrics.size());
     for (Map.Entry<String, Counter> entry : metrics2.entrySet()) {
       Object value = fromMetrics.get(SolrMetricManager.mkName(entry.getKey(), "metrics2"));
@@ -78,7 +80,7 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
       assertEquals(entry.getValue(), value);
     }
     // check the moved metrics
-    Map<String, Metric> toMetrics = SolrMetricManager.registry(toName).getMetrics();
+    Map<String, Metric> toMetrics = metricManager.registry(toName).getMetrics();
     assertEquals(metrics1.size(), toMetrics.size());
     for (Map.Entry<String, Counter> entry : metrics1.entrySet()) {
       Object value = toMetrics.get(SolrMetricManager.mkName(entry.getKey(), "metrics1"));
@@ -87,10 +89,10 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
     }
 
     // move all remaining metrics
-    SolrMetricManager.moveMetrics(fromName, toName, null);
-    fromMetrics = SolrMetricManager.registry(fromName).getMetrics();
+    metricManager.moveMetrics(fromName, toName, null);
+    fromMetrics = metricManager.registry(fromName).getMetrics();
     assertEquals(0, fromMetrics.size());
-    toMetrics = SolrMetricManager.registry(toName).getMetrics();
+    toMetrics = metricManager.registry(toName).getMetrics();
     assertEquals(metrics1.size() + metrics2.size(), toMetrics.size());
   }
 
@@ -98,6 +100,8 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
   public void testRegisterAll() throws Exception {
     Random r = random();
 
+    SolrMetricManager metricManager = new SolrMetricManager();
+
     Map<String, Counter> metrics = SolrMetricTestUtils.getRandomMetrics(r, true);
     MetricRegistry mr = new MetricRegistry();
     for (Map.Entry<String, Counter> entry : metrics.entrySet()) {
@@ -105,13 +109,13 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
     }
 
     String registryName = TestUtil.randomSimpleString(r, 1, 10);
-    assertEquals(0, SolrMetricManager.registry(registryName).getMetrics().size());
-    SolrMetricManager.registerAll(registryName, mr, false);
+    assertEquals(0, metricManager.registry(registryName).getMetrics().size());
+    metricManager.registerAll(registryName, mr, false);
     // this should simply skip existing names
-    SolrMetricManager.registerAll(registryName, mr, true);
+    metricManager.registerAll(registryName, mr, true);
     // this should produce error
     try {
-      SolrMetricManager.registerAll(registryName, mr, false);
+      metricManager.registerAll(registryName, mr, false);
       fail("registerAll with duplicate metric names should fail");
     } catch (IllegalArgumentException e) {
       // expected
@@ -122,34 +126,36 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
   public void testClearMetrics() throws Exception {
     Random r = random();
 
+    SolrMetricManager metricManager = new SolrMetricManager();
+
     Map<String, Counter> metrics = SolrMetricTestUtils.getRandomMetrics(r, true);
     String registryName = TestUtil.randomSimpleString(r, 1, 10);
 
     for (Map.Entry<String, Counter> entry : metrics.entrySet()) {
-      SolrMetricManager.register(registryName, entry.getValue(), false, entry.getKey(), "foo", "bar");
+      metricManager.register(registryName, entry.getValue(), false, entry.getKey(), "foo", "bar");
     }
     for (Map.Entry<String, Counter> entry : metrics.entrySet()) {
-      SolrMetricManager.register(registryName, entry.getValue(), false, entry.getKey(), "foo", "baz");
+      metricManager.register(registryName, entry.getValue(), false, entry.getKey(), "foo", "baz");
     }
     for (Map.Entry<String, Counter> entry : metrics.entrySet()) {
-      SolrMetricManager.register(registryName, entry.getValue(), false, entry.getKey(), "foo");
+      metricManager.register(registryName, entry.getValue(), false, entry.getKey(), "foo");
     }
 
-    assertEquals(metrics.size() * 3, SolrMetricManager.registry(registryName).getMetrics().size());
+    assertEquals(metrics.size() * 3, metricManager.registry(registryName).getMetrics().size());
 
     // clear "foo.bar"
-    Set<String> removed = SolrMetricManager.clearMetrics(registryName, "foo", "bar");
+    Set<String> removed = metricManager.clearMetrics(registryName, "foo", "bar");
     assertEquals(metrics.size(), removed.size());
     for (String s : removed) {
       assertTrue(s.startsWith("foo.bar."));
     }
-    removed = SolrMetricManager.clearMetrics(registryName, "foo", "baz");
+    removed = metricManager.clearMetrics(registryName, "foo", "baz");
     assertEquals(metrics.size(), removed.size());
     for (String s : removed) {
       assertTrue(s.startsWith("foo.baz."));
     }
     // perhaps surprisingly, this works too - see PrefixFilter docs
-    removed = SolrMetricManager.clearMetrics(registryName, "fo");
+    removed = metricManager.clearMetrics(registryName, "fo");
     assertEquals(metrics.size(), removed.size());
     for (String s : removed) {
       assertTrue(s.startsWith("foo."));
@@ -160,13 +166,15 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
   public void testSimpleMetrics() throws Exception {
     Random r = random();
 
+    SolrMetricManager metricManager = new SolrMetricManager();
+
     String registryName = TestUtil.randomSimpleString(r, 1, 10);
 
-    SolrMetricManager.counter(registryName, "simple_counter", "foo", "bar");
-    SolrMetricManager.timer(registryName, "simple_timer", "foo", "bar");
-    SolrMetricManager.meter(registryName, "simple_meter", "foo", "bar");
-    SolrMetricManager.histogram(registryName, "simple_histogram", "foo", "bar");
-    Map<String, Metric> metrics = SolrMetricManager.registry(registryName).getMetrics();
+    metricManager.counter(registryName, "simple_counter", "foo", "bar");
+    metricManager.timer(registryName, "simple_timer", "foo", "bar");
+    metricManager.meter(registryName, "simple_meter", "foo", "bar");
+    metricManager.histogram(registryName, "simple_histogram", "foo", "bar");
+    Map<String, Metric> metrics = metricManager.registry(registryName).getMetrics();
     assertEquals(4, metrics.size());
     for (Map.Entry<String, Metric> entry : metrics.entrySet()) {
       assertTrue(entry.getKey().startsWith("foo.bar.simple_"));
@@ -194,6 +202,7 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
     Random r = random();
 
     SolrResourceLoader loader = new SolrResourceLoader();
+    SolrMetricManager metricManager = new SolrMetricManager();
 
     PluginInfo[] plugins = new PluginInfo[] {
         createPluginInfo("universal_foo", null, null),
@@ -204,8 +213,8 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
         createPluginInfo("core_foo", "core", null)
     };
 
-    SolrMetricManager.loadReporters(plugins, loader, SolrInfoMBean.Group.node);
-    Map<String, SolrMetricReporter> reporters = SolrMetricManager.getReporters(
+    metricManager.loadReporters(plugins, loader, SolrInfoMBean.Group.node);
+    Map<String, SolrMetricReporter> reporters = metricManager.getReporters(
         SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node));
     assertEquals(4, reporters.size());
     assertTrue(reporters.containsKey("universal_foo"));
@@ -213,8 +222,8 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
     assertTrue(reporters.containsKey("node_foo"));
     assertTrue(reporters.containsKey("multiregistry_foo"));
 
-    SolrMetricManager.loadReporters(plugins, loader, SolrInfoMBean.Group.core, "collection1");
-    reporters = SolrMetricManager.getReporters(
+    metricManager.loadReporters(plugins, loader, SolrInfoMBean.Group.core, "collection1");
+    reporters = metricManager.getReporters(
         SolrMetricManager.getRegistryName(SolrInfoMBean.Group.core, "collection1"));
     assertEquals(5, reporters.size());
     assertTrue(reporters.containsKey("universal_foo"));
@@ -223,25 +232,25 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
     assertTrue(reporters.containsKey("core_foo"));
     assertTrue(reporters.containsKey("multiregistry_foo"));
 
-    SolrMetricManager.loadReporters(plugins, loader, SolrInfoMBean.Group.jvm);
-    reporters = SolrMetricManager.getReporters(
+    metricManager.loadReporters(plugins, loader, SolrInfoMBean.Group.jvm);
+    reporters = metricManager.getReporters(
         SolrMetricManager.getRegistryName(SolrInfoMBean.Group.jvm));
     assertEquals(2, reporters.size());
     assertTrue(reporters.containsKey("universal_foo"));
     assertTrue(reporters.containsKey("multigroup_foo"));
 
-    SolrMetricManager.removeRegistry("solr.jvm");
-    reporters = SolrMetricManager.getReporters(
+    metricManager.removeRegistry("solr.jvm");
+    reporters = metricManager.getReporters(
         SolrMetricManager.getRegistryName(SolrInfoMBean.Group.jvm));
     assertEquals(0, reporters.size());
 
-    SolrMetricManager.removeRegistry("solr.node");
-    reporters = SolrMetricManager.getReporters(
+    metricManager.removeRegistry("solr.node");
+    reporters = metricManager.getReporters(
         SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node));
     assertEquals(0, reporters.size());
 
-    SolrMetricManager.removeRegistry("solr.core.collection1");
-    reporters = SolrMetricManager.getReporters(
+    metricManager.removeRegistry("solr.core.collection1");
+    reporters = metricManager.getReporters(
         SolrMetricManager.getRegistryName(SolrInfoMBean.Group.core, "collection1"));
     assertEquals(0, reporters.size());
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/test/org/apache/solr/metrics/SolrMetricReporterTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/metrics/SolrMetricReporterTest.java b/solr/core/src/test/org/apache/solr/metrics/SolrMetricReporterTest.java
index 0cbf009..b275919 100644
--- a/solr/core/src/test/org/apache/solr/metrics/SolrMetricReporterTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/SolrMetricReporterTest.java
@@ -34,8 +34,10 @@ public class SolrMetricReporterTest extends LuceneTestCase {
   public void testInit() throws Exception {
     Random random = random();
 
+    SolrMetricManager metricManager = new SolrMetricManager();
+
     final String registryName = TestUtil.randomSimpleString(random);
-    final MockMetricReporter reporter = new MockMetricReporter(registryName);
+    final MockMetricReporter reporter = new MockMetricReporter(metricManager, registryName);
 
     Map<String, Object> attrs = new HashMap<>();
     attrs.put(FieldType.CLASS_NAME, MockMetricReporter.class.getName());

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/test/org/apache/solr/metrics/SolrMetricTestUtils.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/metrics/SolrMetricTestUtils.java b/solr/core/src/test/org/apache/solr/metrics/SolrMetricTestUtils.java
index f8ca6d7..44ae9db 100644
--- a/solr/core/src/test/org/apache/solr/metrics/SolrMetricTestUtils.java
+++ b/solr/core/src/test/org/apache/solr/metrics/SolrMetricTestUtils.java
@@ -79,15 +79,15 @@ public final class SolrMetricTestUtils {
     return metrics;
   }
 
-  public static SolrMetricProducer getProducerOf(SolrInfoMBean.Category category, String scope, Map<String, Counter> metrics) {
+  public static SolrMetricProducer getProducerOf(SolrMetricManager metricManager, SolrInfoMBean.Category category, String scope, Map<String, Counter> metrics) {
     return new SolrMetricProducer() {
       @Override
-      public Collection<String> initializeMetrics(String registry, String scope) {
+      public Collection<String> initializeMetrics(SolrMetricManager manager, String registry, String scope) {
         if (metrics == null || metrics.isEmpty()) {
           return Collections.emptyList();
         }
         for (Map.Entry<String, Counter> entry : metrics.entrySet()) {
-          SolrMetricManager.counter(registry, entry.getKey(), category.toString(), scope);
+          manager.counter(registry, entry.getKey(), category.toString(), scope);
         }
         return metrics.keySet();
       }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java b/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java
index 67a073b..c6449ac 100644
--- a/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java
@@ -54,6 +54,7 @@ public class SolrMetricsIntegrationTest extends SolrTestCaseJ4 {
   private static final SolrInfoMBean.Category HANDLER_CATEGORY = SolrInfoMBean.Category.QUERYHANDLER;
 
   private CoreContainer cc;
+  private SolrMetricManager metricManager;
 
   @Before
   public void beforeTest() throws Exception {
@@ -66,8 +67,9 @@ public class SolrMetricsIntegrationTest extends SolrTestCaseJ4 {
     cc = createCoreContainer(cfg,
         new TestHarness.TestCoresLocator(DEFAULT_TEST_CORENAME, initCoreDataDir.getAbsolutePath(), "solrconfig.xml", "schema.xml"));
     h.coreName = DEFAULT_TEST_CORENAME;
+    metricManager = cc.getMetricManager();
     // initially there are more reporters, because two of them are added via a matching collection name
-    Map<String, SolrMetricReporter> reporters = SolrMetricManager.getReporters("solr.core." + DEFAULT_TEST_CORENAME);
+    Map<String, SolrMetricReporter> reporters = metricManager.getReporters("solr.core." + DEFAULT_TEST_CORENAME);
     assertEquals(INITIAL_REPORTERS.length, reporters.size());
     assertTrue(reporters.keySet().containsAll(Arrays.asList(INITIAL_REPORTERS)));
     // test rename operation
@@ -77,7 +79,7 @@ public class SolrMetricsIntegrationTest extends SolrTestCaseJ4 {
     PluginInfo[] plugins = cfg.getMetricReporterPlugins();
     assertNotNull(plugins);
     assertEquals(10, plugins.length);
-    reporters = SolrMetricManager.getReporters("solr.node");
+    reporters = metricManager.getReporters("solr.node");
     assertEquals(4, reporters.size());
     assertTrue("Reporter '" + REPORTER_NAMES[0] + "' missing in solr.node", reporters.containsKey(REPORTER_NAMES[0]));
     assertTrue("Reporter '" + UNIVERSAL + "' missing in solr.node", reporters.containsKey(UNIVERSAL));
@@ -93,8 +95,8 @@ public class SolrMetricsIntegrationTest extends SolrTestCaseJ4 {
 
   @After
   public void afterTest() throws Exception {
-    SolrCoreMetricManager metricManager = h.getCore().getMetricManager();
-    Map<String, SolrMetricReporter> reporters = SolrMetricManager.getReporters(metricManager.getRegistryName());
+    SolrCoreMetricManager coreMetricManager = h.getCore().getCoreMetricManager();
+    Map<String, SolrMetricReporter> reporters = metricManager.getReporters(coreMetricManager.getRegistryName());
 
     deleteCore();
 
@@ -110,8 +112,8 @@ public class SolrMetricsIntegrationTest extends SolrTestCaseJ4 {
     Random random = random();
 
     String metricName = SolrMetricManager.mkName(METRIC_NAME, HANDLER_CATEGORY.toString(), HANDLER_NAME);
-    SolrCoreMetricManager metricManager = h.getCore().getMetricManager();
-    Timer timer = (Timer) SolrMetricManager.timer(metricManager.getRegistryName(), metricName);
+    SolrCoreMetricManager coreMetricManager = h.getCore().getCoreMetricManager();
+    Timer timer = (Timer) metricManager.timer(coreMetricManager.getRegistryName(), metricName);
 
     long initialCount = timer.getCount();
 
@@ -122,7 +124,7 @@ public class SolrMetricsIntegrationTest extends SolrTestCaseJ4 {
 
     long finalCount = timer.getCount();
     assertEquals("metric counter incorrect", iterations, finalCount - initialCount);
-    Map<String, SolrMetricReporter> reporters = SolrMetricManager.getReporters(metricManager.getRegistryName());
+    Map<String, SolrMetricReporter> reporters = metricManager.getReporters(coreMetricManager.getRegistryName());
     assertEquals(RENAMED_REPORTERS.length, reporters.size());
 
     // SPECIFIC and MULTIREGISTRY were skipped because they were

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/test/org/apache/solr/metrics/reporters/MockMetricReporter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/metrics/reporters/MockMetricReporter.java b/solr/core/src/test/org/apache/solr/metrics/reporters/MockMetricReporter.java
index 4d5ef69..2ecc33b 100644
--- a/solr/core/src/test/org/apache/solr/metrics/reporters/MockMetricReporter.java
+++ b/solr/core/src/test/org/apache/solr/metrics/reporters/MockMetricReporter.java
@@ -34,8 +34,8 @@ public class MockMetricReporter extends SolrMetricReporter {
   public boolean didClose = false;
   public boolean didValidate = false;
 
-  public MockMetricReporter(String registryName) {
-    super(registryName);
+  public MockMetricReporter(SolrMetricManager metricManager, String registryName) {
+    super(metricManager, registryName);
   }
 
   @Override
@@ -62,7 +62,7 @@ public class MockMetricReporter extends SolrMetricReporter {
   }
 
   public Metric reportMetric(String metricName) throws NoSuchElementException {
-    MetricRegistry registry = SolrMetricManager.registry(registryName);
+    MetricRegistry registry = metricManager.registry(registryName);
     Metric metric = registry.getMetrics().get(metricName);
     if (metric == null) {
       throw new NoSuchElementException("Metric was not found for metric name = " + metricName);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java b/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java
index 607296e..ea452b2 100644
--- a/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java
@@ -48,7 +48,8 @@ public class SolrJmxReporterTest extends SolrTestCaseJ4 {
 
   private String domain;
 
-  private SolrCoreMetricManager metricManager;
+  private SolrCoreMetricManager coreMetricManager;
+  private SolrMetricManager metricManager;
   private SolrJmxReporter reporter;
   private MBeanServer mBeanServer;
   private String reporterName;
@@ -60,11 +61,12 @@ public class SolrJmxReporterTest extends SolrTestCaseJ4 {
     final SolrCore core = h.getCore();
     domain = core.getName();
 
-    metricManager = new SolrCoreMetricManager(core);
+    coreMetricManager = core.getCoreMetricManager();
+    metricManager = core.getCoreDescriptor().getCoreContainer().getMetricManager();
     PluginInfo pluginInfo = createReporterPluginInfo();
-    SolrMetricManager.loadReporter(metricManager.getRegistryName(), metricManager.getCore().getResourceLoader(), pluginInfo);
+    metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore().getResourceLoader(), pluginInfo);
 
-    Map<String, SolrMetricReporter> reporters = SolrMetricManager.getReporters(metricManager.getRegistryName());
+    Map<String, SolrMetricReporter> reporters = metricManager.getReporters(coreMetricManager.getRegistryName());
     assertTrue("reporters.size should be > 0, but was + " + reporters.size(), reporters.size() > 0);
     reporterName = pluginInfo.name;
     assertNotNull("reporter " + reporterName + " not present among " + reporters, reporters.get(reporterName));
@@ -95,12 +97,12 @@ public class SolrJmxReporterTest extends SolrTestCaseJ4 {
 
   @After
   public void afterTest() throws Exception {
-    SolrMetricManager.closeReporters(metricManager.getRegistryName());
+    metricManager.closeReporters(coreMetricManager.getRegistryName());
     Set<ObjectInstance> objects =
         mBeanServer.queryMBeans(ObjectName.getInstance(domain + ":*"), null);
     assertTrue(objects.isEmpty());
 
-    metricManager.close();
+    coreMetricManager.close();
     deleteCore();
   }
 
@@ -115,8 +117,8 @@ public class SolrJmxReporterTest extends SolrTestCaseJ4 {
     int iterations = TestUtil.nextInt(random, 0, MAX_ITERATIONS);
     for (int i = 0; i < iterations; ++i) {
       Map<String, Counter> metrics = SolrMetricTestUtils.getRandomMetricsWithReplacements(random, registered);
-      SolrMetricProducer producer = SolrMetricTestUtils.getProducerOf(category, scope, metrics);
-      metricManager.registerMetricProducer(scope, producer);
+      SolrMetricProducer producer = SolrMetricTestUtils.getProducerOf(metricManager, category, scope, metrics);
+      coreMetricManager.registerMetricProducer(scope, producer);
       registered.putAll(metrics);
       //waitForListener();
       Set<ObjectInstance> objects = mBeanServer.queryMBeans(null, null);
@@ -133,8 +135,8 @@ public class SolrJmxReporterTest extends SolrTestCaseJ4 {
     String scope = SolrMetricTestUtils.getRandomScope(random, true);
     SolrInfoMBean.Category category = SolrMetricTestUtils.getRandomCategory(random, true);
     Map<String, Counter> metrics = SolrMetricTestUtils.getRandomMetrics(random, true);
-    SolrMetricProducer producer = SolrMetricTestUtils.getProducerOf(category, scope, metrics);
-    metricManager.registerMetricProducer(scope, producer);
+    SolrMetricProducer producer = SolrMetricTestUtils.getProducerOf(metricManager, category, scope, metrics);
+    coreMetricManager.registerMetricProducer(scope, producer);
     Set<ObjectInstance> objects = mBeanServer.queryMBeans(null, null);
     assertEquals(metrics.size(), objects.stream().
         filter(o -> scope.equals(o.getObjectName().getKeyProperty("scope")) &&
@@ -142,8 +144,8 @@ public class SolrJmxReporterTest extends SolrTestCaseJ4 {
 
     h.getCoreContainer().reload(h.getCore().getName());
     PluginInfo pluginInfo = createReporterPluginInfo();
-    SolrMetricManager.loadReporter(metricManager.getRegistryName(), metricManager.getCore().getResourceLoader(), pluginInfo);
-    metricManager.registerMetricProducer(scope, producer);
+    metricManager.loadReporter(coreMetricManager.getRegistryName(), coreMetricManager.getCore().getResourceLoader(), pluginInfo);
+    coreMetricManager.registerMetricProducer(scope, producer);
 
     objects = mBeanServer.queryMBeans(null, null);
     assertEquals(metrics.size(), objects.stream().

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/adfb4a50/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
index 66992a7..4e6f6d6 100644
--- a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
+++ b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
@@ -192,21 +192,17 @@ public class TestHarness extends BaseTestHarness {
         = new UpdateShardHandlerConfig(UpdateShardHandlerConfig.DEFAULT_MAXUPDATECONNECTIONS,
                                        UpdateShardHandlerConfig.DEFAULT_MAXUPDATECONNECTIONSPERHOST,
                                        30000, 30000);
-    // metric reporters
+    // universal default metric reporter
     Map<String,String> attributes = new HashMap<>();
-    attributes.put("group", SolrInfoMBean.Group.core.toString());
     attributes.put("name", "default");
     attributes.put("class", SolrJmxReporter.class.getName());
-    PluginInfo corePlugin = new PluginInfo("reporter", attributes, null, null);
-    attributes = new HashMap<>(attributes);
-    attributes.put("group", SolrInfoMBean.Group.node.toString());
-    PluginInfo nodePlugin = new PluginInfo("reporter", attributes, null, null);
+    PluginInfo defaultPlugin = new PluginInfo("reporter", attributes, null, null);
 
     return new NodeConfig.NodeConfigBuilder("testNode", loader)
         .setUseSchemaCache(Boolean.getBoolean("shareSchema"))
         .setCloudConfig(cloudConfig)
         .setUpdateShardHandlerConfig(updateShardHandlerConfig)
-        .setMetricReporterPlugins(new PluginInfo[] {corePlugin, nodePlugin})
+        .setMetricReporterPlugins(new PluginInfo[] {defaultPlugin})
         .build();
   }
 


Mime
View raw message