fix schema-related trigger issues

patch by Aleksey Yeschenko; reviewed by Jonathan Ellis for
CASSANDRA-5774
This commit is contained in:
Aleksey Yeschenko 2013-07-23 01:30:29 +03:00
parent 453b6f56fb
commit a9659774b3
24 changed files with 1607 additions and 1009 deletions

View File

@ -1,5 +1,6 @@
2.0.0-rc1
* fix potential spurious wakeup in AsyncOneResponse (CASSANDRA-5690)
* fix schema-related trigger issues (CASSANDRA-5774)
2.0.0-beta2

View File

@ -430,6 +430,15 @@ struct ColumnDef {
5: optional map<string,string> index_options
}
/**
Describes a trigger.
`options` should include at least 'class' param.
Other options are not supported yet.
*/
struct TriggerDef {
1: required string name,
2: required map<string,string> options
}
/* describes a column family. */
struct CfDef {
@ -460,7 +469,7 @@ struct CfDef {
40: optional i32 default_time_to_live,
41: optional i32 index_interval,
42: optional string speculative_retry="NONE",
43: optional map<string, map<string, string>> triggers,
43: optional list<TriggerDef> triggers,
/* All of the following are now ignored and unsupplied. */

View File

@ -383,7 +383,7 @@ public class AuthenticationRequest implements org.apache.thrift.TBase<Authentica
struct.credentials = new HashMap<String,String>(2*_map80.size);
for (int _i81 = 0; _i81 < _map80.size; ++_i81)
{
String _key82; // required
String _key82; // optional
String _val83; // required
_key82 = iprot.readString();
_val83 = iprot.readString();
@ -459,7 +459,7 @@ public class AuthenticationRequest implements org.apache.thrift.TBase<Authentica
struct.credentials = new HashMap<String,String>(2*_map86.size);
for (int _i87 = 0; _i87 < _map86.size; ++_i87)
{
String _key88; // required
String _key88; // optional
String _val89; // required
_key88 = iprot.readString();
_val89 = iprot.readString();

View File

@ -82,7 +82,7 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
private static final org.apache.thrift.protocol.TField DEFAULT_TIME_TO_LIVE_FIELD_DESC = new org.apache.thrift.protocol.TField("default_time_to_live", org.apache.thrift.protocol.TType.I32, (short)40);
private static final org.apache.thrift.protocol.TField INDEX_INTERVAL_FIELD_DESC = new org.apache.thrift.protocol.TField("index_interval", org.apache.thrift.protocol.TType.I32, (short)41);
private static final org.apache.thrift.protocol.TField SPECULATIVE_RETRY_FIELD_DESC = new org.apache.thrift.protocol.TField("speculative_retry", org.apache.thrift.protocol.TType.STRING, (short)42);
private static final org.apache.thrift.protocol.TField TRIGGERS_FIELD_DESC = new org.apache.thrift.protocol.TField("triggers", org.apache.thrift.protocol.TType.MAP, (short)43);
private static final org.apache.thrift.protocol.TField TRIGGERS_FIELD_DESC = new org.apache.thrift.protocol.TField("triggers", org.apache.thrift.protocol.TType.LIST, (short)43);
private static final org.apache.thrift.protocol.TField ROW_CACHE_SIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("row_cache_size", org.apache.thrift.protocol.TType.DOUBLE, (short)9);
private static final org.apache.thrift.protocol.TField KEY_CACHE_SIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("key_cache_size", org.apache.thrift.protocol.TType.DOUBLE, (short)11);
private static final org.apache.thrift.protocol.TField ROW_CACHE_SAVE_PERIOD_IN_SECONDS_FIELD_DESC = new org.apache.thrift.protocol.TField("row_cache_save_period_in_seconds", org.apache.thrift.protocol.TType.I32, (short)19);
@ -127,7 +127,7 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
public int default_time_to_live; // optional
public int index_interval; // optional
public String speculative_retry; // optional
public Map<String,Map<String,String>> triggers; // optional
public List<TriggerDef> triggers; // optional
/**
* @deprecated
*/
@ -455,11 +455,8 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
tmpMap.put(_Fields.SPECULATIVE_RETRY, new org.apache.thrift.meta_data.FieldMetaData("speculative_retry", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.TRIGGERS, new org.apache.thrift.meta_data.FieldMetaData("triggers", org.apache.thrift.TFieldRequirementType.OPTIONAL,
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.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)))));
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, TriggerDef.class))));
tmpMap.put(_Fields.ROW_CACHE_SIZE, new org.apache.thrift.meta_data.FieldMetaData("row_cache_size", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
tmpMap.put(_Fields.KEY_CACHE_SIZE, new org.apache.thrift.meta_data.FieldMetaData("key_cache_size", org.apache.thrift.TFieldRequirementType.OPTIONAL,
@ -598,28 +595,9 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
this.speculative_retry = other.speculative_retry;
}
if (other.isSetTriggers()) {
Map<String,Map<String,String>> __this__triggers = new HashMap<String,Map<String,String>>();
for (Map.Entry<String, Map<String,String>> other_element : other.triggers.entrySet()) {
String other_element_key = other_element.getKey();
Map<String,String> other_element_value = other_element.getValue();
String __this__triggers_copy_key = other_element_key;
Map<String,String> __this__triggers_copy_value = new HashMap<String,String>();
for (Map.Entry<String, String> other_element_value_element : other_element_value.entrySet()) {
String other_element_value_element_key = other_element_value_element.getKey();
String other_element_value_element_value = other_element_value_element.getValue();
String __this__triggers_copy_value_copy_key = other_element_value_element_key;
String __this__triggers_copy_value_copy_value = other_element_value_element_value;
__this__triggers_copy_value.put(__this__triggers_copy_value_copy_key, __this__triggers_copy_value_copy_value);
}
__this__triggers.put(__this__triggers_copy_key, __this__triggers_copy_value);
List<TriggerDef> __this__triggers = new ArrayList<TriggerDef>();
for (TriggerDef other_element : other.triggers) {
__this__triggers.add(new TriggerDef(other_element));
}
this.triggers = __this__triggers;
}
@ -1395,18 +1373,22 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
return (this.triggers == null) ? 0 : this.triggers.size();
}
public void putToTriggers(String key, Map<String,String> val) {
if (this.triggers == null) {
this.triggers = new HashMap<String,Map<String,String>>();
}
this.triggers.put(key, val);
public java.util.Iterator<TriggerDef> getTriggersIterator() {
return (this.triggers == null) ? null : this.triggers.iterator();
}
public Map<String,Map<String,String>> getTriggers() {
public void addToTriggers(TriggerDef elem) {
if (this.triggers == null) {
this.triggers = new ArrayList<TriggerDef>();
}
this.triggers.add(elem);
}
public List<TriggerDef> getTriggers() {
return this.triggers;
}
public CfDef setTriggers(Map<String,Map<String,String>> triggers) {
public CfDef setTriggers(List<TriggerDef> triggers) {
this.triggers = triggers;
return this;
}
@ -1939,7 +1921,7 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
if (value == null) {
unsetTriggers();
} else {
setTriggers((Map<String,Map<String,String>>)value);
setTriggers((List<TriggerDef>)value);
}
break;
@ -3597,14 +3579,14 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
case 13: // COLUMN_METADATA
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list100 = iprot.readListBegin();
struct.column_metadata = new ArrayList<ColumnDef>(_list100.size);
for (int _i101 = 0; _i101 < _list100.size; ++_i101)
org.apache.thrift.protocol.TList _list110 = iprot.readListBegin();
struct.column_metadata = new ArrayList<ColumnDef>(_list110.size);
for (int _i111 = 0; _i111 < _list110.size; ++_i111)
{
ColumnDef _elem102; // required
_elem102 = new ColumnDef();
_elem102.read(iprot);
struct.column_metadata.add(_elem102);
ColumnDef _elem112; // required
_elem112 = new ColumnDef();
_elem112.read(iprot);
struct.column_metadata.add(_elem112);
}
iprot.readListEnd();
}
@ -3688,15 +3670,15 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
case 30: // COMPACTION_STRATEGY_OPTIONS
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map103 = iprot.readMapBegin();
struct.compaction_strategy_options = new HashMap<String,String>(2*_map103.size);
for (int _i104 = 0; _i104 < _map103.size; ++_i104)
org.apache.thrift.protocol.TMap _map113 = iprot.readMapBegin();
struct.compaction_strategy_options = new HashMap<String,String>(2*_map113.size);
for (int _i114 = 0; _i114 < _map113.size; ++_i114)
{
String _key105; // required
String _val106; // required
_key105 = iprot.readString();
_val106 = iprot.readString();
struct.compaction_strategy_options.put(_key105, _val106);
String _key115; // optional
String _val116; // required
_key115 = iprot.readString();
_val116 = iprot.readString();
struct.compaction_strategy_options.put(_key115, _val116);
}
iprot.readMapEnd();
}
@ -3708,15 +3690,15 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
case 32: // COMPRESSION_OPTIONS
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map107 = iprot.readMapBegin();
struct.compression_options = new HashMap<String,String>(2*_map107.size);
for (int _i108 = 0; _i108 < _map107.size; ++_i108)
org.apache.thrift.protocol.TMap _map117 = iprot.readMapBegin();
struct.compression_options = new HashMap<String,String>(2*_map117.size);
for (int _i118 = 0; _i118 < _map117.size; ++_i118)
{
String _key109; // required
String _val110; // required
_key109 = iprot.readString();
_val110 = iprot.readString();
struct.compression_options.put(_key109, _val110);
String _key119; // optional
String _val120; // required
_key119 = iprot.readString();
_val120 = iprot.readString();
struct.compression_options.put(_key119, _val120);
}
iprot.readMapEnd();
}
@ -3790,31 +3772,18 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
}
break;
case 43: // TRIGGERS
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TMap _map111 = iprot.readMapBegin();
struct.triggers = new HashMap<String,Map<String,String>>(2*_map111.size);
for (int _i112 = 0; _i112 < _map111.size; ++_i112)
org.apache.thrift.protocol.TList _list121 = iprot.readListBegin();
struct.triggers = new ArrayList<TriggerDef>(_list121.size);
for (int _i122 = 0; _i122 < _list121.size; ++_i122)
{
String _key113; // required
Map<String,String> _val114; // required
_key113 = iprot.readString();
{
org.apache.thrift.protocol.TMap _map115 = iprot.readMapBegin();
_val114 = new HashMap<String,String>(2*_map115.size);
for (int _i116 = 0; _i116 < _map115.size; ++_i116)
{
String _key117; // required
String _val118; // required
_key117 = iprot.readString();
_val118 = iprot.readString();
_val114.put(_key117, _val118);
}
iprot.readMapEnd();
}
struct.triggers.put(_key113, _val114);
TriggerDef _elem123; // required
_elem123 = new TriggerDef();
_elem123.read(iprot);
struct.triggers.add(_elem123);
}
iprot.readMapEnd();
iprot.readListEnd();
}
struct.setTriggersIsSet(true);
} else {
@ -3974,9 +3943,9 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
oprot.writeFieldBegin(COLUMN_METADATA_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.column_metadata.size()));
for (ColumnDef _iter119 : struct.column_metadata)
for (ColumnDef _iter124 : struct.column_metadata)
{
_iter119.write(oprot);
_iter124.write(oprot);
}
oprot.writeListEnd();
}
@ -4078,10 +4047,10 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
oprot.writeFieldBegin(COMPACTION_STRATEGY_OPTIONS_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.compaction_strategy_options.size()));
for (Map.Entry<String, String> _iter120 : struct.compaction_strategy_options.entrySet())
for (Map.Entry<String, String> _iter125 : struct.compaction_strategy_options.entrySet())
{
oprot.writeString(_iter120.getKey());
oprot.writeString(_iter120.getValue());
oprot.writeString(_iter125.getKey());
oprot.writeString(_iter125.getValue());
}
oprot.writeMapEnd();
}
@ -4098,10 +4067,10 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
oprot.writeFieldBegin(COMPRESSION_OPTIONS_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.compression_options.size()));
for (Map.Entry<String, String> _iter121 : struct.compression_options.entrySet())
for (Map.Entry<String, String> _iter126 : struct.compression_options.entrySet())
{
oprot.writeString(_iter121.getKey());
oprot.writeString(_iter121.getValue());
oprot.writeString(_iter126.getKey());
oprot.writeString(_iter126.getValue());
}
oprot.writeMapEnd();
}
@ -4156,21 +4125,12 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
if (struct.isSetTriggers()) {
oprot.writeFieldBegin(TRIGGERS_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.MAP, struct.triggers.size()));
for (Map.Entry<String, Map<String,String>> _iter122 : struct.triggers.entrySet())
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.triggers.size()));
for (TriggerDef _iter127 : struct.triggers)
{
oprot.writeString(_iter122.getKey());
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, _iter122.getValue().size()));
for (Map.Entry<String, String> _iter123 : _iter122.getValue().entrySet())
{
oprot.writeString(_iter123.getKey());
oprot.writeString(_iter123.getValue());
}
oprot.writeMapEnd();
}
_iter127.write(oprot);
}
oprot.writeMapEnd();
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
@ -4322,9 +4282,9 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
if (struct.isSetColumn_metadata()) {
{
oprot.writeI32(struct.column_metadata.size());
for (ColumnDef _iter124 : struct.column_metadata)
for (ColumnDef _iter128 : struct.column_metadata)
{
_iter124.write(oprot);
_iter128.write(oprot);
}
}
}
@ -4358,20 +4318,20 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
if (struct.isSetCompaction_strategy_options()) {
{
oprot.writeI32(struct.compaction_strategy_options.size());
for (Map.Entry<String, String> _iter125 : struct.compaction_strategy_options.entrySet())
for (Map.Entry<String, String> _iter129 : struct.compaction_strategy_options.entrySet())
{
oprot.writeString(_iter125.getKey());
oprot.writeString(_iter125.getValue());
oprot.writeString(_iter129.getKey());
oprot.writeString(_iter129.getValue());
}
}
}
if (struct.isSetCompression_options()) {
{
oprot.writeI32(struct.compression_options.size());
for (Map.Entry<String, String> _iter126 : struct.compression_options.entrySet())
for (Map.Entry<String, String> _iter130 : struct.compression_options.entrySet())
{
oprot.writeString(_iter126.getKey());
oprot.writeString(_iter126.getValue());
oprot.writeString(_iter130.getKey());
oprot.writeString(_iter130.getValue());
}
}
}
@ -4402,17 +4362,9 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
if (struct.isSetTriggers()) {
{
oprot.writeI32(struct.triggers.size());
for (Map.Entry<String, Map<String,String>> _iter127 : struct.triggers.entrySet())
for (TriggerDef _iter131 : struct.triggers)
{
oprot.writeString(_iter127.getKey());
{
oprot.writeI32(_iter127.getValue().size());
for (Map.Entry<String, String> _iter128 : _iter127.getValue().entrySet())
{
oprot.writeString(_iter128.getKey());
oprot.writeString(_iter128.getValue());
}
}
_iter131.write(oprot);
}
}
}
@ -4478,14 +4430,14 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
}
if (incoming.get(5)) {
{
org.apache.thrift.protocol.TList _list129 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.column_metadata = new ArrayList<ColumnDef>(_list129.size);
for (int _i130 = 0; _i130 < _list129.size; ++_i130)
org.apache.thrift.protocol.TList _list132 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.column_metadata = new ArrayList<ColumnDef>(_list132.size);
for (int _i133 = 0; _i133 < _list132.size; ++_i133)
{
ColumnDef _elem131; // required
_elem131 = new ColumnDef();
_elem131.read(iprot);
struct.column_metadata.add(_elem131);
ColumnDef _elem134; // required
_elem134 = new ColumnDef();
_elem134.read(iprot);
struct.column_metadata.add(_elem134);
}
}
struct.setColumn_metadataIsSet(true);
@ -4528,30 +4480,30 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
}
if (incoming.get(15)) {
{
org.apache.thrift.protocol.TMap _map132 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.compaction_strategy_options = new HashMap<String,String>(2*_map132.size);
for (int _i133 = 0; _i133 < _map132.size; ++_i133)
org.apache.thrift.protocol.TMap _map135 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.compaction_strategy_options = new HashMap<String,String>(2*_map135.size);
for (int _i136 = 0; _i136 < _map135.size; ++_i136)
{
String _key134; // required
String _val135; // required
_key134 = iprot.readString();
_val135 = iprot.readString();
struct.compaction_strategy_options.put(_key134, _val135);
String _key137; // optional
String _val138; // required
_key137 = iprot.readString();
_val138 = iprot.readString();
struct.compaction_strategy_options.put(_key137, _val138);
}
}
struct.setCompaction_strategy_optionsIsSet(true);
}
if (incoming.get(16)) {
{
org.apache.thrift.protocol.TMap _map136 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.compression_options = new HashMap<String,String>(2*_map136.size);
for (int _i137 = 0; _i137 < _map136.size; ++_i137)
org.apache.thrift.protocol.TMap _map139 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.compression_options = new HashMap<String,String>(2*_map139.size);
for (int _i140 = 0; _i140 < _map139.size; ++_i140)
{
String _key138; // required
String _val139; // required
_key138 = iprot.readString();
_val139 = iprot.readString();
struct.compression_options.put(_key138, _val139);
String _key141; // optional
String _val142; // required
_key141 = iprot.readString();
_val142 = iprot.readString();
struct.compression_options.put(_key141, _val142);
}
}
struct.setCompression_optionsIsSet(true);
@ -4590,26 +4542,14 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
}
if (incoming.get(25)) {
{
org.apache.thrift.protocol.TMap _map140 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.MAP, iprot.readI32());
struct.triggers = new HashMap<String,Map<String,String>>(2*_map140.size);
for (int _i141 = 0; _i141 < _map140.size; ++_i141)
org.apache.thrift.protocol.TList _list143 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.triggers = new ArrayList<TriggerDef>(_list143.size);
for (int _i144 = 0; _i144 < _list143.size; ++_i144)
{
String _key142; // required
Map<String,String> _val143; // required
_key142 = iprot.readString();
{
org.apache.thrift.protocol.TMap _map144 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
_val143 = new HashMap<String,String>(2*_map144.size);
for (int _i145 = 0; _i145 < _map144.size; ++_i145)
{
String _key146; // required
String _val147; // required
_key146 = iprot.readString();
_val147 = iprot.readString();
_val143.put(_key146, _val147);
}
}
struct.triggers.put(_key142, _val143);
TriggerDef _elem145; // required
_elem145 = new TriggerDef();
_elem145.read(iprot);
struct.triggers.add(_elem145);
}
}
struct.setTriggersIsSet(true);

