You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2010/10/13 19:40:58 UTC

svn commit: r1022209 - in /cassandra/trunk: ./ interface/ interface/thrift/gen-java/org/apache/cassandra/thrift/ src/java/org/apache/cassandra/config/

Author: jbellis
Date: Wed Oct 13 17:40:56 2010
New Revision: 1022209

URL: http://svn.apache.org/viewvc?rev=1022209&view=rev
Log:
add row/key cache save periods to CfDef.
patch by Jon Hermes; reviewed by jbellis for CASSANDRA-1606

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/interface/cassandra.thrift
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/CfDef.java
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
    cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1022209&r1=1022208&r2=1022209&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Wed Oct 13 17:40:56 2010
@@ -17,7 +17,7 @@ dev
    (CASSANDRA-1566)
  * allow keyspace creation with RF > N (CASSANDRA-1428)
  * improve cli error handling (CASSANDRA-1580)
- * add cache save/load ability (CASSANDRA-1417)
+ * add cache save/load ability (CASSANDRA-1417, 1606)
  * add StorageService.getDrainProgress (CASSANDRA-1588)
  * Disallow bootstrap to an in-use token (CASSANDRA-1561)
  * Allow dynamic secondary index creation and destruction (CASSANDRA-1532)

Modified: cassandra/trunk/interface/cassandra.thrift
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/cassandra.thrift?rev=1022209&r1=1022208&r2=1022209&view=diff
==============================================================================
--- cassandra/trunk/interface/cassandra.thrift (original)
+++ cassandra/trunk/interface/cassandra.thrift Wed Oct 13 17:40:56 2010
@@ -46,7 +46,7 @@ namespace rb CassandraThrift
 #           for every edit that doesn't result in a change to major/minor.
 #
 # See the Semantic Versioning Specification (SemVer) http://semver.org.
-const string VERSION = "19.0.0"
+const string VERSION = "19.1.0"
 
 
 #
@@ -342,6 +342,8 @@ struct CfDef {
     16: optional i32 id,
     17: optional i32 min_compaction_threshold,
     18: optional i32 max_compaction_threshold,
+    19: optional i32 row_cache_save_period_in_seconds,
+    20: optional i32 key_cache_save_period_in_seconds,
 }
 
 /* describes a keyspace. */

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/CfDef.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/CfDef.java?rev=1022209&r1=1022208&r2=1022209&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/CfDef.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/CfDef.java Wed Oct 13 17:40:56 2010
@@ -66,6 +66,8 @@ public class CfDef implements TBase<CfDe
   private static final TField ID_FIELD_DESC = new TField("id", TType.I32, (short)16);
   private static final TField MIN_COMPACTION_THRESHOLD_FIELD_DESC = new TField("min_compaction_threshold", TType.I32, (short)17);
   private static final TField MAX_COMPACTION_THRESHOLD_FIELD_DESC = new TField("max_compaction_threshold", TType.I32, (short)18);
+  private static final TField ROW_CACHE_SAVE_PERIOD_IN_SECONDS_FIELD_DESC = new TField("row_cache_save_period_in_seconds", TType.I32, (short)19);
+  private static final TField KEY_CACHE_SAVE_PERIOD_IN_SECONDS_FIELD_DESC = new TField("key_cache_save_period_in_seconds", TType.I32, (short)20);
 
   public String keyspace;
   public String name;
@@ -83,6 +85,8 @@ public class CfDef implements TBase<CfDe
   public int id;
   public int min_compaction_threshold;
   public int max_compaction_threshold;
