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 2011/04/18 17:51:47 UTC
svn commit: r1094628 - in /cassandra/branches/cassandra-0.8:
drivers/py/cql/cassandra/ drivers/txpy/txcql/cassandra/ interface/
interface/thrift/gen-java/org/apache/cassandra/thrift/
src/java/org/apache/cassandra/config/ src/java/org/apache/cassandra/t...
Author: jbellis
Date: Mon Apr 18 15:51:47 2011
New Revision: 1094628
URL: http://svn.apache.org/viewvc?rev=1094628&view=rev
Log:
add optional replication_factor fields to KsDef to make supporting both 0.8 and 0.7 easier for client devs
patch by jbellis; reviewed by Nate McCall for CASSANDRA-2481
Modified:
cassandra/branches/cassandra-0.8/drivers/py/cql/cassandra/constants.py
cassandra/branches/cassandra-0.8/drivers/py/cql/cassandra/ttypes.py
cassandra/branches/cassandra-0.8/drivers/txpy/txcql/cassandra/constants.py
cassandra/branches/cassandra-0.8/drivers/txpy/txcql/cassandra/ttypes.py
cassandra/branches/cassandra-0.8/interface/cassandra.thrift
cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/KSMetaData.java
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/CassandraServer.java
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java
cassandra/branches/cassandra-0.8/test/system/__init__.py
cassandra/branches/cassandra-0.8/test/system/test_thrift_server.py
Modified: cassandra/branches/cassandra-0.8/drivers/py/cql/cassandra/constants.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/drivers/py/cql/cassandra/constants.py?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/drivers/py/cql/cassandra/constants.py (original)
+++ cassandra/branches/cassandra-0.8/drivers/py/cql/cassandra/constants.py Mon Apr 18 15:51:47 2011
@@ -7,4 +7,4 @@
from thrift.Thrift import *
from ttypes import *
-VERSION = "20.1.0"
+VERSION = "19.10.0"
Modified: cassandra/branches/cassandra-0.8/drivers/py/cql/cassandra/ttypes.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/drivers/py/cql/cassandra/ttypes.py?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/drivers/py/cql/cassandra/ttypes.py (original)
+++ cassandra/branches/cassandra-0.8/drivers/py/cql/cassandra/ttypes.py Mon Apr 18 15:51:47 2011
@@ -246,10 +246,6 @@ class Column:
def validate(self):
if self.name is None:
raise TProtocol.TProtocolException(message='Required field name is unset!')
- if self.value is None:
- raise TProtocol.TProtocolException(message='Required field value is unset!')
- if self.timestamp is None:
- raise TProtocol.TProtocolException(message='Required field timestamp is unset!')
return
@@ -2666,6 +2662,7 @@ class KsDef:
- name
- strategy_class
- strategy_options
+ - replication_factor: deprecated
- cf_defs
"""
@@ -2674,13 +2671,15 @@ class KsDef:
(1, TType.STRING, 'name', None, None, ), # 1
(2, TType.STRING, 'strategy_class', None, None, ), # 2
(3, TType.MAP, 'strategy_options', (TType.STRING,None,TType.STRING,None), None, ), # 3
- (4, TType.LIST, 'cf_defs', (TType.STRUCT,(CfDef, CfDef.thrift_spec)), None, ), # 4
+ (4, TType.I32, 'replication_factor', None, None, ), # 4
+ (5, TType.LIST, 'cf_defs', (TType.STRUCT,(CfDef, CfDef.thrift_spec)), None, ), # 5
)
- def __init__(self, name=None, strategy_class=None, strategy_options=None, cf_defs=None,):
+ def __init__(self, name=None, strategy_class=None, strategy_options=None, replication_factor=None, cf_defs=None,):
self.name = name
self.strategy_class = strategy_class
self.strategy_options = strategy_options
+ self.replication_factor = replication_factor
self.cf_defs = cf_defs
def read(self, iprot):
@@ -2714,6 +2713,11 @@ class KsDef:
else:
iprot.skip(ftype)
elif fid == 4:
+ if ftype == TType.I32:
+ self.replication_factor = iprot.readI32();
+ else:
+ iprot.skip(ftype)
+ elif fid == 5:
if ftype == TType.LIST:
self.cf_defs = []
(_etype68, _size65) = iprot.readListBegin()
@@ -2750,8 +2754,12 @@ class KsDef:
oprot.writeString(viter72)
oprot.writeMapEnd()
oprot.writeFieldEnd()
+ if self.replication_factor != None:
+ oprot.writeFieldBegin('replication_factor', TType.I32, 4)
+ oprot.writeI32(self.replication_factor)
+ oprot.writeFieldEnd()
if self.cf_defs != None:
- oprot.writeFieldBegin('cf_defs', TType.LIST, 4)
+ oprot.writeFieldBegin('cf_defs', TType.LIST, 5)
oprot.writeListBegin(TType.STRUCT, len(self.cf_defs))
for iter73 in self.cf_defs:
iter73.write(oprot)
Modified: cassandra/branches/cassandra-0.8/drivers/txpy/txcql/cassandra/constants.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/drivers/txpy/txcql/cassandra/constants.py?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/drivers/txpy/txcql/cassandra/constants.py (original)
+++ cassandra/branches/cassandra-0.8/drivers/txpy/txcql/cassandra/constants.py Mon Apr 18 15:51:47 2011
@@ -7,4 +7,4 @@
from thrift.Thrift import *
from ttypes import *
-VERSION = "20.1.0"
+VERSION = "19.10.0"
Modified: cassandra/branches/cassandra-0.8/drivers/txpy/txcql/cassandra/ttypes.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/drivers/txpy/txcql/cassandra/ttypes.py?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/drivers/txpy/txcql/cassandra/ttypes.py (original)
+++ cassandra/branches/cassandra-0.8/drivers/txpy/txcql/cassandra/ttypes.py Mon Apr 18 15:51:47 2011
@@ -246,10 +246,6 @@ class Column:
def validate(self):
if self.name is None:
raise TProtocol.TProtocolException(message='Required field name is unset!')
- if self.value is None:
- raise TProtocol.TProtocolException(message='Required field value is unset!')
- if self.timestamp is None:
- raise TProtocol.TProtocolException(message='Required field timestamp is unset!')
return
@@ -2666,6 +2662,7 @@ class KsDef:
- name
- strategy_class
- strategy_options
+ - replication_factor: deprecated
- cf_defs
"""
@@ -2674,13 +2671,15 @@ class KsDef:
(1, TType.STRING, 'name', None, None, ), # 1
(2, TType.STRING, 'strategy_class', None, None, ), # 2
(3, TType.MAP, 'strategy_options', (TType.STRING,None,TType.STRING,None), None, ), # 3
- (4, TType.LIST, 'cf_defs', (TType.STRUCT,(CfDef, CfDef.thrift_spec)), None, ), # 4
+ (4, TType.I32, 'replication_factor', None, None, ), # 4
+ (5, TType.LIST, 'cf_defs', (TType.STRUCT,(CfDef, CfDef.thrift_spec)), None, ), # 5
)
- def __init__(self, name=None, strategy_class=None, strategy_options=None, cf_defs=None,):
+ def __init__(self, name=None, strategy_class=None, strategy_options=None, replication_factor=None, cf_defs=None,):
self.name = name
self.strategy_class = strategy_class
self.strategy_options = strategy_options
+ self.replication_factor = replication_factor
self.cf_defs = cf_defs
def read(self, iprot):
@@ -2714,6 +2713,11 @@ class KsDef:
else:
iprot.skip(ftype)
elif fid == 4:
+ if ftype == TType.I32:
+ self.replication_factor = iprot.readI32();
+ else:
+ iprot.skip(ftype)
+ elif fid == 5:
if ftype == TType.LIST:
self.cf_defs = []
(_etype68, _size65) = iprot.readListBegin()
@@ -2750,8 +2754,12 @@ class KsDef:
oprot.writeString(viter72)
oprot.writeMapEnd()
oprot.writeFieldEnd()
+ if self.replication_factor != None:
+ oprot.writeFieldBegin('replication_factor', TType.I32, 4)
+ oprot.writeI32(self.replication_factor)
+ oprot.writeFieldEnd()
if self.cf_defs != None:
- oprot.writeFieldBegin('cf_defs', TType.LIST, 4)
+ oprot.writeFieldBegin('cf_defs', TType.LIST, 5)
oprot.writeListBegin(TType.STRUCT, len(self.cf_defs))
for iter73 in self.cf_defs:
iter73.write(oprot)
Modified: cassandra/branches/cassandra-0.8/interface/cassandra.thrift
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/interface/cassandra.thrift?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/interface/cassandra.thrift (original)
+++ cassandra/branches/cassandra-0.8/interface/cassandra.thrift Mon Apr 18 15:51:47 2011
@@ -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 = "20.2.0"
+const string VERSION = "19.10.0"
#
@@ -402,7 +402,11 @@ struct KsDef {
1: required string name,
2: required string strategy_class,
3: optional map<string,string> strategy_options,
- 4: required list<CfDef> cf_defs,
+
+ /** @deprecated */
+ 4: optional i32 replication_factor,
+
+ 5: required list<CfDef> cf_defs,
}
/** CQL query compression */
Modified: cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java (original)
+++ cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java Mon Apr 18 15:51:47 2011
@@ -44,6 +44,6 @@ import org.slf4j.LoggerFactory;
public class Constants {
- public static final String VERSION = "20.2.0";
+ public static final String VERSION = "19.10.0";
}
Modified: cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java (original)
+++ cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java Mon Apr 18 15:51:47 2011
@@ -48,11 +48,16 @@ public class KsDef implements org.apache
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 CF_DEFS_FIELD_DESC = new org.apache.thrift.protocol.TField("cf_defs", org.apache.thrift.protocol.TType.LIST, (short)4);
+ 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);
public String name;
public String strategy_class;
public Map<String,String> strategy_options;
+ /**
+ * @deprecated
+ */
+ public int replication_factor;
public List<CfDef> cf_defs;
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
@@ -60,7 +65,11 @@ public class KsDef implements org.apache
NAME((short)1, "name"),
STRATEGY_CLASS((short)2, "strategy_class"),
STRATEGY_OPTIONS((short)3, "strategy_options"),
- CF_DEFS((short)4, "cf_defs");
+ /**
+ * @deprecated
+ */
+ REPLICATION_FACTOR((short)4, "replication_factor"),
+ CF_DEFS((short)5, "cf_defs");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@@ -81,7 +90,9 @@ public class KsDef implements org.apache
return STRATEGY_CLASS;
case 3: // STRATEGY_OPTIONS
return STRATEGY_OPTIONS;
- case 4: // CF_DEFS
+ case 4: // REPLICATION_FACTOR
+ return REPLICATION_FACTOR;
+ case 5: // CF_DEFS
return CF_DEFS;
default:
return null;
@@ -123,6 +134,8 @@ public class KsDef implements org.apache
}
// isset id assignments
+ private static final int __REPLICATION_FACTOR_ISSET_ID = 0;
+ private BitSet __isset_bit_vector = new BitSet(1);
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
@@ -135,6 +148,8 @@ public class KsDef implements org.apache
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))));
@@ -160,6 +175,8 @@ public class KsDef implements org.apache
* Performs a deep copy on <i>other</i>.
*/
public KsDef(KsDef other) {
+ __isset_bit_vector.clear();
+ __isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetName()) {
this.name = other.name;
}
@@ -181,6 +198,7 @@ public class KsDef implements org.apache
}
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) {
@@ -199,6 +217,8 @@ public class KsDef implements org.apache
this.name = null;
this.strategy_class = null;
this.strategy_options = null;
+ setReplication_factorIsSet(false);
+ this.replication_factor = 0;
this.cf_defs = null;
}
@@ -285,6 +305,35 @@ public class KsDef implements org.apache
}
}
+ /**
+ * @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();
}
@@ -350,6 +399,14 @@ public class KsDef implements org.apache
}
break;
+ case REPLICATION_FACTOR:
+ if (value == null) {
+ unsetReplication_factor();
+ } else {
+ setReplication_factor((Integer)value);
+ }
+ break;
+
case CF_DEFS:
if (value == null) {
unsetCf_defs();
@@ -372,6 +429,9 @@ public class KsDef implements org.apache
case STRATEGY_OPTIONS:
return getStrategy_options();
+ case REPLICATION_FACTOR:
+ return new Integer(getReplication_factor());
+
case CF_DEFS:
return getCf_defs();
@@ -392,6 +452,8 @@ public class KsDef implements org.apache
return isSetStrategy_class();
case STRATEGY_OPTIONS:
return isSetStrategy_options();
+ case REPLICATION_FACTOR:
+ return isSetReplication_factor();
case CF_DEFS:
return isSetCf_defs();
}
@@ -438,6 +500,15 @@ public class KsDef implements org.apache
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) {
@@ -469,6 +540,11 @@ public class KsDef implements org.apache
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)
@@ -515,6 +591,16 @@ public class KsDef implements org.apache
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;
@@ -575,7 +661,15 @@ public class KsDef implements org.apache
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
- case 4: // CF_DEFS
+ 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) {
{
org.apache.thrift.protocol.TList _list37 = iprot.readListBegin();
@@ -633,6 +727,11 @@ public class KsDef implements org.apache
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);
{
@@ -679,6 +778,12 @@ public class KsDef implements org.apache
}
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) {
@@ -714,6 +819,8 @@ public class KsDef implements org.apache
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);
Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/KSMetaData.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/KSMetaData.java?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/KSMetaData.java (original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/KSMetaData.java Mon Apr 18 15:51:47 2011
@@ -29,6 +29,8 @@ import org.apache.avro.util.Utf8;
import org.apache.cassandra.io.SerDeUtils;
import org.apache.cassandra.locator.AbstractReplicationStrategy;
import org.apache.cassandra.locator.NetworkTopologyStrategy;
+import org.apache.cassandra.thrift.KsDef;
+
import org.apache.commons.lang.StringUtils;
public final class KSMetaData
@@ -48,7 +50,22 @@ public final class KSMetaData
cfmap.put(cfm.cfName, cfm);
this.cfMetaData = Collections.unmodifiableMap(cfmap);
}
-
+
+ public static Map<String, String> backwardsCompatibleOptions(KsDef ks_def)
+ {
+ Map<String, String> options;
+ if (ks_def.isSetReplication_factor())
+ {
+ options = new HashMap<String, String>(ks_def.strategy_options == null ? Collections.<String, String>emptyMap() : ks_def.strategy_options);
+ options.put("replication_factor", String.valueOf(ks_def.replication_factor));
+ }
+ else
+ {
+ options = ks_def.strategy_options;
+ }
+ return options;
+ }
+
public int hashCode()
{
return name.hashCode();
Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/CassandraServer.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/CassandraServer.java?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/CassandraServer.java (original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/CassandraServer.java Mon Apr 18 15:51:47 2011
@@ -24,7 +24,6 @@ import java.io.UnsupportedEncodingExcept
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.util.*;
-import java.util.Map.Entry;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@@ -55,7 +54,6 @@ import org.apache.cassandra.service.Clie
import org.apache.cassandra.service.StorageProxy;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
import org.apache.thrift.TException;
public class CassandraServer implements Cassandra.Iface
@@ -858,21 +856,10 @@ public class CassandraServer implements
cfDefs.add(CFMetaData.convertToCFMetaData(cfDef));
}
- // 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.
- TokenMetadata tmd = StorageService.instance.getTokenMetadata();
- IEndpointSnitch eps = DatabaseDescriptor.getEndpointSnitch();
- Class<? extends AbstractReplicationStrategy> cls = AbstractReplicationStrategy.getClass(ks_def.strategy_class);
- AbstractReplicationStrategy strat = AbstractReplicationStrategy
- .createReplicationStrategy(ks_def.name,
- cls,
- tmd,
- eps,
- ks_def.strategy_options);
-
+ ThriftValidation.validateKsDef(ks_def);
KSMetaData ksm = new KSMetaData(ks_def.name,
AbstractReplicationStrategy.getClass(ks_def.strategy_class),
- ks_def.strategy_options,
+ KSMetaData.backwardsCompatibleOptions(ks_def),
cfDefs.toArray(new CFMetaData[cfDefs.size()]));
applyMigrationOnStage(new AddKeyspace(ksm));
@@ -891,7 +878,7 @@ public class CassandraServer implements
throw ex;
}
}
-
+
public synchronized String system_drop_keyspace(String keyspace)
throws InvalidRequestException, SchemaDisagreementException, TException
{
@@ -932,9 +919,10 @@ public class CassandraServer implements
try
{
+ ThriftValidation.validateKsDef(ks_def);
KSMetaData ksm = new KSMetaData(ks_def.name,
AbstractReplicationStrategy.getClass(ks_def.strategy_class),
- ks_def.strategy_options);
+ KSMetaData.backwardsCompatibleOptions(ks_def));
applyMigrationOnStage(new UpdateKeyspace(ksm));
return DatabaseDescriptor.getDefsVersion().toString();
}
Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java (original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java Mon Apr 18 15:51:47 2011
@@ -23,16 +23,16 @@ package org.apache.cassandra.thrift;
import java.nio.ByteBuffer;
import java.util.*;
-import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.ConfigurationException;
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.config.ColumnDefinition;
+import org.apache.cassandra.config.*;
import org.apache.cassandra.db.*;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.MarshalException;
import org.apache.cassandra.dht.IPartitioner;
import org.apache.cassandra.dht.RandomPartitioner;
import org.apache.cassandra.dht.Token;
+import org.apache.cassandra.locator.AbstractReplicationStrategy;
+import org.apache.cassandra.locator.IEndpointSnitch;
+import org.apache.cassandra.locator.TokenMetadata;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.FBUtilities;
@@ -554,4 +554,15 @@ public class ThriftValidation
throw new InvalidRequestException("cannot achieve CL > CL.ONE without replicate_on_write on columnfamily " + metadata.cfName);
}
}
+
+ static void validateKsDef(KsDef ks_def) throws ConfigurationException
+ {
+ // 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.backwardsCompatibleOptions(ks_def);
+ TokenMetadata tmd = StorageService.instance.getTokenMetadata();
+ IEndpointSnitch eps = DatabaseDescriptor.getEndpointSnitch();
+ Class<? extends AbstractReplicationStrategy> cls = AbstractReplicationStrategy.getClass(ks_def.strategy_class);
+ AbstractReplicationStrategy.createReplicationStrategy(ks_def.name, cls, tmd, eps, options);
+ }
}
Modified: cassandra/branches/cassandra-0.8/test/system/__init__.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/test/system/__init__.py?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/test/system/__init__.py (original)
+++ cassandra/branches/cassandra-0.8/test/system/__init__.py Mon Apr 18 15:51:47 2011
@@ -33,7 +33,7 @@ import Cassandra
def get_thrift_client(host='127.0.0.1', port=9170):
socket = TSocket.TSocket(host, port)
transport = TTransport.TFramedTransport(socket)
- protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport)
+ protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Cassandra.Client(protocol)
client.transport = transport
return client
@@ -149,7 +149,7 @@ class ThriftTester(BaseTester):
def define_schema(self):
keyspace1 = Cassandra.KsDef('Keyspace1', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'},
- [
+ cf_defs=[
Cassandra.CfDef('Keyspace1', 'Standard1'),
Cassandra.CfDef('Keyspace1', 'Standard2'),
Cassandra.CfDef('Keyspace1', 'StandardLong1', comparator_type='LongType'),
@@ -168,7 +168,7 @@ class ThriftTester(BaseTester):
])
keyspace2 = Cassandra.KsDef('Keyspace2', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'},
- [
+ cf_defs=[
Cassandra.CfDef('Keyspace2', 'Standard1'),
Cassandra.CfDef('Keyspace2', 'Standard3'),
Cassandra.CfDef('Keyspace2', 'Super3', column_type='Super', subcomparator_type='BytesType'),
Modified: cassandra/branches/cassandra-0.8/test/system/test_thrift_server.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/test/system/test_thrift_server.py?rev=1094628&r1=1094627&r2=1094628&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/test/system/test_thrift_server.py (original)
+++ cassandra/branches/cassandra-0.8/test/system/test_thrift_server.py Mon Apr 18 15:51:47 2011
@@ -1192,20 +1192,20 @@ class TestMutations(ThriftTester):
def test_invalid_ks_names(self):
def invalid_keyspace():
- client.system_add_keyspace(KsDef('in-valid', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, []))
+ client.system_add_keyspace(KsDef('in-valid', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, cf_defs=[]))
_expect_exception(invalid_keyspace, InvalidRequestException)
def test_invalid_strategy_class(self):
def add_invalid_keyspace():
- client.system_add_keyspace(KsDef('ValidKs', 'InvalidStrategyClass', {}, []))
+ client.system_add_keyspace(KsDef('ValidKs', 'InvalidStrategyClass', {}, cf_defs=[]))
exc = _expect_exception(add_invalid_keyspace, InvalidRequestException)
s = str(exc)
assert s.find("InvalidStrategyClass") > -1, s
assert s.find("Unable to find replication strategy") > -1, s
def update_invalid_keyspace():
- client.system_add_keyspace(KsDef('ValidKsForUpdate', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, []))
- client.system_update_keyspace(KsDef('ValidKsForUpdate', 'InvalidStrategyClass', {}, []))
+ client.system_add_keyspace(KsDef('ValidKsForUpdate', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, cf_defs=[]))
+ client.system_update_keyspace(KsDef('ValidKsForUpdate', 'InvalidStrategyClass', {}, cf_defs=[]))
exc = _expect_exception(update_invalid_keyspace, InvalidRequestException)
s = str(exc)
@@ -1222,7 +1222,7 @@ class TestMutations(ThriftTester):
def invalid_cf_inside_new_ks():
cf = CfDef('ValidKsName_invalid_cf', 'in-valid')
_set_keyspace('system')
- client.system_add_keyspace(KsDef('ValidKsName_invalid_cf', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor': '1'}, [cf]))
+ client.system_add_keyspace(KsDef('ValidKsName_invalid_cf', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor': '1'}, cf_defs=[cf]))
_expect_exception(invalid_cf_inside_new_ks, InvalidRequestException)
def test_system_cf_recreate(self):
@@ -1234,7 +1234,7 @@ class TestMutations(ThriftTester):
# create
newcf = CfDef(keyspace, cf_name)
- newks = KsDef(keyspace, 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, [newcf])
+ newks = KsDef(keyspace, 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, cf_defs=[newcf])
client.system_add_keyspace(newks)
_set_keyspace(keyspace)
@@ -1261,7 +1261,7 @@ class TestMutations(ThriftTester):
keyspace = KsDef('CreateKeyspace',
'org.apache.cassandra.locator.SimpleStrategy',
{'replication_factor': '10'},
- [CfDef('CreateKeyspace', 'CreateKsCf')])
+ cf_defs=[CfDef('CreateKeyspace', 'CreateKsCf')])
client.system_add_keyspace(keyspace)
newks = client.describe_keyspace('CreateKeyspace')
assert 'CreateKsCf' in [x.name for x in newks.cf_defs]
@@ -1272,7 +1272,7 @@ class TestMutations(ThriftTester):
modified_keyspace = KsDef('CreateKeyspace',
'org.apache.cassandra.locator.OldNetworkTopologyStrategy',
{'replication_factor': '1'},
- [])
+ cf_defs=[])
client.system_update_keyspace(modified_keyspace)
modks = client.describe_keyspace('CreateKeyspace')
assert modks.strategy_class == modified_keyspace.strategy_class