View File

@ -771,7 +771,7 @@ public class ColumnDef implements org.apache.thrift.TBase<ColumnDef, ColumnDef._
struct.index_options = new HashMap<String,String>(2*_map90.size);
for (int _i91 = 0; _i91 < _map90.size; ++_i91)
{
String _key92; // required
String _key92; // optional
String _val93; // required
_key92 = iprot.readString();
_val93 = iprot.readString();
@ -908,7 +908,7 @@ public class ColumnDef implements org.apache.thrift.TBase<ColumnDef, ColumnDef._
struct.index_options = new HashMap<String,String>(2*_map96.size);
for (int _i97 = 0; _i97 < _map96.size; ++_i97)
{
String _key98; // required
String _key98; // optional
String _val99; // required
_key98 = iprot.readString();
_val99 = iprot.readString();

View File

@ -658,15 +658,15 @@ public class CqlMetadata implements org.apache.thrift.TBase<CqlMetadata, CqlMeta
case 1: // NAME_TYPES
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map174 = iprot.readMapBegin();
struct.name_types = new HashMap<ByteBuffer,String>(2*_map174.size);
for (int _i175 = 0; _i175 < _map174.size; ++_i175)
org.apache.thrift.protocol.TMap _map172 = iprot.readMapBegin();
struct.name_types = new HashMap<ByteBuffer,String>(2*_map172.size);
for (int _i173 = 0; _i173 < _map172.size; ++_i173)
{
ByteBuffer _key176; // required
String _val177; // required
_key176 = iprot.readBinary();
_val177 = iprot.readString();
struct.name_types.put(_key176, _val177);
ByteBuffer _key174; // optional
String _val175; // required
_key174 = iprot.readBinary();
_val175 = iprot.readString();
struct.name_types.put(_key174, _val175);
}
iprot.readMapEnd();
}
@ -678,15 +678,15 @@ public class CqlMetadata implements org.apache.thrift.TBase<CqlMetadata, CqlMeta
case 2: // VALUE_TYPES
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map178 = iprot.readMapBegin();
struct.value_types = new HashMap<ByteBuffer,String>(2*_map178.size);
for (int _i179 = 0; _i179 < _map178.size; ++_i179)
org.apache.thrift.protocol.TMap _map176 = iprot.readMapBegin();
struct.value_types = new HashMap<ByteBuffer,String>(2*_map176.size);
for (int _i177 = 0; _i177 < _map176.size; ++_i177)
{
ByteBuffer _key180; // required
String _val181; // required
_key180 = iprot.readBinary();
_val181 = iprot.readString();
struct.value_types.put(_key180, _val181);
ByteBuffer _key178; // optional
String _val179; // required
_key178 = iprot.readBinary();
_val179 = iprot.readString();
struct.value_types.put(_key178, _val179);
}
iprot.readMapEnd();
}
@ -730,10 +730,10 @@ public class CqlMetadata implements org.apache.thrift.TBase<CqlMetadata, CqlMeta
oprot.writeFieldBegin(NAME_TYPES_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.name_types.size()));
for (Map.Entry<ByteBuffer, String> _iter182 : struct.name_types.entrySet())
for (Map.Entry<ByteBuffer, String> _iter180 : struct.name_types.entrySet())
{
oprot.writeBinary(_iter182.getKey());
oprot.writeString(_iter182.getValue());
oprot.writeBinary(_iter180.getKey());
oprot.writeString(_iter180.getValue());
}
oprot.writeMapEnd();
}
@ -743,10 +743,10 @@ public class CqlMetadata implements org.apache.thrift.TBase<CqlMetadata, CqlMeta
oprot.writeFieldBegin(VALUE_TYPES_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.value_types.size()));
for (Map.Entry<ByteBuffer, String> _iter183 : struct.value_types.entrySet())
for (Map.Entry<ByteBuffer, String> _iter181 : struct.value_types.entrySet())
{
oprot.writeBinary(_iter183.getKey());
oprot.writeString(_iter183.getValue());
oprot.writeBinary(_iter181.getKey());
oprot.writeString(_iter181.getValue());
}
oprot.writeMapEnd();
}
@ -781,18 +781,18 @@ public class CqlMetadata implements org.apache.thrift.TBase<CqlMetadata, CqlMeta
TTupleProtocol oprot = (TTupleProtocol) prot;
{
oprot.writeI32(struct.name_types.size());
for (Map.Entry<ByteBuffer, String> _iter184 : struct.name_types.entrySet())
for (Map.Entry<ByteBuffer, String> _iter182 : struct.name_types.entrySet())
{
oprot.writeBinary(_iter184.getKey());
oprot.writeString(_iter184.getValue());
oprot.writeBinary(_iter182.getKey());
oprot.writeString(_iter182.getValue());
}
}
{
oprot.writeI32(struct.value_types.size());
for (Map.Entry<ByteBuffer, String> _iter185 : struct.value_types.entrySet())
for (Map.Entry<ByteBuffer, String> _iter183 : struct.value_types.entrySet())
{
oprot.writeBinary(_iter185.getKey());
oprot.writeString(_iter185.getValue());
oprot.writeBinary(_iter183.getKey());
oprot.writeString(_iter183.getValue());
}
}
oprot.writeString(struct.default_name_type);
@ -803,28 +803,28 @@ public class CqlMetadata implements org.apache.thrift.TBase<CqlMetadata, CqlMeta
public void read(org.apache.thrift.protocol.TProtocol prot, CqlMetadata struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
{
org.apache.thrift.protocol.TMap _map186 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.name_types = new HashMap<ByteBuffer,String>(2*_map186.size);
for (int _i187 = 0; _i187 < _map186.size; ++_i187)
org.apache.thrift.protocol.TMap _map184 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.name_types = new HashMap<ByteBuffer,String>(2*_map184.size);
for (int _i185 = 0; _i185 < _map184.size; ++_i185)
{
ByteBuffer _key188; // required
String _val189; // required
_key188 = iprot.readBinary();
_val189 = iprot.readString();
struct.name_types.put(_key188, _val189);
ByteBuffer _key186; // optional
String _val187; // required
_key186 = iprot.readBinary();
_val187 = iprot.readString();
struct.name_types.put(_key186, _val187);
}
}
struct.setName_typesIsSet(true);
{
org.apache.thrift.protocol.TMap _map190 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.value_types = new HashMap<ByteBuffer,String>(2*_map190.size);
for (int _i191 = 0; _i191 < _map190.size; ++_i191)
org.apache.thrift.protocol.TMap _map188 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.value_types = new HashMap<ByteBuffer,String>(2*_map188.size);
for (int _i189 = 0; _i189 < _map188.size; ++_i189)
{
ByteBuffer _key192; // required
String _val193; // required
_key192 = iprot.readBinary();
_val193 = iprot.readString();
struct.value_types.put(_key192, _val193);
ByteBuffer _key190; // optional
String _val191; // required
_key190 = iprot.readBinary();
_val191 = iprot.readString();
struct.value_types.put(_key190, _val191);
}
}
struct.setValue_typesIsSet(true);

View File

@ -649,13 +649,13 @@ public class CqlPreparedResult implements org.apache.thrift.TBase<CqlPreparedRes
case 3: // VARIABLE_TYPES
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list202 = iprot.readListBegin();
struct.variable_types = new ArrayList<String>(_list202.size);
for (int _i203 = 0; _i203 < _list202.size; ++_i203)
org.apache.thrift.protocol.TList _list200 = iprot.readListBegin();
struct.variable_types = new ArrayList<String>(_list200.size);
for (int _i201 = 0; _i201 < _list200.size; ++_i201)
{
String _elem204; // required
_elem204 = iprot.readString();
struct.variable_types.add(_elem204);
String _elem202; // required
_elem202 = iprot.readString();
struct.variable_types.add(_elem202);
}
iprot.readListEnd();
}
@ -667,13 +667,13 @@ public class CqlPreparedResult implements org.apache.thrift.TBase<CqlPreparedRes
case 4: // VARIABLE_NAMES
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list205 = iprot.readListBegin();
struct.variable_names = new ArrayList<String>(_list205.size);
for (int _i206 = 0; _i206 < _list205.size; ++_i206)
org.apache.thrift.protocol.TList _list203 = iprot.readListBegin();
struct.variable_names = new ArrayList<String>(_list203.size);
for (int _i204 = 0; _i204 < _list203.size; ++_i204)
{
String _elem207; // required
_elem207 = iprot.readString();
struct.variable_names.add(_elem207);
String _elem205; // required
_elem205 = iprot.readString();
struct.variable_names.add(_elem205);
}
iprot.readListEnd();
}
@ -714,9 +714,9 @@ public class CqlPreparedResult implements org.apache.thrift.TBase<CqlPreparedRes
oprot.writeFieldBegin(VARIABLE_TYPES_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.variable_types.size()));
for (String _iter208 : struct.variable_types)
for (String _iter206 : struct.variable_types)
{
oprot.writeString(_iter208);
oprot.writeString(_iter206);
}
oprot.writeListEnd();
}
@ -728,9 +728,9 @@ public class CqlPreparedResult implements org.apache.thrift.TBase<CqlPreparedRes
oprot.writeFieldBegin(VARIABLE_NAMES_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.variable_names.size()));
for (String _iter209 : struct.variable_names)
for (String _iter207 : struct.variable_names)
{
oprot.writeString(_iter209);
oprot.writeString(_iter207);
}
oprot.writeListEnd();
}
@ -767,18 +767,18 @@ public class CqlPreparedResult implements org.apache.thrift.TBase<CqlPreparedRes
if (struct.isSetVariable_types()) {
{
oprot.writeI32(struct.variable_types.size());
for (String _iter210 : struct.variable_types)
for (String _iter208 : struct.variable_types)
{
oprot.writeString(_iter210);
oprot.writeString(_iter208);
}
}
}
if (struct.isSetVariable_names()) {
{
oprot.writeI32(struct.variable_names.size());
for (String _iter211 : struct.variable_names)
for (String _iter209 : struct.variable_names)
{
oprot.writeString(_iter211);
oprot.writeString(_iter209);
}
}
}
@ -794,26 +794,26 @@ public class CqlPreparedResult implements org.apache.thrift.TBase<CqlPreparedRes
BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
{
org.apache.thrift.protocol.TList _list212 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.variable_types = new ArrayList<String>(_list212.size);
for (int _i213 = 0; _i213 < _list212.size; ++_i213)
org.apache.thrift.protocol.TList _list210 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.variable_types = new ArrayList<String>(_list210.size);
for (int _i211 = 0; _i211 < _list210.size; ++_i211)
{
String _elem214; // required
_elem214 = iprot.readString();
struct.variable_types.add(_elem214);
String _elem212; // required
_elem212 = iprot.readString();
struct.variable_types.add(_elem212);
}
}
struct.setVariable_typesIsSet(true);
}
if (incoming.get(1)) {
{
org.apache.thrift.protocol.TList _list215 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.variable_names = new ArrayList<String>(_list215.size);
for (int _i216 = 0; _i216 < _list215.size; ++_i216)
org.apache.thrift.protocol.TList _list213 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.variable_names = new ArrayList<String>(_list213.size);
for (int _i214 = 0; _i214 < _list213.size; ++_i214)
{
String _elem217; // required
_elem217 = iprot.readString();
struct.variable_names.add(_elem217);
String _elem215; // required
_elem215 = iprot.readString();
struct.variable_names.add(_elem215);
}
}
struct.setVariable_namesIsSet(true);

View File

@ -644,14 +644,14 @@ public class CqlResult implements org.apache.thrift.TBase<CqlResult, CqlResult._
case 2: // ROWS
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list194 = iprot.readListBegin();
struct.rows = new ArrayList<CqlRow>(_list194.size);
for (int _i195 = 0; _i195 < _list194.size; ++_i195)
org.apache.thrift.protocol.TList _list192 = iprot.readListBegin();
struct.rows = new ArrayList<CqlRow>(_list192.size);
for (int _i193 = 0; _i193 < _list192.size; ++_i193)
{
CqlRow _elem196; // required
_elem196 = new CqlRow();
_elem196.read(iprot);
struct.rows.add(_elem196);
CqlRow _elem194; // required
_elem194 = new CqlRow();
_elem194.read(iprot);
struct.rows.add(_elem194);
}
iprot.readListEnd();
}
@ -702,9 +702,9 @@ public class CqlResult implements org.apache.thrift.TBase<CqlResult, CqlResult._
oprot.writeFieldBegin(ROWS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.rows.size()));
for (CqlRow _iter197 : struct.rows)
for (CqlRow _iter195 : struct.rows)
{
_iter197.write(oprot);
_iter195.write(oprot);
}
oprot.writeListEnd();
}
@ -755,9 +755,9 @@ public class CqlResult implements org.apache.thrift.TBase<CqlResult, CqlResult._
if (struct.isSetRows()) {
{
oprot.writeI32(struct.rows.size());
for (CqlRow _iter198 : struct.rows)
for (CqlRow _iter196 : struct.rows)
{
_iter198.write(oprot);
_iter196.write(oprot);
}
}
}
@ -777,14 +777,14 @@ public class CqlResult implements org.apache.thrift.TBase<CqlResult, CqlResult._
BitSet incoming = iprot.readBitSet(3);
if (incoming.get(0)) {
{
org.apache.thrift.protocol.TList _list199 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.rows = new ArrayList<CqlRow>(_list199.size);
for (int _i200 = 0; _i200 < _list199.size; ++_i200)
org.apache.thrift.protocol.TList _list197 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.rows = new ArrayList<CqlRow>(_list197.size);
for (int _i198 = 0; _i198 < _list197.size; ++_i198)
{
CqlRow _elem201; // required
_elem201 = new CqlRow();
_elem201.read(iprot);
struct.rows.add(_elem201);
CqlRow _elem199; // required
_elem199 = new CqlRow();
_elem199.read(iprot);
struct.rows.add(_elem199);
}
}
struct.setRowsIsSet(true);

View File

@ -478,14 +478,14 @@ public class CqlRow implements org.apache.thrift.TBase<CqlRow, CqlRow._Fields>,
case 2: // COLUMNS
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list166 = iprot.readListBegin();
struct.columns = new ArrayList<Column>(_list166.size);
for (int _i167 = 0; _i167 < _list166.size; ++_i167)
org.apache.thrift.protocol.TList _list164 = iprot.readListBegin();
struct.columns = new ArrayList<Column>(_list164.size);
for (int _i165 = 0; _i165 < _list164.size; ++_i165)
{
Column _elem168; // required
_elem168 = new Column();
_elem168.read(iprot);
struct.columns.add(_elem168);
Column _elem166; // required
_elem166 = new Column();
_elem166.read(iprot);
struct.columns.add(_elem166);
}
iprot.readListEnd();
}
@ -518,9 +518,9 @@ public class CqlRow implements org.apache.thrift.TBase<CqlRow, CqlRow._Fields>,
oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.columns.size()));
for (Column _iter169 : struct.columns)
for (Column _iter167 : struct.columns)
{
_iter169.write(oprot);
_iter167.write(oprot);
}
oprot.writeListEnd();
}
@ -546,9 +546,9 @@ public class CqlRow implements org.apache.thrift.TBase<CqlRow, CqlRow._Fields>,
oprot.writeBinary(struct.key);
{
oprot.writeI32(struct.columns.size());
for (Column _iter170 : struct.columns)
for (Column _iter168 : struct.columns)
{
_iter170.write(oprot);
_iter168.write(oprot);
}
}
}
@ -559,14 +559,14 @@ public class CqlRow implements org.apache.thrift.TBase<CqlRow, CqlRow._Fields>,
struct.key = iprot.readBinary();
struct.setKeyIsSet(true);
{
org.apache.thrift.protocol.TList _list171 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.columns = new ArrayList<Column>(_list171.size);
for (int _i172 = 0; _i172 < _list171.size; ++_i172)
org.apache.thrift.protocol.TList _list169 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.columns = new ArrayList<Column>(_list169.size);
for (int _i170 = 0; _i170 < _list169.size; ++_i170)
{
Column _elem173; // required
_elem173 = new Column();
_elem173.read(iprot);
struct.columns.add(_elem173);
Column _elem171; // required
_elem171 = new Column();
_elem171.read(iprot);
struct.columns.add(_elem171);
}
}
struct.setColumnsIsSet(true);

