lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1640587 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/core/ solr/core/src/test/org/apache/solr/core/
Date Wed, 19 Nov 2014 16:18:09 GMT
Author: markrmiller
Date: Wed Nov 19 16:18:09 2014
New Revision: 1640587

URL: http://svn.apache.org/r1640587
Log:
SOLR-6747: Add an optional caching option as a workaround for SOLR-6586.

Added:
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/MockInfoMBean.java
      - copied unchanged from r1640582, lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/MockInfoMBean.java
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestSolrDynamicMBean.java
      - copied unchanged from r1640582, lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDynamicMBean.java
Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/solr/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/JmxMonitoredMap.java
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestJmxMonitoredMap.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1640587&r1=1640586&r2=1640587&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Wed Nov 19 16:18:09 2014
@@ -370,6 +370,9 @@ Other Changes
 
 * SOLR-6570: Run SolrZkClient session watch asynchronously. 
  (Ramkumar Aiyengar via Mark Miller)
+ 
+* SOLR-6747: Add an optional caching option as a workaround for SOLR-6586.
+  (Mark Miller, Gregory Chanan)
 
 ==================  4.10.3 ==================
 

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/JmxMonitoredMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/JmxMonitoredMap.java?rev=1640587&r1=1640586&r2=1640587&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/JmxMonitoredMap.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/JmxMonitoredMap.java
Wed Nov 19 16:18:09 2014
@@ -53,6 +53,10 @@ public class JmxMonitoredMap<K, V> exten
   private static final Logger LOG = LoggerFactory.getLogger(JmxMonitoredMap.class
           .getName());
 
+  // set to true to use cached statistics NamedLists between getMBeanInfo calls to work
+  // around over calling getStatistics on MBeanInfos when iterating over all attributes (SOLR-6586)
+  private boolean useCachedStatsBetweenGetMBeanInfoCalls = Boolean.getBoolean("useCachedStatsBetweenGetMBeanInfoCalls");
+  
   private MBeanServer server = null;
 
   private String jmxRootName;
@@ -144,7 +148,7 @@ public class JmxMonitoredMap<K, V> exten
         ObjectName name = getObjectName(key, infoBean);
         if (server.isRegistered(name))
           server.unregisterMBean(name);
-        SolrDynamicMBean mbean = new SolrDynamicMBean(coreHashCode, infoBean);
+        SolrDynamicMBean mbean = new SolrDynamicMBean(coreHashCode, infoBean, useCachedStatsBetweenGetMBeanInfoCalls);
         server.registerMBean(mbean, name);
       } catch (Exception e) {
         LOG.warn( "Failed to register info bean: " + key, e);
@@ -213,8 +217,17 @@ public class JmxMonitoredMap<K, V> exten
     private HashSet<String> staticStats;
 
     private String coreHashCode;
-
+    
+    private volatile NamedList cachedDynamicStats;
+    
+    private boolean useCachedStatsBetweenGetMBeanInfoCalls;
+    
     public SolrDynamicMBean(String coreHashCode, SolrInfoMBean managedResource) {
+      this(coreHashCode, managedResource, false);
+    }
+
+    public SolrDynamicMBean(String coreHashCode, SolrInfoMBean managedResource, boolean useCachedStatsBetweenGetMBeanInfoCalls)
{
+      this.useCachedStatsBetweenGetMBeanInfoCalls = useCachedStatsBetweenGetMBeanInfoCalls;
       this.infoBean = managedResource;
       staticStats = new HashSet<>();
 
@@ -242,6 +255,11 @@ public class JmxMonitoredMap<K, V> exten
 
       try {
         NamedList dynamicStats = infoBean.getStatistics();
+        
+        if (useCachedStatsBetweenGetMBeanInfoCalls) {
+          cachedDynamicStats = dynamicStats;
+        }
+        
         if (dynamicStats != null) {
           for (int i = 0; i < dynamicStats.size(); i++) {
             String name = dynamicStats.getName(i);
@@ -303,8 +321,17 @@ public class JmxMonitoredMap<K, V> exten
           throw new AttributeNotFoundException(attribute);
         }
       } else {
-        NamedList list = infoBean.getStatistics();
-        val = list.get(attribute);
+        NamedList stats = null;
+        if (useCachedStatsBetweenGetMBeanInfoCalls) {
+          NamedList cachedStats = this.cachedDynamicStats;
+          if (cachedStats != null) {
+            stats = cachedStats;
+          }
+        }
+        if (stats == null) {
+          stats = infoBean.getStatistics();
+        }
+        val = stats.get(attribute);
       }
 
       if (val != null) {

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestJmxMonitoredMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestJmxMonitoredMap.java?rev=1640587&r1=1640586&r2=1640587&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestJmxMonitoredMap.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestJmxMonitoredMap.java
Wed Nov 19 16:18:09 2014
@@ -32,9 +32,9 @@ import javax.management.remote.JMXConnec
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
 import javax.management.remote.rmi.RMIConnectorServer;
+
 import java.io.IOException;
 import java.net.ServerSocket;
-import java.net.URL;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.server.RMIServerSocketFactory;
 import java.util.Set;
@@ -175,51 +175,4 @@ public class TestJmxMonitoredMap extends
 
   }
 
-  private class MockInfoMBean implements SolrInfoMBean {
-    @Override
-    public String getName() {
-      return "mock";
-    }
-
-    @Override
-    public Category getCategory() {
-      return Category.OTHER;
-    }
-
-    @Override
-    public String getDescription() {
-      return "mock";
-    }
-
-    @Override
-    public URL[] getDocs() {
-      // TODO Auto-generated method stub
-      return null;
-    }
-
-    @Override
-    public String getVersion() {
-      return "mock";
-    }
-
-    @Override
-    public String getSource() {
-      return "mock";
-    }
-
-    @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");
-      return myList;
-    }
-  }
-
 }



Mime
View raw message