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 2012/01/31 04:56:43 UTC

git commit: remove deprecated KsDef.replication_factor from KsMetaData patch by jbellis; reviewed by brandonwilliams for CASSANDRA-3793

Updated Branches:
  refs/heads/trunk 3d55a2b03 -> f0ec9e4ea


remove deprecated KsDef.replication_factor from KsMetaData
patch by jbellis; reviewed by brandonwilliams for CASSANDRA-3793


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

Branch: refs/heads/trunk
Commit: f0ec9e4eaa05071c2acf9e732d9f5e5c814ab339
Parents: 3d55a2b
Author: Jonathan Ellis <jb...@apache.org>
Authored: Thu Jan 26 17:39:14 2012 -0600
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Mon Jan 30 21:56:27 2012 -0600

----------------------------------------------------------------------
 NEWS.txt                                           |    3 +
 interface/cassandra.thrift                         |    5 +-
 .../org/apache/cassandra/thrift/Cassandra.java     |    4 +
 .../org/apache/cassandra/thrift/Constants.java     |    2 +-
 .../org/apache/cassandra/thrift/KsDef.java         |  106 +--------------
 src/java/org/apache/cassandra/cli/CliClient.java   |    3 -
 .../org/apache/cassandra/config/KSMetaData.java    |   22 +---
 .../apache/cassandra/thrift/ThriftValidation.java  |    2 +-
 8 files changed, 13 insertions(+), 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0ec9e4e/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 0b227f3..8fca1cd 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -14,6 +14,9 @@ by version X, but the inverse is not necessarily the case.)
 
 Upgrading
 ---------
+    - The KsDef.replication_factor field (deprecated since 0.8) has
+      been removed.  Older clients will need to be updated to be able
+      to continue to created and update keyspaces.
     - If you are running a multi datacenter setup, you should upgrade to
       the latest 1.0.x (or 0.8.x) release before upgrading.  Versions
       0.8.8 and 1.0.3-1.0.5 generate cross-dc forwarding that is incompatible

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0ec9e4e/interface/cassandra.thrift
----------------------------------------------------------------------
diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift
index 99e7d1c..5fd2af6 100644
--- a/interface/cassandra.thrift
+++ b/interface/cassandra.thrift
@@ -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.27.0"
+const string VERSION = "19.28.0"
 
 
 #