+  public int row_cache_save_period_in_seconds;
+  public int key_cache_save_period_in_seconds;
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements TFieldIdEnum {
@@ -101,7 +105,9 @@ public class CfDef implements TBase<CfDe
     DEFAULT_VALIDATION_CLASS((short)15, "default_validation_class"),
     ID((short)16, "id"),
     MIN_COMPACTION_THRESHOLD((short)17, "min_compaction_threshold"),
-    MAX_COMPACTION_THRESHOLD((short)18, "max_compaction_threshold");
+    MAX_COMPACTION_THRESHOLD((short)18, "max_compaction_threshold"),
+    ROW_CACHE_SAVE_PERIOD_IN_SECONDS((short)19, "row_cache_save_period_in_seconds"),
+    KEY_CACHE_SAVE_PERIOD_IN_SECONDS((short)20, "key_cache_save_period_in_seconds");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -148,6 +154,10 @@ public class CfDef implements TBase<CfDe
           return MIN_COMPACTION_THRESHOLD;
         case 18: // MAX_COMPACTION_THRESHOLD
           return MAX_COMPACTION_THRESHOLD;
+        case 19: // ROW_CACHE_SAVE_PERIOD_IN_SECONDS
+          return ROW_CACHE_SAVE_PERIOD_IN_SECONDS;
+        case 20: // KEY_CACHE_SAVE_PERIOD_IN_SECONDS
+          return KEY_CACHE_SAVE_PERIOD_IN_SECONDS;
         default:
           return null;
       }
@@ -196,7 +206,9 @@ public class CfDef implements TBase<CfDe
   private static final int __ID_ISSET_ID = 5;
   private static final int __MIN_COMPACTION_THRESHOLD_ISSET_ID = 6;
   private static final int __MAX_COMPACTION_THRESHOLD_ISSET_ID = 7;
-  private BitSet __isset_bit_vector = new BitSet(8);
+  private static final int __ROW_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID = 8;
+  private static final int __KEY_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID = 9;
+  private BitSet __isset_bit_vector = new BitSet(10);
 
   public static final Map<_Fields, FieldMetaData> metaDataMap;
   static {
@@ -234,6 +246,10 @@ public class CfDef implements TBase<CfDe
         new FieldValueMetaData(TType.I32)));
     tmpMap.put(_Fields.MAX_COMPACTION_THRESHOLD, new FieldMetaData("max_compaction_threshold", TFieldRequirementType.OPTIONAL, 
         new FieldValueMetaData(TType.I32)));
+    tmpMap.put(_Fields.ROW_CACHE_SAVE_PERIOD_IN_SECONDS, new FieldMetaData("row_cache_save_period_in_seconds", TFieldRequirementType.OPTIONAL, 
+        new FieldValueMetaData(TType.I32)));
+    tmpMap.put(_Fields.KEY_CACHE_SAVE_PERIOD_IN_SECONDS, new FieldMetaData("key_cache_save_period_in_seconds", TFieldRequirementType.OPTIONAL, 
+        new FieldValueMetaData(TType.I32)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     FieldMetaData.addStructMetaDataMap(CfDef.class, metaDataMap);
   }
@@ -304,6 +320,8 @@ public class CfDef implements TBase<CfDe
     this.id = other.id;
     this.min_compaction_threshold = other.min_compaction_threshold;
     this.max_compaction_threshold = other.max_compaction_threshold;
+    this.row_cache_save_period_in_seconds = other.row_cache_save_period_in_seconds;
+    this.key_cache_save_period_in_seconds = other.key_cache_save_period_in_seconds;
   }
 
   public CfDef deepCopy() {
@@ -706,6 +724,52 @@ public class CfDef implements TBase<CfDe
     __isset_bit_vector.set(__MAX_COMPACTION_THRESHOLD_ISSET_ID, value);
   }
 