View File

@ -837,15 +837,15 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
case 3: // STRATEGY_OPTIONS
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map148 = iprot.readMapBegin();
struct.strategy_options = new HashMap<String,String>(2*_map148.size);
for (int _i149 = 0; _i149 < _map148.size; ++_i149)
org.apache.thrift.protocol.TMap _map146 = iprot.readMapBegin();
struct.strategy_options = new HashMap<String,String>(2*_map146.size);
for (int _i147 = 0; _i147 < _map146.size; ++_i147)
{
String _key150; // required
String _val151; // required
_key150 = iprot.readString();
_val151 = iprot.readString();
struct.strategy_options.put(_key150, _val151);
String _key148; // optional
String _val149; // required
_key148 = iprot.readString();
_val149 = iprot.readString();
struct.strategy_options.put(_key148, _val149);
}
iprot.readMapEnd();
}
@ -865,14 +865,14 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
case 5: // CF_DEFS
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list152 = iprot.readListBegin();
struct.cf_defs = new ArrayList<CfDef>(_list152.size);
for (int _i153 = 0; _i153 < _list152.size; ++_i153)
org.apache.thrift.protocol.TList _list150 = iprot.readListBegin();
struct.cf_defs = new ArrayList<CfDef>(_list150.size);
for (int _i151 = 0; _i151 < _list150.size; ++_i151)
{
CfDef _elem154; // required
_elem154 = new CfDef();
_elem154.read(iprot);
struct.cf_defs.add(_elem154);
CfDef _elem152; // required
_elem152 = new CfDef();
_elem152.read(iprot);
struct.cf_defs.add(_elem152);
}
iprot.readListEnd();
}
@ -919,10 +919,10 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
oprot.writeFieldBegin(STRATEGY_OPTIONS_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.strategy_options.size()));
for (Map.Entry<String, String> _iter155 : struct.strategy_options.entrySet())
for (Map.Entry<String, String> _iter153 : struct.strategy_options.entrySet())
{
oprot.writeString(_iter155.getKey());
oprot.writeString(_iter155.getValue());
oprot.writeString(_iter153.getKey());
oprot.writeString(_iter153.getValue());
}
oprot.writeMapEnd();
}
@ -938,9 +938,9 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
oprot.writeFieldBegin(CF_DEFS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.cf_defs.size()));
for (CfDef _iter156 : struct.cf_defs)
for (CfDef _iter154 : struct.cf_defs)
{
_iter156.write(oprot);
_iter154.write(oprot);
}
oprot.writeListEnd();
}
@ -972,9 +972,9 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
oprot.writeString(struct.strategy_class);
{
oprot.writeI32(struct.cf_defs.size());
for (CfDef _iter157 : struct.cf_defs)
for (CfDef _iter155 : struct.cf_defs)
{
_iter157.write(oprot);
_iter155.write(oprot);
}
}
BitSet optionals = new BitSet();
@ -991,10 +991,10 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
if (struct.isSetStrategy_options()) {
{
oprot.writeI32(struct.strategy_options.size());
for (Map.Entry<String, String> _iter158 : struct.strategy_options.entrySet())
for (Map.Entry<String, String> _iter156 : struct.strategy_options.entrySet())
{
oprot.writeString(_iter158.getKey());
oprot.writeString(_iter158.getValue());
oprot.writeString(_iter156.getKey());
oprot.writeString(_iter156.getValue());
}
}
}
@ -1014,29 +1014,29 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
struct.strategy_class = iprot.readString();
struct.setStrategy_classIsSet(true);
{
org.apache.thrift.protocol.TList _list159 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.cf_defs = new ArrayList<CfDef>(_list159.size);
for (int _i160 = 0; _i160 < _list159.size; ++_i160)
org.apache.thrift.protocol.TList _list157 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.cf_defs = new ArrayList<CfDef>(_list157.size);
for (int _i158 = 0; _i158 < _list157.size; ++_i158)
{
CfDef _elem161; // required
_elem161 = new CfDef();
_elem161.read(iprot);
struct.cf_defs.add(_elem161);
CfDef _elem159; // required
_elem159 = new CfDef();
_elem159.read(iprot);
struct.cf_defs.add(_elem159);
}
}
struct.setCf_defsIsSet(true);
BitSet incoming = iprot.readBitSet(3);
if (incoming.get(0)) {
{
org.apache.thrift.protocol.TMap _map162 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.strategy_options = new HashMap<String,String>(2*_map162.size);
for (int _i163 = 0; _i163 < _map162.size; ++_i163)
org.apache.thrift.protocol.TMap _map160 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.strategy_options = new HashMap<String,String>(2*_map160.size);
for (int _i161 = 0; _i161 < _map160.size; ++_i161)
{
String _key164; // required
String _val165; // required
_key164 = iprot.readString();
_val165 = iprot.readString();
struct.strategy_options.put(_key164, _val165);
String _key162; // optional
String _val163; // required
_key162 = iprot.readString();
_val163 = iprot.readString();
struct.strategy_options.put(_key162, _val163);
}
}
struct.setStrategy_optionsIsSet(true);

View File

@ -0,0 +1,577 @@
/**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.cassandra.thrift;
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Describes a trigger.
* `options` should include at least 'class' param.
* Other options are not supported yet.
*/
public class TriggerDef implements org.apache.thrift.TBase<TriggerDef, TriggerDef._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TriggerDef");
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 OPTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("options", org.apache.thrift.protocol.TType.MAP, (short)2);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TriggerDefStandardSchemeFactory());
schemes.put(TupleScheme.class, new TriggerDefTupleSchemeFactory());
}
public String name; // required
public Map<String,String> options; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
NAME((short)1, "name"),
OPTIONS((short)2, "options");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // NAME
return NAME;
case 2: // OPTIONS
return OPTIONS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.OPTIONS, new org.apache.thrift.meta_data.FieldMetaData("options", org.apache.thrift.TFieldRequirementType.REQUIRED,
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))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TriggerDef.class, metaDataMap);
}
public TriggerDef() {
}
public TriggerDef(
String name,
Map<String,String> options)
{
this();
this.name = name;
this.options = options;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TriggerDef(TriggerDef other) {
if (other.isSetName()) {
this.name = other.name;
}
if (other.isSetOptions()) {
Map<String,String> __this__options = new HashMap<String,String>();
for (Map.Entry<String, String> other_element : other.options.entrySet()) {
String other_element_key = other_element.getKey();
String other_element_value = other_element.getValue();
String __this__options_copy_key = other_element_key;
String __this__options_copy_value = other_element_value;
__this__options.put(__this__options_copy_key, __this__options_copy_value);
}
this.options = __this__options;
}
}
public TriggerDef deepCopy() {
return new TriggerDef(this);
}
@Override
public void clear() {
this.name = null;
this.options = null;
}
public String getName() {
return this.name;
}
public TriggerDef setName(String name) {
this.name = name;
return this;
}
public void unsetName() {
this.name = null;
}
/** Returns true if field name is set (has been assigned a value) and false otherwise */
public boolean isSetName() {
return this.name != null;
}
public void setNameIsSet(boolean value) {
if (!value) {
this.name = null;
}
}
public int getOptionsSize() {
return (this.options == null) ? 0 : this.options.size();
}
public void putToOptions(String key, String val) {
if (this.options == null) {
this.options = new HashMap<String,String>();
}
this.options.put(key, val);
}
public Map<String,String> getOptions() {
return this.options;
}
public TriggerDef setOptions(Map<String,String> options) {
this.options = options;
return this;
}
public void unsetOptions() {
this.options = null;
}
/** Returns true if field options is set (has been assigned a value) and false otherwise */
public boolean isSetOptions() {
return this.options != null;
}
public void setOptionsIsSet(boolean value) {
if (!value) {
this.options = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case NAME:
if (value == null) {
unsetName();
} else {
setName((String)value);
}
break;
case OPTIONS:
if (value == null) {
unsetOptions();
} else {
setOptions((Map<String,String>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case NAME:
return getName();
case OPTIONS:
return getOptions();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case NAME:
return isSetName();
case OPTIONS:
return isSetOptions();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TriggerDef)
return this.equals((TriggerDef)that);
return false;
}
public boolean equals(TriggerDef that) {
if (that == null)
return false;
boolean this_present_name = true && this.isSetName();
boolean that_present_name = true && that.isSetName();
if (this_present_name || that_present_name) {
if (!(this_present_name && that_present_name))
return false;
if (!this.name.equals(that.name))
return false;
}
boolean this_present_options = true && this.isSetOptions();
boolean that_present_options = true && that.isSetOptions();
if (this_present_options || that_present_options) {
if (!(this_present_options && that_present_options))
return false;
if (!this.options.equals(that.options))
return false;
}
return true;
}
@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_name = true && (isSetName());
builder.append(present_name);
if (present_name)
builder.append(name);
boolean present_options = true && (isSetOptions());
builder.append(present_options);
if (present_options)
builder.append(options);
return builder.toHashCode();
}
public int compareTo(TriggerDef other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TriggerDef typedOther = (TriggerDef)other;
lastComparison = Boolean.valueOf(isSetName()).compareTo(typedOther.isSetName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetName()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, typedOther.name);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetOptions()).compareTo(typedOther.isSetOptions());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetOptions()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.options, typedOther.options);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TriggerDef(");
boolean first = true;
sb.append("name:");
if (this.name == null) {
sb.append("null");
} else {
sb.append(this.name);
}
first = false;
if (!first) sb.append(", ");
sb.append("options:");
if (this.options == null) {
sb.append("null");
} else {
sb.append(this.options);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (name == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'name' was not present! Struct: " + toString());
}
if (options == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'options' was not present! Struct: " + toString());
}
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
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);
}
}
private static class TriggerDefStandardSchemeFactory implements SchemeFactory {
public TriggerDefStandardScheme getScheme() {
return new TriggerDefStandardScheme();
}
}
private static class TriggerDefStandardScheme extends StandardScheme<TriggerDef> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TriggerDef struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.name = iprot.readString();
struct.setNameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // OPTIONS
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map100 = iprot.readMapBegin();
struct.options = new HashMap<String,String>(2*_map100.size);
for (int _i101 = 0; _i101 < _map100.size; ++_i101)
{
String _key102; // optional
String _val103; // required
_key102 = iprot.readString();
_val103 = iprot.readString();
struct.options.put(_key102, _val103);
}
iprot.readMapEnd();
}
struct.setOptionsIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TriggerDef struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.name != null) {
oprot.writeFieldBegin(NAME_FIELD_DESC);
oprot.writeString(struct.name);
oprot.writeFieldEnd();
}
if (struct.options != null) {
oprot.writeFieldBegin(OPTIONS_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.options.size()));
for (Map.Entry<String, String> _iter104 : struct.options.entrySet())
{
oprot.writeString(_iter104.getKey());
oprot.writeString(_iter104.getValue());
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TriggerDefTupleSchemeFactory implements SchemeFactory {
public TriggerDefTupleScheme getScheme() {
return new TriggerDefTupleScheme();
}
}
private static class TriggerDefTupleScheme extends TupleScheme<TriggerDef> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TriggerDef struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
oprot.writeString(struct.name);
{
oprot.writeI32(struct.options.size());
for (Map.Entry<String, String> _iter105 : struct.options.entrySet())
{
oprot.writeString(_iter105.getKey());
oprot.writeString(_iter105.getValue());
}
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TriggerDef struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.name = iprot.readString();
struct.setNameIsSet(true);
{
org.apache.thrift.protocol.TMap _map106 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.options = new HashMap<String,String>(2*_map106.size);
for (int _i107 = 0; _i107 < _map106.size; ++_i107)
{
String _key108; // optional
String _val109; // required
_key108 = iprot.readString();
_val109 = iprot.readString();
struct.options.put(_key108, _val109);
}
}
struct.setOptionsIsSet(true);
}
}
}

