cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject git commit: Allow cache-keys-to-save to be set at runtime patch by Chris Burroughs; reviewed by jbellis for CASSANDRA-5980
Date Thu, 19 Sep 2013 15:22:07 GMT
Updated Branches:
  refs/heads/cassandra-1.2 937536363 -> df046d6b4


Allow cache-keys-to-save to be set at runtime
patch by Chris Burroughs; reviewed by jbellis for CASSANDRA-5980


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

Branch: refs/heads/cassandra-1.2
Commit: df046d6b4262c3a879b60d1b6f082aea792e09a0
Parents: 9375363
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Sep 19 10:18:07 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Sep 19 10:18:07 2013 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  4 ++
 .../cassandra/config/DatabaseDescriptor.java    | 10 +++++
 .../apache/cassandra/service/CacheService.java  | 42 ++++++++++++++++----
 .../cassandra/service/CacheServiceMBean.java    |  6 +++
 .../org/apache/cassandra/tools/NodeCmd.java     |  8 +++-
 .../org/apache/cassandra/tools/NodeProbe.java   | 16 ++++++++
 .../apache/cassandra/tools/NodeToolHelp.yaml    |  3 ++
 7 files changed, 80 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/df046d6b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f853cce..27e6f24 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+1.2.11
+ * Allow cache-keys-to-save to be set at runtime (CASSANDRA-5980)
+
+
 1.2.10
  * Avoid second-guessing out-of-space state (CASSANDRA-5605)
  * Tuning knobs for dealing with large blobs and many CFs (CASSANDRA-5982)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/df046d6b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index 8e3cbe2..22de2d6 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -1251,6 +1251,11 @@ public class DatabaseDescriptor
         return conf.key_cache_keys_to_save;
     }
 
+    public static void setKeyCacheKeysToSave(int keyCacheKeysToSave)
+    {
+        conf.key_cache_keys_to_save = keyCacheKeysToSave;
+    }
+
     public static long getRowCacheSizeInMB()
     {
         return conf.row_cache_size_in_mb;
@@ -1271,6 +1276,11 @@ public class DatabaseDescriptor
         return conf.row_cache_keys_to_save;
     }
 
+    public static void setRowCacheKeysToSave(int rowCacheKeysToSave)
+    {
+        conf.row_cache_keys_to_save = rowCacheKeysToSave;
+    }
+
     public static IRowCacheProvider getRowCacheProvider()
     {
         return rowCacheProvider;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/df046d6b/src/java/org/apache/cassandra/service/CacheService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CacheService.java b/src/java/org/apache/cassandra/service/CacheService.java
index 34864f2..5d3dc72 100644
--- a/src/java/org/apache/cassandra/service/CacheService.java
+++ b/src/java/org/apache/cassandra/service/CacheService.java
@@ -207,13 +207,13 @@ public class CacheService implements CacheServiceMBean
         return DatabaseDescriptor.getRowCacheSavePeriod();
     }
 
-    public void setRowCacheSavePeriodInSeconds(int rcspis)
+    public void setRowCacheSavePeriodInSeconds(int seconds)
     {
-        if (rcspis < 0)
+        if (seconds < 0)
             throw new RuntimeException("RowCacheSavePeriodInSeconds must be non-negative.");
 
-        DatabaseDescriptor.setRowCacheSavePeriod(rcspis);
-        rowCache.scheduleSaving(rcspis, DatabaseDescriptor.getRowCacheKeysToSave());
+        DatabaseDescriptor.setRowCacheSavePeriod(seconds);
+        rowCache.scheduleSaving(seconds, DatabaseDescriptor.getRowCacheKeysToSave());
     }
 
     public int getKeyCacheSavePeriodInSeconds()
@@ -221,13 +221,39 @@ public class CacheService implements CacheServiceMBean
         return DatabaseDescriptor.getKeyCacheSavePeriod();
     }
 
