lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [23/24] lucene-solr:jira/solr-8593: SOLR-4735 Use overridableRegistryName also for predefined shared registries. Cleanup + javadocs.
Date Tue, 20 Dec 2016 16:39:59 GMT
SOLR-4735 Use overridableRegistryName also for predefined shared registries.
Cleanup + javadocs.


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

Branch: refs/heads/jira/solr-8593
Commit: b37a72d941dba705b43c8868584bd9df775a1537
Parents: 4ccb9fb
Author: Andrzej Bialecki <ab@apache.org>
Authored: Tue Dec 20 14:46:19 2016 +0100
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Tue Dec 20 14:47:40 2016 +0100

----------------------------------------------------------------------
 .../apache/solr/metrics/SolrMetricManager.java  | 29 ++++++++++++++++----
 1 file changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b37a72d9/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 3f51aef..9f126ed 100644
--- a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
+++ b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
@@ -69,20 +69,21 @@ public class SolrMetricManager {
 
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+  /** Common prefix for all registry names that Solr uses. */
   public static final String REGISTRY_NAME_PREFIX = "solr.";
 
+  /** Registry name for Jetty-specific metrics. This name is also subject to overrides controlled
by
+   * system properties. This registry is shared between instances of {@link SolrMetricManager}.
*/
   public static final String JETTY_REGISTRY = REGISTRY_NAME_PREFIX + SolrInfoMBean.Group.jetty.toString();
 
+  /** Registry name for JVM-specific metrics. This name is also subject to overrides controlled
by
+   * system properties. This registry is shared between instances of {@link SolrMetricManager}.
*/
   public static final String JVM_REGISTRY = REGISTRY_NAME_PREFIX + SolrInfoMBean.Group.jvm.toString();
 
   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() { }
@@ -146,13 +147,29 @@ public class SolrMetricManager {
   }
 
   /**
+   * Check for predefined shared registry names. This compares the input name
+   * with normalized and possibly overriden names of predefined shared registries -
+   * {@link #JVM_REGISTRY} and {@link #JETTY_REGISTRY}.
+   * @param registry already normalized and possibly overriden name
+   * @return true if the name matches one of shared registries
+   */
+  private static boolean isSharedRegistry(String registry) {
+    if (overridableRegistryName(JETTY_REGISTRY).equals(registry) ||
+        overridableRegistryName(JVM_REGISTRY).equals(registry)) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  /**
    * Get (or create if not present) a named registry
    * @param registry name of the registry
    * @return existing or newly created registry
    */
   public MetricRegistry registry(String registry) {
     registry = overridableRegistryName(registry);
-    if (JETTY_REGISTRY.equals(registry) || JVM_REGISTRY.equals(registry)) {
+    if (isSharedRegistry(registry)) {
       return SharedMetricRegistries.getOrCreate(registry);
     } else {
       final MetricRegistry existing = registries.get(registry);
@@ -179,7 +196,7 @@ public class SolrMetricManager {
     closeReporters(registry);
     // make sure we use a name with prefix, with overrides
     registry = overridableRegistryName(registry);
-    if (JETTY_REGISTRY.equals(registry) || JVM_REGISTRY.equals(registry)) {
+    if (isSharedRegistry(registry)) {
       SharedMetricRegistries.remove(registry);
     } else {
       registries.remove(registry);


Mime
View raw message