View File

@ -24,13 +24,11 @@ import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.util.*;
import java.util.Map.Entry;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.collect.MapDifference;
import com.google.common.collect.Maps;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.EqualsBuilder;
@ -373,8 +371,7 @@ public final class CFMetaData
private volatile SpeculativeRetry speculativeRetry = DEFAULT_SPECULATIVE_RETRY;
private volatile boolean populateIoCacheOnFlush = DEFAULT_POPULATE_IO_CACHE_ON_FLUSH;
private volatile Map<ByteBuffer, Long> droppedColumns = new HashMap<>();
private volatile Map<String, Map<String, String>> triggers = new HashMap<>();
private volatile Collection<String> cachedTriggers;
private volatile Map<String, TriggerDefinition> triggers = new HashMap<>();
/*
* All CQL3 columns definition are stored in the column_metadata map.
@ -424,7 +421,7 @@ public final class CFMetaData
public CFMetaData speculativeRetry(SpeculativeRetry prop) {speculativeRetry = prop; return this;}
public CFMetaData populateIoCacheOnFlush(boolean prop) {populateIoCacheOnFlush = prop; return this;}
public CFMetaData droppedColumns(Map<ByteBuffer, Long> cols) {droppedColumns = cols; return this;}
public CFMetaData triggers(Map<String, Map<String, String>> prop) {triggers = prop; cachedTriggers = TriggerOptions.extractClasses(triggers); return this;}
public CFMetaData triggers(Map<String, TriggerDefinition> prop) {triggers = prop; return this;}
public CFMetaData(String keyspace, String name, ColumnFamilyType type, AbstractType<?> comp, AbstractType<?> subcc)
{
@ -447,9 +444,9 @@ public final class CFMetaData
cfId = id;
}
public Map<String, Map<String, String>> getTriggers()
public Map<String, TriggerDefinition> getTriggers()
{
return new HashMap<>(triggers);
return triggers;
}
private static CFMetaData compile(String cql)
@ -515,7 +512,6 @@ public final class CFMetaData
.gcGraceSeconds(0)
.caching(indexCaching)
.speculativeRetry(parent.speculativeRetry)
.triggers(parent.triggers)
.compactionStrategyClass(parent.compactionStrategyClass)
.compactionStrategyOptions(parent.compactionStrategyOptions)
.reloadSecondaryIndexMetadata(parent)
@ -713,11 +709,6 @@ public final class CFMetaData
: bloomFilterFpChance;
}
public Collection<String> getTriggerClasses()
{
return cachedTriggers;
}
public Caching getCaching()
{
return caching;
@ -911,7 +902,7 @@ public final class CFMetaData
if (cf_def.isSetPopulate_io_cache_on_flush())
newCFMD.populateIoCacheOnFlush(cf_def.populate_io_cache_on_flush);
if (cf_def.isSetTriggers())
newCFMD.triggers(cf_def.triggers);
newCFMD.triggers(TriggerDefinition.fromThrift(cf_def.triggers));
CompressionParameters cp = CompressionParameters.create(cf_def.compression_options);
@ -954,12 +945,12 @@ public final class CFMetaData
}
catch (CharacterCodingException ignore) {}
UntypedResultSet.Row cql3row = new UntypedResultSet.Row(columns);
return fromSchemaNoColumns(cql3row);
return fromSchemaNoColumnsNoTriggers(cql3row);
}
public void reload()
{
Row cfDefRow = SystemKeyspace.readSchemaRow(ksName, cfName);
Row cfDefRow = SystemKeyspace.readSchemaRow(SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF, ksName, cfName);
if (cfDefRow.cf == null || cfDefRow.cf.getColumnCount() == 0)
throw new RuntimeException(String.format("%s not found in the schema definitions keyspace.", ksName + ":" + cfName));
@ -1030,11 +1021,12 @@ public final class CFMetaData
oldDef.apply(def, getColumnDefinitionComparator(oldDef));
}
triggers(new HashMap<>(cfm.triggers)); // update trigger as an unit.
compactionStrategyClass = cfm.compactionStrategyClass;
compactionStrategyOptions = cfm.compactionStrategyOptions;
compressionParameters = cfm.compressionParameters();
compressionParameters = cfm.compressionParameters;
triggers = cfm.triggers;
rebuild();
logger.debug("application result is {}", this);
@ -1156,13 +1148,7 @@ public final class CFMetaData
// We only return the alias if only one is set since thrift don't know about multiple key aliases
if (partitionKeyColumns.size() == 1)
def.setKey_alias(partitionKeyColumns.get(0).name);
List<org.apache.cassandra.thrift.ColumnDef> column_meta = new ArrayList<org.apache.cassandra.thrift.ColumnDef>(column_metadata.size());
for (ColumnDefinition cd : column_metadata.values())
{
if (cd.type == ColumnDefinition.Type.REGULAR)
column_meta.add(cd.toThrift());
}
def.setColumn_metadata(column_meta);
def.setColumn_metadata(ColumnDefinition.toThrift(column_metadata));
def.setCompaction_strategy(compactionStrategyClass.getName());
def.setCompaction_strategy_options(new HashMap<String, String>(compactionStrategyOptions));
def.setCompression_options(compressionParameters.asThriftOptions());
@ -1173,7 +1159,8 @@ public final class CFMetaData
def.setCaching(caching.toString());
def.setDefault_time_to_live(defaultTimeToLive);
def.setSpeculative_retry(speculativeRetry.toString());
def.setTriggers(triggers);
def.setTriggers(TriggerDefinition.toThrift(triggers));
return def;
}
@ -1438,7 +1425,7 @@ public final class CFMetaData
{
RowMutation rm = new RowMutation(Keyspace.SYSTEM_KS, SystemKeyspace.getSchemaKSKey(ksName));
newState.toSchemaNoColumns(rm, modificationTimestamp);
newState.toSchemaNoColumnsNoTriggers(rm, modificationTimestamp);
MapDifference<ByteBuffer, ColumnDefinition> columnDiff = Maps.difference(column_metadata, newState.column_metadata);
@ -1464,11 +1451,15 @@ public final class CFMetaData
cd.toSchema(rm, cfName, getColumnDefinitionComparator(cd), modificationTimestamp);
}
MapDifference<String, Map<String, String>> tdiffrence = Maps.difference(triggers, newState.triggers);
for (Entry<String, Map<String, String>> tentry : tdiffrence.entriesOnlyOnLeft().entrySet())
TriggerOptions.deleteColumns(rm, cfName, tentry, modificationTimestamp);
for (Entry<String, Map<String, String>> tentry : tdiffrence.entriesOnlyOnRight().entrySet())
TriggerOptions.addColumns(rm, cfName, tentry, modificationTimestamp);
MapDifference<String, TriggerDefinition> triggerDiff = Maps.difference(triggers, newState.triggers);
// dropped triggers
for (TriggerDefinition td : triggerDiff.entriesOnlyOnLeft().values())
td.deleteFromSchema(rm, cfName, modificationTimestamp);
// newly created triggers
for (TriggerDefinition td : triggerDiff.entriesOnlyOnRight().values())
td.toSchema(rm, cfName, modificationTimestamp);
return rm;
}
@ -1490,26 +1481,24 @@ public final class CFMetaData
builder.add(ByteBufferUtil.bytes(cfName));
cf.addAtom(new RangeTombstone(builder.build(), builder.buildAsEndOfRange(), timestamp, ldt));
ColumnFamily tcf = rm.addOrGet(SchemaTriggersCf);
ColumnNameBuilder tbuilder = SchemaTriggersCf.getCfDef().getColumnNameBuilder();
tbuilder.add(ByteBufferUtil.bytes(cfName));
tcf.addAtom(new RangeTombstone(tbuilder.build(), tbuilder.buildAsEndOfRange(), timestamp, ldt));
for (ColumnDefinition cd : column_metadata.values())
cd.deleteFromSchema(rm, cfName, timestamp);
for (TriggerDefinition td : triggers.values())
td.deleteFromSchema(rm, cfName, timestamp);
return rm;
}
public void toSchema(RowMutation rm, long timestamp)
{
toSchemaNoColumns(rm, timestamp);
toSchemaNoColumnsNoTriggers(rm, timestamp);
for (ColumnDefinition cd : column_metadata.values())
cd.toSchema(rm, cfName, getColumnDefinitionComparator(cd), timestamp);
}
private void toSchemaNoColumns(RowMutation rm, long timestamp)
private void toSchemaNoColumnsNoTriggers(RowMutation rm, long timestamp)
{
// For property that can be null (and can be changed), we insert tombstones, to make sure
// we don't keep a property the user has removed
@ -1566,7 +1555,7 @@ public final class CFMetaData
}
// Package protected for use by tests
static CFMetaData fromSchemaNoColumns(UntypedResultSet.Row result)
static CFMetaData fromSchemaNoColumnsNoTriggers(UntypedResultSet.Row result)
{
try
{
@ -1664,13 +1653,13 @@ public final class CFMetaData
*/
public static CFMetaData fromSchema(UntypedResultSet.Row result)
{
CFMetaData cfDef = fromSchemaNoColumns(result);
CFMetaData cfDef = fromSchemaNoColumnsNoTriggers(result);
// read triggers.
cfDef.triggers(TriggerOptions.getAllTriggers(cfDef.ksName, cfDef.cfName));
Row serializedTriggers = SystemKeyspace.readSchemaRow(SystemKeyspace.SCHEMA_TRIGGERS_CF, cfDef.ksName, cfDef.cfName);
addTriggerDefinitionsFromSchema(cfDef, serializedTriggers);
Row serializedColumnDefinitions = ColumnDefinition.readSchema(cfDef.ksName, cfDef.cfName);
return addColumnDefinitionSchema(cfDef, serializedColumnDefinitions);
Row serializedColumns = SystemKeyspace.readSchemaRow(SystemKeyspace.SCHEMA_COLUMNS_CF, cfDef.ksName, cfDef.cfName);
return addColumnDefinitionsFromSchema(cfDef, serializedColumns);
}
private static CFMetaData fromSchema(Row row)
@ -1761,7 +1750,7 @@ public final class CFMetaData
}
// Package protected for use by tests
static CFMetaData addColumnDefinitionSchema(CFMetaData cfDef, Row serializedColumnDefinitions)
static CFMetaData addColumnDefinitionsFromSchema(CFMetaData cfDef, Row serializedColumnDefinitions)
{
for (ColumnDefinition cd : ColumnDefinition.fromSchema(serializedColumnDefinitions, cfDef))
cfDef.column_metadata.put(cd.name, cd);
@ -1788,6 +1777,24 @@ public final class CFMetaData
return column_metadata.remove(def.name) != null;
}
private static void addTriggerDefinitionsFromSchema(CFMetaData cfDef, Row serializedTriggerDefinitions)
{
for (TriggerDefinition td : TriggerDefinition.fromSchema(serializedTriggerDefinitions))
cfDef.triggers.put(td.name, td);
}
public void addTriggerDefinition(TriggerDefinition def) throws ConfigurationException
{
if (triggers.containsKey(def.name))
throw new ConfigurationException(String.format("Cannot create trigger %s, a trigger with the same name already exists", def.name));
triggers.put(def.name, def);
}
public boolean removeTrigger(String name)
{
return triggers.remove(name) != null;
}
public void recordColumnDrop(ColumnDefinition def)
{
assert def.componentIndex != null;

View File

@ -148,6 +148,15 @@ public class ColumnDefinition
return type == ColumnDefinition.Type.REGULAR && componentIndex == null;
}
public static List<ColumnDef> toThrift(Map<ByteBuffer, ColumnDefinition> columns)
{
List<ColumnDef> thriftDefs = new ArrayList<>(columns.size());
for (ColumnDefinition def : columns.values())
if (def.type == ColumnDefinition.Type.REGULAR)
thriftDefs.add(def.toThrift());
return thriftDefs;
}
public ColumnDef toThrift()
{
ColumnDef cd = new ColumnDef();

View File

@ -308,13 +308,11 @@ public final class KSMetaData
for (CFMetaData cfm : cfms.values())
{
Row columnRow = ColumnDefinition.readSchema(cfm.ksName, cfm.cfName);
Row columnRow = SystemKeyspace.readSchemaRow(SystemKeyspace.SCHEMA_COLUMNS_CF, cfm.ksName, cfm.cfName);
// This may replace some existing definition coming from the old key, column and
// value aliases. But that's what we want (see CFMetaData.fromSchemaNoColumnsNoTriggers).
for (ColumnDefinition cd : ColumnDefinition.fromSchema(columnRow, cfm))
{
// This may replace some existing definition coming from the old key, column and
// value aliases. But that's what we want (see CFMetaData.fromSchemaNoColumns).
cfm.addOrReplaceColumnDefinition(cd);
}
cfm.rebuild();
}

View File

@ -0,0 +1,166 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cassandra.config;
import java.util.*;
import com.google.common.base.Objects;
import org.apache.cassandra.cql3.ColumnNameBuilder;
import org.apache.cassandra.cql3.QueryProcessor;
import org.apache.cassandra.cql3.UntypedResultSet;
import org.apache.cassandra.db.*;
import org.apache.cassandra.db.marshal.UTF8Type;
import org.apache.cassandra.thrift.TriggerDef;
import static org.apache.cassandra.utils.ByteBufferUtil.bytes;
public class TriggerDefinition
{
private static final String TRIGGER_NAME = "trigger_name";
private static final String TRIGGER_OPTIONS = "trigger_options";
private static final String CLASS = "class";
public final String name;
// For now, the only supported option is 'class'.
// Proper trigger parametrization will be added later.
public final String classOption;
TriggerDefinition(String name, String classOption)
{
this.name = name;
this.classOption = classOption;
}
public static TriggerDefinition create(String name, String classOption)
{
return new TriggerDefinition(name, classOption);
}
/**
* Deserialize triggers from storage-level representation.
*
* @param serializedTriggers storage-level partition containing the trigger definitions
* @return the list of processed TriggerDefinitions
*/
public static List<TriggerDefinition> fromSchema(Row serializedTriggers)
{
List<TriggerDefinition> triggers = new ArrayList<>();
String query = String.format("SELECT * FROM %s.%s", Keyspace.SYSTEM_KS, SystemKeyspace.SCHEMA_TRIGGERS_CF);
for (UntypedResultSet.Row row : QueryProcessor.resultify(query, serializedTriggers))
{
String name = row.getString(TRIGGER_NAME);
String classOption = row.getMap(TRIGGER_OPTIONS, UTF8Type.instance, UTF8Type.instance).get(CLASS);
triggers.add(new TriggerDefinition(name, classOption));
}
return triggers;
}
/**
* Add specified trigger to the schema using given row.
*
* @param rm The schema row mutation
* @param cfName The name of the parent ColumnFamily
* @param timestamp The timestamp to use for the columns
*/
public void toSchema(RowMutation rm, String cfName, long timestamp)
{
ColumnFamily cf = rm.addOrGet(SystemKeyspace.SCHEMA_TRIGGERS_CF);
ColumnNameBuilder builder = CFMetaData.SchemaTriggersCf.getCfDef().getColumnNameBuilder();
builder.add(bytes(cfName)).add(bytes(name));
cf.addColumn(builder.copy().add(bytes("")).build(), bytes(""), timestamp); // the row marker
cf.addColumn(builder.copy().add(bytes(TRIGGER_OPTIONS)).add(bytes(CLASS)).build(), bytes(classOption), timestamp);
}
/**
* Drop specified trigger from the schema using given row.
*
* @param rm The schema row mutation
* @param cfName The name of the parent ColumnFamily
* @param timestamp The timestamp to use for the tombstone
*/
public void deleteFromSchema(RowMutation rm, String cfName, long timestamp)
{
ColumnFamily cf = rm.addOrGet(SystemKeyspace.SCHEMA_TRIGGERS_CF);
int ldt = (int) (System.currentTimeMillis() / 1000);
ColumnNameBuilder builder = CFMetaData.SchemaTriggersCf.getCfDef().getColumnNameBuilder();
builder.add(bytes(cfName)).add(bytes(name));
cf.addAtom(new RangeTombstone(builder.build(), builder.buildAsEndOfRange(), timestamp, ldt));
}
public static TriggerDefinition fromThrift(TriggerDef thriftDef)
{
return new TriggerDefinition(thriftDef.getName(), thriftDef.getOptions().get(CLASS));
}
public TriggerDef toThrift()
{
TriggerDef td = new TriggerDef();
td.setName(name);
td.setOptions(Collections.singletonMap(CLASS, classOption));
return td;
}
public static Map<String, TriggerDefinition> fromThrift(List<TriggerDef> thriftDefs)
{
Map<String, TriggerDefinition> triggerDefinitions = new HashMap<>();
for (TriggerDef thriftDef : thriftDefs)
triggerDefinitions.put(thriftDef.getName(), fromThrift(thriftDef));
return triggerDefinitions;
}
public static List<TriggerDef> toThrift(Map<String, TriggerDefinition> triggers)
{
List<TriggerDef> thriftDefs = new ArrayList<>(triggers.size());
for (TriggerDefinition def : triggers.values())
thriftDefs.add(def.toThrift());
return thriftDefs;
}
@Override
public boolean equals(Object o)
{
if (this == o)
return true;
if (!(o instanceof TriggerDefinition))
return false;
TriggerDefinition td = (TriggerDefinition) o;
return Objects.equal(this.name, td.name)
&& Objects.equal(this.classOption, td.classOption);
}
@Override
public int hashCode()
{
return Objects.hashCode(name, classOption);
}
@Override
public String toString()
{
return Objects.toStringHelper(this).add("name", name).add("classOption", classOption).toString();
}
}

View File

@ -1,110 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cassandra.config;
import static org.apache.cassandra.cql3.QueryProcessor.processInternal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.cassandra.cql3.ColumnNameBuilder;
import org.apache.cassandra.cql3.UntypedResultSet;
import org.apache.cassandra.cql3.UntypedResultSet.Row;
import org.apache.cassandra.db.ColumnFamily;
import org.apache.cassandra.db.RangeTombstone;
import org.apache.cassandra.db.RowMutation;
import org.apache.cassandra.db.SystemKeyspace;
import org.apache.cassandra.db.marshal.UTF8Type;
import org.apache.cassandra.utils.ByteBufferUtil;
public class TriggerOptions
{
private static final String CLASS_KEY = "class";
private static final String OPTIONS_KEY = "trigger_options";
public static Map<String, Map<String, String>> getAllTriggers(String ksName, String cfName)
{
String req = "SELECT * FROM system.%s WHERE keyspace_name='%s' AND columnfamily_name='%s'";
UntypedResultSet result = processInternal(String.format(req, SystemKeyspace.SCHEMA_TRIGGERS_CF, ksName, cfName));
Map<String, Map<String, String>> triggers = new HashMap<>();
if (result.isEmpty())
return triggers;
for (Row row : result)
triggers.put(row.getString("trigger_name"), row.getMap(OPTIONS_KEY, UTF8Type.instance, UTF8Type.instance));
return triggers;
}
public static void addColumns(RowMutation rm, String cfName, Entry<String, Map<String, String>> tentry, long modificationTimestamp)
{
ColumnFamily cf = rm.addOrGet(CFMetaData.SchemaTriggersCf);
assert tentry.getValue().get(CLASS_KEY) != null;
ColumnNameBuilder builder = CFMetaData.SchemaTriggersCf.getCfDef().getColumnNameBuilder();
builder.add(ByteBufferUtil.bytes(cfName)).add(ByteBufferUtil.bytes(tentry.getKey())).add(ByteBufferUtil.bytes(OPTIONS_KEY));
for (Entry<String, String> entry : tentry.getValue().entrySet())
{
ColumnNameBuilder builderCopy = builder.copy();
builderCopy.add(ByteBufferUtil.bytes(entry.getKey()));
cf.addColumn(builderCopy.build(), ByteBufferUtil.bytes(entry.getValue()), modificationTimestamp);
}
}
public static void deleteColumns(RowMutation rm, String cfName, Entry<String, Map<String, String>> tentry, long modificationTimestamp)
{
ColumnFamily cf = rm.addOrGet(CFMetaData.SchemaTriggersCf);
int ldt = (int) (System.currentTimeMillis() / 1000);
ColumnNameBuilder builder = CFMetaData.SchemaTriggersCf.getCfDef().getColumnNameBuilder();
builder.add(ByteBufferUtil.bytes(cfName)).add(ByteBufferUtil.bytes(tentry.getKey()));
cf.addAtom(new RangeTombstone(builder.build(), builder.buildAsEndOfRange(), modificationTimestamp, ldt));
}
public static void update(CFMetaData cfm, String triggerName, String clazz)
{
Map<String, Map<String, String>> existingTriggers = cfm.getTriggers();
assert existingTriggers.get(triggerName) == null;
Map<String, String> triggerUnit = new HashMap<>();
triggerUnit.put(CLASS_KEY, clazz);
existingTriggers.put(triggerName, triggerUnit);
cfm.triggers(existingTriggers);
}
public static void remove(CFMetaData cfm, String triggerName)
{
Map<String, Map<String, String>> existingTriggers = cfm.getTriggers(); // have a copy of the triggers
existingTriggers.remove(triggerName);
cfm.triggers(existingTriggers);
}
public static boolean hasTrigger(CFMetaData cfm, String triggerName)
{
return cfm.getTriggers().get(triggerName) != null;
}
public static Collection<String> extractClasses(Map<String, Map<String, String>> triggers)
{
List<String> classes = new ArrayList<>();
if (triggers.isEmpty())
return null;
for (Map<String, String> options : triggers.values())
classes.add(options.get(CLASS_KEY));
return classes;
}
}

View File

@ -17,13 +17,15 @@
*/
package org.apache.cassandra.cql3.statements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.cassandra.auth.Permission;
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.config.Schema;
import org.apache.cassandra.config.TriggerOptions;
import org.apache.cassandra.config.TriggerDefinition;
import org.apache.cassandra.cql3.CFName;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.exceptions.ExceptionCode;
import org.apache.cassandra.exceptions.InvalidRequestException;
import org.apache.cassandra.exceptions.RequestValidationException;
import org.apache.cassandra.exceptions.UnauthorizedException;
@ -32,21 +34,19 @@ import org.apache.cassandra.service.MigrationManager;
import org.apache.cassandra.thrift.ThriftValidation;
import org.apache.cassandra.transport.messages.ResultMessage;
import org.apache.cassandra.triggers.TriggerExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CreateTriggerStatement extends SchemaAlteringStatement
{
private static final Logger logger = LoggerFactory.getLogger(CreateTriggerStatement.class);
private final String triggerName;
private final String clazz;
private final String triggerClass;
public CreateTriggerStatement(CFName name, String triggerName, String clazz)
{
super(name);
this.triggerName = triggerName;
this.clazz = clazz;
this.triggerClass = clazz;
}
public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException
@ -59,19 +59,19 @@ public class CreateTriggerStatement extends SchemaAlteringStatement
ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
try
{
TriggerExecutor.instance.loadTriggerInstance(clazz);
TriggerExecutor.instance.loadTriggerInstance(triggerClass);
}
catch (Exception ex)
catch (Exception e)
{
throw new RequestValidationException(ExceptionCode.INVALID, "Trigger class: " + clazz + ", doesnt exist.", ex) {};
throw new ConfigurationException(String.format("Trigger class '%s' doesn't exist", triggerClass));
}
}
public void announceMigration() throws InvalidRequestException, ConfigurationException
{
CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).clone();
TriggerOptions.update(cfm, triggerName, clazz);
logger.info("Adding triggers with name {} and classes {}", triggerName, clazz);
cfm.addTriggerDefinition(TriggerDefinition.create(triggerName, triggerClass));
logger.info("Adding trigger with name {} and class {}", triggerName, triggerClass);
MigrationManager.announceColumnFamilyUpdate(cfm, false);
}