@@ -425,9 +425,6 @@ struct KsDef {
     2: required string strategy_class,
     3: optional map<string,string> strategy_options,
 
-    /** @deprecated */
-    4: optional i32 replication_factor, 
-
     5: required list<CfDef> cf_defs,
     6: optional bool durable_writes=1,
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0ec9e4e/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
----------------------------------------------------------------------
diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
index 5b79e18..58f5ac5 100644
--- a/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
+++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
@@ -17733,6 +17733,8 @@ public class Cassandra {
 
     private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
       try {
+        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+        __isset_bit_vector = new BitSet(1);
         read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
       } catch (org.apache.thrift.TException te) {
         throw new java.io.IOException(te);
@@ -34146,6 +34148,8 @@ public class Cassandra {
 
     private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
       try {
+        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+        __isset_bit_vector = new BitSet(1);
         read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
       } catch (org.apache.thrift.TException te) {
         throw new java.io.IOException(te);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0ec9e4e/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
----------------------------------------------------------------------
diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
index 8227239..ff0f180 100644
--- a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
+++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
@@ -44,6 +44,6 @@ import org.slf4j.LoggerFactory;
 
 public class Constants {
 
-  public static final String VERSION = "19.27.0";
+  public static final String VERSION = "19.28.0";
 
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0ec9e4e/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java
----------------------------------------------------------------------
diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java
index bc552ab..0c20439 100644
--- a/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java
+++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java
@@ -48,17 +48,12 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
   private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)1);
   private static final org.apache.thrift.protocol.TField STRATEGY_CLASS_FIELD_DESC = new org.apache.thrift.protocol.TField("strategy_class", org.apache.thrift.protocol.TType.STRING, (short)2);
   private static final org.apache.thrift.protocol.TField STRATEGY_OPTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("strategy_options", org.apache.thrift.protocol.TType.MAP, (short)3);
-  private static final org.apache.thrift.protocol.TField REPLICATION_FACTOR_FIELD_DESC = new org.apache.thrift.protocol.TField("replication_factor", org.apache.thrift.protocol.TType.I32, (short)4);
   private static final org.apache.thrift.protocol.TField CF_DEFS_FIELD_DESC = new org.apache.thrift.protocol.TField("cf_defs", org.apache.thrift.protocol.TType.LIST, (short)5);
   private static final org.apache.thrift.protocol.TField DURABLE_WRITES_FIELD_DESC = new org.apache.thrift.protocol.TField("durable_writes", org.apache.thrift.protocol.TType.BOOL, (short)6);
 
   public String name; // required
   public String strategy_class; // required
   public Map<String,String> strategy_options; // required
-  /**
-   * @deprecated
-   */
-  public int replication_factor; // required
   public List<CfDef> cf_defs; // required
   public boolean durable_writes; // required
 
@@ -67,10 +62,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
     NAME((short)1, "name"),
     STRATEGY_CLASS((short)2, "strategy_class"),
     STRATEGY_OPTIONS((short)3, "strategy_options"),
-    /**
-     * @deprecated
-     */
-    REPLICATION_FACTOR((short)4, "replication_factor"),
     CF_DEFS((short)5, "cf_defs"),
     DURABLE_WRITES((short)6, "durable_writes");
 
@@ -93,8 +84,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
           return STRATEGY_CLASS;
         case 3: // STRATEGY_OPTIONS
           return STRATEGY_OPTIONS;
-        case 4: // REPLICATION_FACTOR
-          return REPLICATION_FACTOR;
         case 5: // CF_DEFS
           return CF_DEFS;
         case 6: // DURABLE_WRITES
@@ -139,9 +128,8 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
   }
 
   // isset id assignments
-  private static final int __REPLICATION_FACTOR_ISSET_ID = 0;
-  private static final int __DURABLE_WRITES_ISSET_ID = 1;
-  private BitSet __isset_bit_vector = new BitSet(2);
+  private static final int __DURABLE_WRITES_ISSET_ID = 0;
+  private BitSet __isset_bit_vector = new BitSet(1);
 
   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
   static {
@@ -154,8 +142,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
         new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), 
             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
-    tmpMap.put(_Fields.REPLICATION_FACTOR, new org.apache.thrift.meta_data.FieldMetaData("replication_factor", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
     tmpMap.put(_Fields.CF_DEFS, new org.apache.thrift.meta_data.FieldMetaData("cf_defs", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
             new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CfDef.class))));
@@ -208,7 +194,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
       }
       this.strategy_options = __this__strategy_options;
     }
-    this.replication_factor = other.replication_factor;
     if (other.isSetCf_defs()) {
       List<CfDef> __this__cf_defs = new ArrayList<CfDef>();
       for (CfDef other_element : other.cf_defs) {
@@ -228,8 +213,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
     this.name = null;
     this.strategy_class = null;
     this.strategy_options = null;
-    setReplication_factorIsSet(false);
-    this.replication_factor = 0;
     this.cf_defs = null;
     this.durable_writes = true;
 
@@ -318,35 +301,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
     }
   }
 
-  /**
-   * @deprecated
-   */
-  public int getReplication_factor() {
-    return this.replication_factor;
-  }
-
-  /**
-   * @deprecated
-   */
-  public KsDef setReplication_factor(int replication_factor) {
-    this.replication_factor = replication_factor;
-    setReplication_factorIsSet(true);
-    return this;
-  }
-
-  public void unsetReplication_factor() {
-    __isset_bit_vector.clear(__REPLICATION_FACTOR_ISSET_ID);
-  }
-
-  /** Returns true if field replication_factor is set (has been assigned a value) and false otherwise */
-  public boolean isSetReplication_factor() {
-    return __isset_bit_vector.get(__REPLICATION_FACTOR_ISSET_ID);
-  }
-
-  public void setReplication_factorIsSet(boolean value) {
-    __isset_bit_vector.set(__REPLICATION_FACTOR_ISSET_ID, value);
-  }
-
   public int getCf_defsSize() {
     return (this.cf_defs == null) ? 0 : this.cf_defs.size();
   }
@@ -435,14 +389,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
       }
       break;
 
