cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r900433 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: cache/ db/
Date Mon, 18 Jan 2010 15:50:39 GMT
Author: jbellis
Date: Mon Jan 18 15:50:38 2010
New Revision: 900433

URL: http://svn.apache.org/viewvc?rev=900433&view=rev
Log:
extract InstrumentingCache from jmx code
patch by jbellis; reviewed by goffinet for CASSANDRA-688

Added:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/AbstractCache.java   (with
props)
    incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXAggregatingCache.java
  (with props)
    incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXAggregatingCacheMBean.java
      - copied, changed from r900432, incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCacheMBean.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCache.java
  (with props)
    incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCacheMBean.java
  (contents, props changed)
      - copied, changed from r900432, incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCacheMBean.java
Removed:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCacheMBean.java
Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCache.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java

Added: incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/AbstractCache.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/AbstractCache.java?rev=900433&view=auto
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/AbstractCache.java (added)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/AbstractCache.java Mon Jan
18 15:50:38 2010
@@ -0,0 +1,22 @@
+package org.apache.cassandra.cache;
+
+import java.lang.management.ManagementFactory;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+public class AbstractCache
+{
+    static void registerMBean(Object cache, String table, String name)
+    {
+        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+        try
+        {
+            String mbeanName = "org.apache.cassandra.db:type=Caches,keyspace=" + table +
",cache=" + name;
+            mbs.registerMBean(cache, new ObjectName(mbeanName));
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+}

Propchange: incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/AbstractCache.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCache.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCache.java?rev=900433&r1=900432&r2=900433&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCache.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCache.java Mon
Jan 18 15:50:38 2010
@@ -1,34 +1,19 @@
 package org.apache.cassandra.cache;
 
-import java.lang.management.ManagementFactory;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
 import com.reardencommerce.kernel.collections.shared.evictable.ConcurrentLinkedHashMap;
 import org.apache.cassandra.utils.TimedStatsDeque;
 
-public class InstrumentedCache<K, V> implements InstrumentedCacheMBean
+public class InstrumentedCache<K, V>
 {
     private final int capacity;
     private final ConcurrentLinkedHashMap<K, V> map;
     private final TimedStatsDeque stats;
 
-    public InstrumentedCache(String table, String name, int capacity)
+    public InstrumentedCache(int capacity)
     {
         this.capacity = capacity;
         map = ConcurrentLinkedHashMap.create(ConcurrentLinkedHashMap.EvictionPolicy.SECOND_CHANCE,
capacity);
         stats = new TimedStatsDeque(60000);
-
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        try
-        {
-            String mbeanName = "org.apache.cassandra.db:type=Caches,keyspace=" + table +
",cache=" + name;
-            mbs.registerMBean(this, new ObjectName(mbeanName));
-        }
-        catch (Exception e)
-        {
-            throw new RuntimeException(e);
-        }
     }
 
     public void put(K key, V value)

Added: incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXAggregatingCache.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXAggregatingCache.java?rev=900433&view=auto
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXAggregatingCache.java
(added)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXAggregatingCache.java
Mon Jan 18 15:50:38 2010
@@ -0,0 +1,5 @@
+package org.apache.cassandra.cache;
+
+public class JMXAggregatingCache
+{
+}

Propchange: incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXAggregatingCache.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXAggregatingCacheMBean.java
(from r900432, incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCacheMBean.java)
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXAggregatingCacheMBean.java?p2=incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXAggregatingCacheMBean.java&p1=incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCacheMBean.java&r1=900432&r2=900433&rev=900433&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCacheMBean.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXAggregatingCacheMBean.java
Mon Jan 18 15:50:38 2010
@@ -1,8 +1,8 @@
 package org.apache.cassandra.cache;
 
-public interface InstrumentedCacheMBean
+public interface JMXAggregatingCacheMBean
 {
     public int getCapacity();
     public int getSize();
     public double getHitRate();
-}
+}
\ No newline at end of file

Added: incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCache.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCache.java?rev=900433&view=auto
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCache.java
(added)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCache.java
Mon Jan 18 15:50:38 2010
@@ -0,0 +1,10 @@
+package org.apache.cassandra.cache;
+
+public class JMXInstrumentedCache<K, V> extends InstrumentedCache<K, V> implements
JMXInstrumentedCacheMBean
+{
+    public JMXInstrumentedCache(String table, String name, int capacity)
+    {
+        super(capacity);
+        AbstractCache.registerMBean(this, table, name);
+    }
+}
\ No newline at end of file

Propchange: incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCache.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCacheMBean.java
(from r900432, incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCacheMBean.java)
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCacheMBean.java?p2=incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCacheMBean.java&p1=incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCacheMBean.java&r1=900432&r2=900433&rev=900433&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/InstrumentedCacheMBean.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCacheMBean.java
Mon Jan 18 15:50:38 2010
@@ -1,6 +1,6 @@
 package org.apache.cassandra.cache;
 
-public interface InstrumentedCacheMBean
+public interface JMXInstrumentedCacheMBean
 {
     public int getCapacity();
     public int getSize();

Propchange: incubator/cassandra/trunk/src/java/org/apache/cassandra/cache/JMXInstrumentedCacheMBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=900433&r1=900432&r2=900433&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Mon
Jan 18 15:50:38 2010
@@ -31,6 +31,7 @@
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.cassandra.cache.InstrumentedCache;
+import org.apache.cassandra.cache.JMXInstrumentedCache;
 import org.apache.cassandra.service.SliceRange;
 import org.apache.log4j.Logger;
 
@@ -106,7 +107,7 @@
     /* active memtable associated with this ColumnFamilyStore. */
     private Memtable memtable_;
 
-    private InstrumentedCache<String, ColumnFamily> rowCache;
+    private JMXInstrumentedCache<String, ColumnFamily> rowCache;
 
     // TODO binarymemtable ops are not threadsafe (do they need to be?)
     private AtomicReference<BinaryMemtable> binaryMemtable_;
@@ -191,7 +192,7 @@
             int cacheSize = Math.max(1, (int)(v * SSTableReader.estimatedKeys(columnFamilyName)));
             if (logger_.isDebugEnabled())
                 logger_.debug("enabling row cache for " + columnFamilyName + " with size
" + cacheSize);
-            rowCache = new InstrumentedCache<String, ColumnFamily>(table, columnFamilyName
+ "RowCache", cacheSize);
+            rowCache = new JMXInstrumentedCache<String, ColumnFamily>(table, columnFamilyName
+ "RowCache", cacheSize);
         }
     }
 



Mime
View raw message