View File

@ -17,13 +17,14 @@
*/
package org.apache.cassandra.cql3.statements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.cassandra.auth.Permission;
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.config.Schema;
import org.apache.cassandra.config.TriggerOptions;
import org.apache.cassandra.cql3.CFName;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.exceptions.ExceptionCode;
import org.apache.cassandra.exceptions.InvalidRequestException;
import org.apache.cassandra.exceptions.RequestValidationException;
import org.apache.cassandra.exceptions.UnauthorizedException;
@ -31,12 +32,11 @@ import org.apache.cassandra.service.ClientState;
import org.apache.cassandra.service.MigrationManager;
import org.apache.cassandra.thrift.ThriftValidation;
import org.apache.cassandra.transport.messages.ResultMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DropTriggerStatement extends SchemaAlteringStatement
{
private static final Logger logger = LoggerFactory.getLogger(DropTriggerStatement.class);
private final String triggerName;
public DropTriggerStatement(CFName name, String triggerName)
@ -53,17 +53,13 @@ public class DropTriggerStatement extends SchemaAlteringStatement
public void validate(ClientState state) throws RequestValidationException
{
ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily());
if (cfm.getTriggerClasses() == null)
throw new RequestValidationException(ExceptionCode.CONFIG_ERROR, "No triggers found") {};
if (!TriggerOptions.hasTrigger(cfm, triggerName))
throw new RequestValidationException(ExceptionCode.CONFIG_ERROR, "trigger: " + triggerName + ", not found") {};
}
public void announceMigration() throws InvalidRequestException, ConfigurationException
{
CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).clone();
TriggerOptions.remove(cfm, triggerName);
if (!cfm.removeTrigger(triggerName))
throw new ConfigurationException(String.format("Trigger %s was not found", triggerName));
logger.info("Dropping trigger with name {}", triggerName);
MigrationManager.announceColumnFamilyUpdate(cfm, false);
}