-    case REPLICATION_FACTOR:
-      if (value == null) {
-        unsetReplication_factor();
-      } else {
-        setReplication_factor((Integer)value);
-      }
-      break;
-
     case CF_DEFS:
       if (value == null) {
         unsetCf_defs();
@@ -473,9 +419,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
     case STRATEGY_OPTIONS:
       return getStrategy_options();
 
-    case REPLICATION_FACTOR:
-      return Integer.valueOf(getReplication_factor());
-
     case CF_DEFS:
       return getCf_defs();
 
@@ -499,8 +442,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
       return isSetStrategy_class();
     case STRATEGY_OPTIONS:
       return isSetStrategy_options();
-    case REPLICATION_FACTOR:
-      return isSetReplication_factor();
     case CF_DEFS:
       return isSetCf_defs();
     case DURABLE_WRITES:
@@ -549,15 +490,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
         return false;
     }
 
-    boolean this_present_replication_factor = true && this.isSetReplication_factor();
-    boolean that_present_replication_factor = true && that.isSetReplication_factor();
-    if (this_present_replication_factor || that_present_replication_factor) {
-      if (!(this_present_replication_factor && that_present_replication_factor))
-        return false;
-      if (this.replication_factor != that.replication_factor)
-        return false;
-    }
-
     boolean this_present_cf_defs = true && this.isSetCf_defs();
     boolean that_present_cf_defs = true && that.isSetCf_defs();
     if (this_present_cf_defs || that_present_cf_defs) {
@@ -598,11 +530,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
     if (present_strategy_options)
       builder.append(strategy_options);
 
-    boolean present_replication_factor = true && (isSetReplication_factor());
-    builder.append(present_replication_factor);
-    if (present_replication_factor)
-      builder.append(replication_factor);
-
     boolean present_cf_defs = true && (isSetCf_defs());
     builder.append(present_cf_defs);
     if (present_cf_defs)
@@ -654,16 +581,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
         return lastComparison;
       }
     }