+  public int getRow_cache_save_period_in_seconds() {
+    return this.row_cache_save_period_in_seconds;
+  }
+
+  public CfDef setRow_cache_save_period_in_seconds(int row_cache_save_period_in_seconds) {
+    this.row_cache_save_period_in_seconds = row_cache_save_period_in_seconds;
+    setRow_cache_save_period_in_secondsIsSet(true);
+    return this;
+  }
+
+  public void unsetRow_cache_save_period_in_seconds() {
+    __isset_bit_vector.clear(__ROW_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID);
+  }
+
+  /** Returns true if field row_cache_save_period_in_seconds is set (has been asigned a value) and false otherwise */
+  public boolean isSetRow_cache_save_period_in_seconds() {
+    return __isset_bit_vector.get(__ROW_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID);
+  }
+
+  public void setRow_cache_save_period_in_secondsIsSet(boolean value) {
+    __isset_bit_vector.set(__ROW_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID, value);
+  }
+
+  public int getKey_cache_save_period_in_seconds() {
+    return this.key_cache_save_period_in_seconds;
+  }
+
+  public CfDef setKey_cache_save_period_in_seconds(int key_cache_save_period_in_seconds) {
+    this.key_cache_save_period_in_seconds = key_cache_save_period_in_seconds;
+    setKey_cache_save_period_in_secondsIsSet(true);
+    return this;
+  }
+
+  public void unsetKey_cache_save_period_in_seconds() {
+    __isset_bit_vector.clear(__KEY_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID);
+  }
+
+  /** Returns true if field key_cache_save_period_in_seconds is set (has been asigned a value) and false otherwise */
+  public boolean isSetKey_cache_save_period_in_seconds() {
+    return __isset_bit_vector.get(__KEY_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID);
+  }
+
+  public void setKey_cache_save_period_in_secondsIsSet(boolean value) {
+    __isset_bit_vector.set(__KEY_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID, value);
+  }
+
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
     case KEYSPACE:
@@ -836,6 +900,22 @@ public class CfDef implements TBase<CfDe
       }
       break;
 
+    case ROW_CACHE_SAVE_PERIOD_IN_SECONDS:
+      if (value == null) {
+        unsetRow_cache_save_period_in_seconds();
+      } else {
+        setRow_cache_save_period_in_seconds((Integer)value);
+      }
+      break;
+
+    case KEY_CACHE_SAVE_PERIOD_IN_SECONDS:
+      if (value == null) {
+        unsetKey_cache_save_period_in_seconds();
+      } else {
+        setKey_cache_save_period_in_seconds((Integer)value);
+      }
+      break;
+
     }
   }
 
@@ -893,6 +973,12 @@ public class CfDef implements TBase<CfDe
     case MAX_COMPACTION_THRESHOLD:
       return new Integer(getMax_compaction_threshold());
 
+    case ROW_CACHE_SAVE_PERIOD_IN_SECONDS:
+      return new Integer(getRow_cache_save_period_in_seconds());
+
+    case KEY_CACHE_SAVE_PERIOD_IN_SECONDS:
+      return new Integer(getKey_cache_save_period_in_seconds());
+
     }
     throw new IllegalStateException();
   }
@@ -936,6 +1022,10 @@ public class CfDef implements TBase<CfDe
       return isSetMin_compaction_threshold();
     case MAX_COMPACTION_THRESHOLD:
       return isSetMax_compaction_threshold();
+    case ROW_CACHE_SAVE_PERIOD_IN_SECONDS:
+      return isSetRow_cache_save_period_in_seconds();
+    case KEY_CACHE_SAVE_PERIOD_IN_SECONDS:
+      return isSetKey_cache_save_period_in_seconds();
     }
     throw new IllegalStateException();
   }
@@ -1101,6 +1191,24 @@ public class CfDef implements TBase<CfDe
         return false;
     }
 