View File

@ -463,6 +463,7 @@ public class DefsTables
SystemKeyspace.forceBlockingFlush(SystemKeyspace.SCHEMA_KEYSPACES_CF);
SystemKeyspace.forceBlockingFlush(SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF);
SystemKeyspace.forceBlockingFlush(SystemKeyspace.SCHEMA_COLUMNS_CF);
SystemKeyspace.forceBlockingFlush(SystemKeyspace.SCHEMA_TRIGGERS_CF);
}
}

View File

@ -676,11 +676,12 @@ public class SystemKeyspace
public static List<Row> serializedSchema()
{
List<Row> schema = new ArrayList<Row>(3);
List<Row> schema = new ArrayList<>();
schema.addAll(serializedSchema(SCHEMA_KEYSPACES_CF));
schema.addAll(serializedSchema(SCHEMA_COLUMNFAMILIES_CF));
schema.addAll(serializedSchema(SCHEMA_COLUMNS_CF));
schema.addAll(serializedSchema(SCHEMA_TRIGGERS_CF));
return schema;
}
@ -702,11 +703,12 @@ public class SystemKeyspace
public static Collection<RowMutation> serializeSchema()
{
Map<DecoratedKey, RowMutation> mutationMap = new HashMap<DecoratedKey, RowMutation>();
Map<DecoratedKey, RowMutation> mutationMap = new HashMap<>();
serializeSchema(mutationMap, SCHEMA_KEYSPACES_CF);
serializeSchema(mutationMap, SCHEMA_COLUMNFAMILIES_CF);
serializeSchema(mutationMap, SCHEMA_COLUMNS_CF);
serializeSchema(mutationMap, SCHEMA_TRIGGERS_CF);
return mutationMap.values();
}
@ -754,19 +756,25 @@ public class SystemKeyspace
return new Row(key, result);
}
public static Row readSchemaRow(String ksName, String cfName)
/**
* Fetches a subset of schema (table data, columns metadata or triggers) for the keyspace+table pair.
*
* @param schemaCfName the schema table to get the data from (schema_columnfamilies, schema_columns or schema_triggers)
* @param ksName the keyspace of the table we are interested in
* @param cfName the table we are interested in
* @return a Row containing the schema data of a particular type for the table
*/
public static Row readSchemaRow(String schemaCfName, String ksName, String cfName)
{
DecoratedKey key = StorageService.getPartitioner().decorateKey(getSchemaKSKey(ksName));
ColumnFamilyStore schemaCFS = SystemKeyspace.schemaCFS(SCHEMA_COLUMNFAMILIES_CF);
ColumnFamily result = schemaCFS.getColumnFamily(key,
DefsTables.searchComposite(cfName, true),
DefsTables.searchComposite(cfName, false),
false,
Integer.MAX_VALUE,
System.currentTimeMillis());
return new Row(key, result);
ColumnFamilyStore schemaCFS = SystemKeyspace.schemaCFS(schemaCfName);
ColumnFamily cf = schemaCFS.getColumnFamily(key,
DefsTables.searchComposite(cfName, true),
DefsTables.searchComposite(cfName, false),
false,
Integer.MAX_VALUE,
System.currentTimeMillis());
return new Row(key, cf);
}
public static PaxosState loadPaxosState(ByteBuffer key, CFMetaData metadata)