-    lastComparison = Boolean.valueOf(isSetReplication_factor()).compareTo(typedOther.isSetReplication_factor());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetReplication_factor()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.replication_factor, typedOther.replication_factor);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
     lastComparison = Boolean.valueOf(isSetCf_defs()).compareTo(typedOther.isSetCf_defs());
     if (lastComparison != 0) {
       return lastComparison;
@@ -734,14 +651,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 4: // REPLICATION_FACTOR
-          if (field.type == org.apache.thrift.protocol.TType.I32) {
-            this.replication_factor = iprot.readI32();
-            setReplication_factorIsSet(true);
-          } else { 
-            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
-          }
-          break;
         case 5: // CF_DEFS
           if (field.type == org.apache.thrift.protocol.TType.LIST) {
             {
@@ -808,11 +717,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
         oprot.writeFieldEnd();
       }
     }
-    if (isSetReplication_factor()) {
-      oprot.writeFieldBegin(REPLICATION_FACTOR_FIELD_DESC);
-      oprot.writeI32(this.replication_factor);
-      oprot.writeFieldEnd();
-    }
     if (this.cf_defs != null) {
       oprot.writeFieldBegin(CF_DEFS_FIELD_DESC);
       {
@@ -864,12 +768,6 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
       }
       first = false;
     }
-    if (isSetReplication_factor()) {
-      if (!first) sb.append(", ");
-      sb.append("replication_factor:");
-      sb.append(this.replication_factor);
-      first = false;
-    }
     if (!first) sb.append(", ");
     sb.append("cf_defs:");
     if (this.cf_defs == null) {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0ec9e4e/src/java/org/apache/cassandra/cli/CliClient.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cli/CliClient.java b/src/java/org/apache/cassandra/cli/CliClient.java
index 5bd4487..4ffa3e9 100644
--- a/src/java/org/apache/cassandra/cli/CliClient.java
+++ b/src/java/org/apache/cassandra/cli/CliClient.java
@@ -1113,9 +1113,6 @@ public class CliClient
     private KsDef updateKsDefAttributes(Tree statement, KsDef ksDefToUpdate)
     {
         KsDef ksDef = new KsDef(ksDefToUpdate);
-        // server helpfully sets deprecated replication factor when it sends a KsDef back, for older clients.
-        // we need to unset that on the new KsDef we create to avoid being treated as a legacy client in return.
-        ksDef.unsetReplication_factor();
 
         // removing all column definitions - thrift system_update_keyspace method requires that 
         ksDef.setCf_defs(new LinkedList<CfDef>());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0ec9e4e/src/java/org/apache/cassandra/config/KSMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/KSMetaData.java b/src/java/org/apache/cassandra/config/KSMetaData.java
index 728b9f9..48cb589 100644
--- a/src/java/org/apache/cassandra/config/KSMetaData.java
+++ b/src/java/org/apache/cassandra/config/KSMetaData.java
@@ -88,23 +88,6 @@ public final class KSMetaData
         return new KSMetaData(name, strategyClass, strategyOptions, false, Arrays.asList(cfDefs));
     }
 
-    public static Map<String, String> forwardsCompatibleOptions(KsDef ks_def)
-    {
-        Map<String, String> options;
-        options = ks_def.strategy_options == null
-                ? new HashMap<String, String>()
-                : new HashMap<String, String>(ks_def.strategy_options);
-        maybeAddReplicationFactor(options, ks_def.strategy_class, ks_def.isSetReplication_factor() ? ks_def.replication_factor : null);
-        return options;
-    }
-
-    // TODO remove this for 1.0
-    private static void maybeAddReplicationFactor(Map<String, String> options, String cls, Integer rf)
-    {
-        if (rf != null && (cls.endsWith("SimpleStrategy") || cls.endsWith("OldNetworkTopologyStrategy")))
-            options.put("replication_factor", rf.toString());
-    }
-
     public int hashCode()
     {
         return name.hashCode();
@@ -172,7 +155,6 @@ public final class KSMetaData
                 strategyOptions.put(name, e.getValue().toString());
             }
         }
-        maybeAddReplicationFactor(strategyOptions, ks.strategy_class.toString(), ks.replication_factor);
 
         int cfsz = ks.cf_defs.size();
         List<CFMetaData> cfMetaData = new ArrayList<CFMetaData>(cfsz);
@@ -200,7 +182,7 @@ public final class KSMetaData
     {
         return new KSMetaData(ksd.name,
                               AbstractReplicationStrategy.getClass(ksd.strategy_class),
-                              forwardsCompatibleOptions(ksd),
+                              ksd.strategy_options == null ? Collections.<String, String>emptyMap() : ksd.strategy_options,
                               ksd.durable_writes,
                               Arrays.asList(cfDefs));
     }
@@ -212,8 +194,6 @@ public final class KSMetaData
             cfDefs.add(cfm.toThrift());
         KsDef ksdef = new KsDef(name, strategyClass.getName(), cfDefs);
         ksdef.setStrategy_options(strategyOptions);
-        if (strategyOptions != null && strategyOptions.containsKey("replication_factor"))
-            ksdef.setReplication_factor(Integer.parseInt(strategyOptions.get("replication_factor")));
         ksdef.setDurable_writes(durableWrites);
 
         return ksdef;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0ec9e4e/src/java/org/apache/cassandra/thrift/ThriftValidation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftValidation.java b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
index a4e32b1..e996ce3 100644
--- a/src/java/org/apache/cassandra/thrift/ThriftValidation.java
+++ b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
@@ -722,7 +722,7 @@ public class ThriftValidation
 
         // Attempt to instantiate the ARS, which will throw a ConfigException if
         //  the strategy_options aren't fully formed or if the ARS Classname is invalid.
-        Map<String, String> options = KSMetaData.forwardsCompatibleOptions(ks_def);
+        Map<String, String> options = ks_def.strategy_options == null ? Collections.<String, String>emptyMap() : ks_def.strategy_options;
         TokenMetadata tmd = StorageService.instance.getTokenMetadata();
         IEndpointSnitch eps = DatabaseDescriptor.getEndpointSnitch();
         Class<? extends AbstractReplicationStrategy> cls = AbstractReplicationStrategy.getClass(ks_def.strategy_class);