-    public void setKeyCacheSavePeriodInSeconds(int kcspis)
+    public void setKeyCacheSavePeriodInSeconds(int seconds)
     {
-        if (kcspis < 0)
+        if (seconds < 0)
             throw new RuntimeException("KeyCacheSavePeriodInSeconds must be non-negative.");
 
-        DatabaseDescriptor.setKeyCacheSavePeriod(kcspis);
-        keyCache.scheduleSaving(kcspis, DatabaseDescriptor.getKeyCacheKeysToSave());
+        DatabaseDescriptor.setKeyCacheSavePeriod(seconds);
+        keyCache.scheduleSaving(seconds, DatabaseDescriptor.getKeyCacheKeysToSave());
+    }
+
+    public int getRowCacheKeysToSave()
+    {
+        return DatabaseDescriptor.getRowCacheKeysToSave();
+    }
+
+    public void setRowCacheKeysToSave(int count)
+    {
+        if (count < 0)
+            throw new RuntimeException("RowCacheKeysToSave must be non-negative.");
+        DatabaseDescriptor.setRowCacheKeysToSave(count);
+        rowCache.scheduleSaving(getRowCacheSavePeriodInSeconds(), count);
+    }
+
+    public int getKeyCacheKeysToSave()
+    {
+        return DatabaseDescriptor.getKeyCacheKeysToSave();
+    }
+
+    public void setKeyCacheKeysToSave(int count)
+    {
+        if (count < 0)
+            throw new RuntimeException("KeyCacheKeysToSave must be non-negative.");
+        DatabaseDescriptor.setKeyCacheKeysToSave(count);
+        keyCache.scheduleSaving(getKeyCacheSavePeriodInSeconds(), count);
     }
 
     public void invalidateKeyCache()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/df046d6b/src/java/org/apache/cassandra/service/CacheServiceMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CacheServiceMBean.java b/src/java/org/apache/cassandra/service/CacheServiceMBean.java
index 8b8adf2..0225db2 100644
--- a/src/java/org/apache/cassandra/service/CacheServiceMBean.java
+++ b/src/java/org/apache/cassandra/service/CacheServiceMBean.java
@@ -27,6 +27,12 @@ public interface CacheServiceMBean
     public int getKeyCacheSavePeriodInSeconds();
     public void setKeyCacheSavePeriodInSeconds(int kcspis);
 
+    public int getRowCacheKeysToSave();
+    public void setRowCacheKeysToSave(int rckts);
+
+    public int getKeyCacheKeysToSave();
+    public void setKeyCacheKeysToSave(int kckts);
+
     /**
      * invalidate the key cache; for use after invalidating row cache
      */

http://git-wip-us.apache.org/repos/asf/cassandra/blob/df046d6b/src/java/org/apache/cassandra/tools/NodeCmd.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeCmd.java b/src/java/org/apache/cassandra/tools/NodeCmd.java
index 7a770bb..26cc50e 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -164,7 +164,8 @@ public class NodeCmd
         RESETLOCALSCHEMA,
         PREDICTCONSISTENCY,
         ENABLEBACKUP,
-        DISABLEBACKUP
+        DISABLEBACKUP,
+        SETCACHEKEYSTOSAVE
     }
 
 
@@ -1271,6 +1272,11 @@ public class NodeCmd
                     probe.setCacheCapacities(Integer.parseInt(arguments[0]), Integer.parseInt(arguments[1]));
                     break;
 
+                case SETCACHEKEYSTOSAVE :
+                    if (arguments.length != 2) { badUse("setcachekeystosave requires key-cache-keys-to-save,
and row-cache-keys-to-save args."); }
+                    probe.setCacheKeysToSave(Integer.parseInt(arguments[0]), Integer.parseInt(arguments[1]));
+                    break;
+
                 case SETCOMPACTIONTHRESHOLD :
                     if (arguments.length != 4) { badUse("setcompactionthreshold requires
ks, cf, min, and max threshold args."); }
                     int minthreshold = Integer.parseInt(arguments[2]);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/df046d6b/src/java/org/apache/cassandra/tools/NodeProbe.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java b/src/java/org/apache/cassandra/tools/NodeProbe.java
index e7cf592..7829b60 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -526,6 +526,22 @@ public class NodeProbe
         }
     }
 
+    public void setCacheKeysToSave(int keyCacheKeysToSave, int rowCacheKeysToSave)
+    {
+        try
+        {
+            String keyCachePath = "org.apache.cassandra.db:type=Caches";
+            CacheServiceMBean cacheMBean = JMX.newMBeanProxy(mbeanServerConn, new ObjectName(keyCachePath),
CacheServiceMBean.class);
+            cacheMBean.setKeyCacheKeysToSave(keyCacheKeysToSave);
+            cacheMBean.setRowCacheKeysToSave(rowCacheKeysToSave);
+        }
+        catch (MalformedObjectNameException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+
+
     public List<InetAddress> getEndpoints(String keyspace, String cf, String key)
     {
         return ssProxy.getNaturalEndpoints(keyspace, cf, key);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/df046d6b/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
----------------------------------------------------------------------
diff --git a/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml b/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
index b540b2c..6feb7b4 100644
--- a/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
+++ b/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
@@ -185,6 +185,9 @@ commands:
   - name: setcachecapacity <key-cache-capacity> <row-cache-capacity>
     help: |
       Set global key and row cache capacities (in MB units).
+  - name: setcachekeystosave <key-cache-keys-to-save> <row-cache-keys-to-save>
+    help: |
+      Set number of keys saved by each cache for faster post-restart warmup. 0 to disable.
   - name: getendpoints <keyspace> <cf> <key>
     help: |
       Print the end points that owns the key


Mime
View raw message