View File

@ -335,6 +335,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
SystemKeyspace.schemaCFS(SystemKeyspace.SCHEMA_KEYSPACES_CF).truncateBlocking();
SystemKeyspace.schemaCFS(SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF).truncateBlocking();
SystemKeyspace.schemaCFS(SystemKeyspace.SCHEMA_COLUMNS_CF).truncateBlocking();
SystemKeyspace.schemaCFS(SystemKeyspace.SCHEMA_TRIGGERS_CF).truncateBlocking();
if (logger.isDebugEnabled())
logger.debug("Clearing local schema keyspace definitions...");

View File

@ -1,6 +1,4 @@
package org.apache.cassandra.triggers;
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -17,17 +15,19 @@ package org.apache.cassandra.triggers;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.cassandra.triggers;
import java.io.File;
import java.lang.reflect.Constructor;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.cassandra.config.TriggerDefinition;
import org.apache.cassandra.cql.QueryProcessor;
import org.apache.cassandra.db.ColumnFamily;
import org.apache.cassandra.db.CounterMutation;
@ -36,9 +36,6 @@ import org.apache.cassandra.db.RowMutation;
import org.apache.cassandra.exceptions.InvalidRequestException;
import org.apache.cassandra.utils.FBUtilities;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
public class TriggerExecutor
{
public static final TriggerExecutor instance = new TriggerExecutor();
@ -106,20 +103,20 @@ public class TriggerExecutor
*/
private List<RowMutation> execute(ByteBuffer key, ColumnFamily columnFamily)
{
Collection<String> triggerNames = columnFamily.metadata().getTriggerClasses();
if (triggerNames == null)
Map<String,TriggerDefinition> triggers = columnFamily.metadata().getTriggers();
if (triggers.isEmpty())
return null;
List<RowMutation> tmutations = Lists.newLinkedList();
Thread.currentThread().setContextClassLoader(customClassLoader);
try
{
for (String triggerName : triggerNames)
for (TriggerDefinition td : triggers.values())
{
ITrigger trigger = cachedTriggers.get(triggerName);
ITrigger trigger = cachedTriggers.get(td.classOption);
if (trigger == null)
{
trigger = loadTriggerInstance(triggerName);
cachedTriggers.put(triggerName, trigger);
trigger = loadTriggerInstance(td.classOption);
cachedTriggers.put(td.classOption, trigger);
}
Collection<RowMutation> temp = trigger.augment(key, columnFamily);
if (temp != null)
@ -142,8 +139,6 @@ public class TriggerExecutor
// double check.
if (cachedTriggers.get(triggerName) != null)
return cachedTriggers.get(triggerName);
Constructor<? extends ITrigger> costructor = (Constructor<? extends ITrigger>) customClassLoader.loadClass(triggerName).getConstructor(new Class<?>[0]);
return costructor.newInstance(new Object[0]);
return (ITrigger) customClassLoader.loadClass(triggerName).getConstructor().newInstance();
}
}

View File

@ -145,7 +145,7 @@ public class CFMetaDataTest extends SchemaLoader
ColumnFamily serializedCf = rm.getColumnFamily(Schema.instance.getId(Keyspace.SYSTEM_KS, SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF));
ColumnFamily serializedCD = rm.getColumnFamily(Schema.instance.getId(Keyspace.SYSTEM_KS, SystemKeyspace.SCHEMA_COLUMNS_CF));
UntypedResultSet.Row result = QueryProcessor.resultify("SELECT * FROM system.schema_columnfamilies", new Row(k, serializedCf)).one();
CFMetaData newCfm = CFMetaData.addColumnDefinitionSchema(CFMetaData.fromSchemaNoColumns(result), new Row(k, serializedCD));
CFMetaData newCfm = CFMetaData.addColumnDefinitionsFromSchema(CFMetaData.fromSchemaNoColumnsNoTriggers(result), new Row(k, serializedCD));
assert cfm.equals(newCfm) : String.format("\n%s\n!=\n%s", cfm, newCfm);
}
}