+    boolean this_present_row_cache_save_period_in_seconds = true && this.isSetRow_cache_save_period_in_seconds();
+    boolean that_present_row_cache_save_period_in_seconds = true && that.isSetRow_cache_save_period_in_seconds();
+    if (this_present_row_cache_save_period_in_seconds || that_present_row_cache_save_period_in_seconds) {
+      if (!(this_present_row_cache_save_period_in_seconds && that_present_row_cache_save_period_in_seconds))
+        return false;
+      if (this.row_cache_save_period_in_seconds != that.row_cache_save_period_in_seconds)
+        return false;
+    }
+
+    boolean this_present_key_cache_save_period_in_seconds = true && this.isSetKey_cache_save_period_in_seconds();
+    boolean that_present_key_cache_save_period_in_seconds = true && that.isSetKey_cache_save_period_in_seconds();
+    if (this_present_key_cache_save_period_in_seconds || that_present_key_cache_save_period_in_seconds) {
+      if (!(this_present_key_cache_save_period_in_seconds && that_present_key_cache_save_period_in_seconds))
+        return false;
+      if (this.key_cache_save_period_in_seconds != that.key_cache_save_period_in_seconds)
+        return false;
+    }
+
     return true;
   }
 
@@ -1188,6 +1296,16 @@ public class CfDef implements TBase<CfDe
     if (present_max_compaction_threshold)
       builder.append(max_compaction_threshold);
 
+    boolean present_row_cache_save_period_in_seconds = true && (isSetRow_cache_save_period_in_seconds());
+    builder.append(present_row_cache_save_period_in_seconds);
+    if (present_row_cache_save_period_in_seconds)
+      builder.append(row_cache_save_period_in_seconds);
+
+    boolean present_key_cache_save_period_in_seconds = true && (isSetKey_cache_save_period_in_seconds());
+    builder.append(present_key_cache_save_period_in_seconds);
+    if (present_key_cache_save_period_in_seconds)
+      builder.append(key_cache_save_period_in_seconds);
+
     return builder.toHashCode();
   }
 
@@ -1343,6 +1461,24 @@ public class CfDef implements TBase<CfDe
         return lastComparison;
       }
     }
+    lastComparison = Boolean.valueOf(isSetRow_cache_save_period_in_seconds()).compareTo(typedOther.isSetRow_cache_save_period_in_seconds());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetRow_cache_save_period_in_seconds()) {      lastComparison = TBaseHelper.compareTo(this.row_cache_save_period_in_seconds, typedOther.row_cache_save_period_in_seconds);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetKey_cache_save_period_in_seconds()).compareTo(typedOther.isSetKey_cache_save_period_in_seconds());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetKey_cache_save_period_in_seconds()) {      lastComparison = TBaseHelper.compareTo(this.key_cache_save_period_in_seconds, typedOther.key_cache_save_period_in_seconds);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
     return 0;
   }
 
@@ -1487,6 +1623,22 @@ public class CfDef implements TBase<CfDe
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
+        case 19: // ROW_CACHE_SAVE_PERIOD_IN_SECONDS
+          if (field.type == TType.I32) {
+            this.row_cache_save_period_in_seconds = iprot.readI32();
+            setRow_cache_save_period_in_secondsIsSet(true);
+          } else { 
+            TProtocolUtil.skip(iprot, field.type);
+          }
+          break;
+        case 20: // KEY_CACHE_SAVE_PERIOD_IN_SECONDS
+          if (field.type == TType.I32) {
+            this.key_cache_save_period_in_seconds = iprot.readI32();
+            setKey_cache_save_period_in_secondsIsSet(true);
+          } else { 
+            TProtocolUtil.skip(iprot, field.type);
+          }
+          break;
         default:
           TProtocolUtil.skip(iprot, field.type);
       }
@@ -1601,6 +1753,16 @@ public class CfDef implements TBase<CfDe
       oprot.writeI32(this.max_compaction_threshold);
       oprot.writeFieldEnd();
     }
+    if (isSetRow_cache_save_period_in_seconds()) {
+      oprot.writeFieldBegin(ROW_CACHE_SAVE_PERIOD_IN_SECONDS_FIELD_DESC);
+      oprot.writeI32(this.row_cache_save_period_in_seconds);
+      oprot.writeFieldEnd();
+    }
+    if (isSetKey_cache_save_period_in_seconds()) {
+      oprot.writeFieldBegin(KEY_CACHE_SAVE_PERIOD_IN_SECONDS_FIELD_DESC);
+      oprot.writeI32(this.key_cache_save_period_in_seconds);
+      oprot.writeFieldEnd();
+    }
     oprot.writeFieldStop();
     oprot.writeStructEnd();
   }
@@ -1733,6 +1895,18 @@ public class CfDef implements TBase<CfDe
       sb.append(this.max_compaction_threshold);
       first = false;
     }
+    if (isSetRow_cache_save_period_in_seconds()) {
+      if (!first) sb.append(", ");
+      sb.append("row_cache_save_period_in_seconds:");
+      sb.append(this.row_cache_save_period_in_seconds);
+      first = false;
+    }
+    if (isSetKey_cache_save_period_in_seconds()) {
+      if (!first) sb.append(", ");
+      sb.append("key_cache_save_period_in_seconds:");
+      sb.append(this.key_cache_save_period_in_seconds);
+      first = false;
+    }
     sb.append(")");
     return sb.toString();
   }

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java?rev=1022209&r1=1022208&r2=1022209&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java Wed Oct 13 17:40:56 2010
@@ -43,6 +43,6 @@ import org.slf4j.LoggerFactory;
 
 public class Constants {
 
-  public static final String VERSION = "18.1.0";
+  public static final String VERSION = "19.1.0";
 
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java?rev=1022209&r1=1022208&r2=1022209&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java Wed Oct 13 17:40:56 2010
@@ -125,8 +125,8 @@ public final class CFMetaData
     public final AbstractType defaultValidator;     // default none, use comparator types
     public final Integer minCompactionThreshold;    // default 4
     public final Integer maxCompactionThreshold;    // default 32
-    public final int rowCacheSavePeriodInSeconds; //default 0 (off)
-    public final int keyCacheSavePeriodInSeconds; //default 0 (off)
+    public final int rowCacheSavePeriodInSeconds;   // default 0 (off)
+    public final int keyCacheSavePeriodInSeconds;   // default 3600 (1 hour)
     // NOTE: if you find yourself adding members to this class, make sure you keep the convert methods in lockstep.
 
     public final Map<byte[], ColumnDefinition> column_metadata;
@@ -548,8 +548,8 @@ public final class CFMetaData
                               cf_def.max_compaction_threshold,
                               cfId,
                               metadata,
-                              rowCacheSavePeriodInSeconds,
-                              keyCacheSavePeriodInSeconds);
+                              cf_def.row_cache_save_period_in_seconds,
+                              cf_def.key_cache_save_period_in_seconds);
     }
     
     // converts CFM to thrift CfDef
@@ -573,6 +573,8 @@ public final class CFMetaData
         def.setDefault_validation_class(cfm.defaultValidator.getClass().getName());
         def.setMin_compaction_threshold(cfm.minCompactionThreshold);
         def.setMax_compaction_threshold(cfm.maxCompactionThreshold);
+        def.setRow_cache_save_period_in_seconds(cfm.rowCacheSavePeriodInSeconds);
+        def.setKey_cache_save_period_in_seconds(cfm.keyCacheSavePeriodInSeconds);
         List<org.apache.cassandra.thrift.ColumnDef> column_meta = new ArrayList< org.apache.cassandra.thrift.ColumnDef>(cfm.column_metadata.size());
         for (ColumnDefinition cd : cfm.column_metadata.values())
         {
@@ -703,6 +705,8 @@ public final class CFMetaData
                ", defaultValidator=" + defaultValidator +
                ", minCompactionThreshold=" + minCompactionThreshold +
                ", maxCompactionThreshold=" + maxCompactionThreshold +
+               ", rowcachesaveperiodsecs= " + rowCacheSavePeriodInSeconds +
+               ", keycachesaveperiodsecs= " + keyCacheSavePeriodInSeconds +
                ", column_metadata=" + FBUtilities.toString(column_metadata) +
                '}';
     }