Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraException.java URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraException.java?rev=768381&r1=768380&r2=768381&view=diff ============================================================================== --- incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraException.java (original) +++ incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraException.java Fri Apr 24 17:52:07 2009 @@ -20,18 +20,18 @@ public class CassandraException extends Exception implements TBase, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("CassandraException"); - private static final TField ERROR_FIELD_DESC = new TField("error", TType.STRING, (short)1); + private static final TField WHY_FIELD_DESC = new TField("why", TType.STRING, (short)1); - public String error; - public static final int ERROR = 1; + public String why; + public static final int WHY = 1; private final Isset __isset = new Isset(); private static final class Isset implements java.io.Serializable { - public boolean error = false; + public boolean why = false; } public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{ - put(ERROR, new FieldMetaData("error", TFieldRequirementType.DEFAULT, + put(WHY, new FieldMetaData("why", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.STRING))); }}); @@ -43,20 +43,20 @@ } public CassandraException( - String error) + String why) { this(); - this.error = error; - this.__isset.error = (error != null); + this.why = why; + this.__isset.why = (why != null); } /** * Performs a deep copy on <i>other</i>. */ public CassandraException(CassandraException other) { - __isset.error = other.__isset.error; - if (other.error != null) { - this.error = other.error; + __isset.why = other.__isset.why; + if (other.why != null) { + this.why = other.why; } } @@ -65,32 +65,32 @@ return new CassandraException(this); } - public String getError() { - return this.error; + public String getWhy() { + return this.why; } - public void setError(String error) { - this.error = error; - this.__isset.error = (error != null); + public void setWhy(String why) { + this.why = why; + this.__isset.why = (why != null); } - public void unsetError() { - this.__isset.error = false; + public void unsetWhy() { + this.__isset.why = false; } - // Returns true if field error is set (has been asigned a value) and false otherwise - public boolean isSetError() { - return this.__isset.error; + // Returns true if field why is set (has been asigned a value) and false otherwise + public boolean isSetWhy() { + return this.__isset.why; } - public void setErrorIsSet(boolean value) { - this.__isset.error = value; + public void setWhyIsSet(boolean value) { + this.__isset.why = value; } public void setFieldValue(int fieldID, Object value) { switch (fieldID) { - case ERROR: - setError((String)value); + case WHY: + setWhy((String)value); break; default: @@ -100,8 +100,8 @@ public Object getFieldValue(int fieldID) { switch (fieldID) { - case ERROR: - return getError(); + case WHY: + return getWhy(); default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); @@ -111,8 +111,8 @@ // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise public boolean isSet(int fieldID) { switch (fieldID) { - case ERROR: - return this.__isset.error; + case WHY: + return this.__isset.why; default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } @@ -131,12 +131,12 @@ if (that == null) return false; - boolean this_present_error = true && (this.error != null); - boolean that_present_error = true && (that.error != null); - if (this_present_error || that_present_error) { - if (!(this_present_error && that_present_error)) + boolean this_present_why = true && (this.why != null); + boolean that_present_why = true && (that.why != null); + if (this_present_why || that_present_why) { + if (!(this_present_why && that_present_why)) return false; - if (!this.error.equals(that.error)) + if (!this.why.equals(that.why)) return false; } @@ -159,10 +159,10 @@ } switch (field.id) { - case ERROR: + case WHY: if (field.type == TType.STRING) { - this.error = iprot.readString(); - this.__isset.error = true; + this.why = iprot.readString(); + this.__isset.why = true; } else { TProtocolUtil.skip(iprot, field.type); } @@ -184,9 +184,9 @@ validate(); oprot.writeStructBegin(STRUCT_DESC); - if (this.error != null) { - oprot.writeFieldBegin(ERROR_FIELD_DESC); - oprot.writeString(this.error); + if (this.why != null) { + oprot.writeFieldBegin(WHY_FIELD_DESC); + oprot.writeString(this.why); oprot.writeFieldEnd(); } oprot.writeFieldStop(); @@ -199,8 +199,8 @@ boolean first = true; if (!first) sb.append(", "); - sb.append("error:"); - sb.append(this.error); + sb.append("why:"); + sb.append(this.why); first = false; sb.append(")"); return sb.toString();
Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraServer.java URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraServer.java?rev=768381&r1=768380&r2=768381&view=diff ============================================================================== --- incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraServer.java (original) +++ incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraServer.java Fri Apr 24 17:52:07 2009 @@ -41,6 +41,7 @@ import org.apache.cassandra.db.ReadCommand; import org.apache.cassandra.db.Table; import org.apache.cassandra.db.ColumnFamilyNotDefinedException; +import org.apache.cassandra.db.TableNotDefinedException; import org.apache.cassandra.utils.LogUtil; import org.apache.thrift.TException; @@ -76,28 +77,34 @@ storageService.start(); } - private void validateTable(String table) throws CassandraException + private void validateCommand(String key, String tablename, String... columnFamilyNames) throws InvalidRequestException { - if ( !DatabaseDescriptor.getTables().contains(table) ) + if (key.isEmpty()) + { + throw new InvalidRequestException("Key may not be empty"); + } + if ( !DatabaseDescriptor.getTables().contains(tablename) ) { - throw new CassandraException("Table " + table + " does not exist in this schema."); + throw new TableNotDefinedException("Table " + tablename + " does not exist in this schema."); } + Table table = Table.open(tablename); + for (String cfName : columnFamilyNames) + { + if (!table.getColumnFamilies().contains(cfName)) + { + throw new ColumnFamilyNotDefinedException("Column Family " + cfName + " is invalid."); + } + } } - protected ColumnFamily readColumnFamily(ReadCommand command) throws CassandraException, TException, IOException, ColumnFamilyNotDefinedException, TimeoutException + protected ColumnFamily readColumnFamily(ReadCommand command) throws CassandraException, TException, IOException, InvalidRequestException, TimeoutException { - validateTable(command.table); String[] values = RowMutation.getColumnAndColumnFamily(command.columnFamilyColumn); if( values.length < 1 ) { - throw new CassandraException("Empty column Family is invalid."); + throw new ColumnFamilyNotDefinedException("Empty column Family is invalid."); } - Table table = Table.open(command.table); - if (!table.getColumnFamilies().contains(values[0])) - { - throw new CassandraException("Column Family " + values[0] + " is invalid."); - } - + validateCommand(command.key, command.table, values[0]); Row row = StorageProxy.readProtocol(command, StorageService.ConsistencyLevel.WEAK); if (row == null) { @@ -121,7 +128,7 @@ return thriftColumns; } - public List<column_t> get_columns_since(String tablename, String key, String columnFamily_column, long timeStamp) throws CassandraException,TException + public List<column_t> get_columns_since(String tablename, String key, String columnFamily_column, long timeStamp) throws CassandraException, TException { long startTime = System.currentTimeMillis(); try @@ -171,7 +178,6 @@ long startTime = System.currentTimeMillis(); try { - validateTable(tablename); ColumnFamily cfamily = readColumnFamily(new ReadCommand(tablename, key, columnFamily, columnNames)); if (cfamily == null) { @@ -346,9 +352,9 @@ { try { - validateTable(tablename); RowMutation rm = new RowMutation(tablename, key.trim()); rm.add(columnFamily_column, cellData, timestamp); + validateCommand(rm.key(), rm.table(), rm.columnFamilyNames().toArray(new String[0])); StorageProxy.insert(rm); } catch (Exception e) @@ -358,25 +364,36 @@ return; } - public boolean batch_insert_blocking(batch_mutation_t batchMutation) + public boolean batch_insert_blocking(batch_mutation_t batchMutation) throws InvalidRequestException { logger_.debug("batch_insert_blocking"); RowMutation rm = RowMutation.getRowMutation(batchMutation); + validateCommand(rm.key(), rm.table(), rm.columnFamilyNames().toArray(new String[0])); return StorageProxy.insertBlocking(rm); } public void batch_insert(batch_mutation_t batchMutation) - { + { logger_.debug("batch_insert"); RowMutation rm = RowMutation.getRowMutation(batchMutation); + try + { + validateCommand(rm.key(), rm.table(), rm.columnFamilyNames().toArray(new String[0])); + } + catch (InvalidRequestException e) + { + // it would be confusing to declare an exception in thrift that can't be returned to the client + throw new RuntimeException(e); + } StorageProxy.insert(rm); } - public boolean remove(String tablename, String key, String columnFamily_column, long timestamp, boolean block) - { + public boolean remove(String tablename, String key, String columnFamily_column, long timestamp, boolean block) throws InvalidRequestException + { logger_.debug("remove"); RowMutation rm = new RowMutation(tablename, key.trim()); rm.delete(columnFamily_column, timestamp); + validateCommand(rm.key(), rm.table(), rm.columnFamilyNames().toArray(new String[0])); if (block) { return StorageProxy.insertBlocking(rm); } else { @@ -391,7 +408,6 @@ try { - validateTable(tablename); ColumnFamily cfamily = readColumnFamily(new ReadCommand(tablename, key, columnFamily, superColumnNames)); if (cfamily == null) { @@ -510,10 +526,11 @@ } } - public boolean batch_insert_superColumn_blocking(batch_mutation_super_t batchMutationSuper) + public boolean batch_insert_superColumn_blocking(batch_mutation_super_t batchMutationSuper) throws InvalidRequestException { logger_.debug("batch_insert_SuperColumn_blocking"); RowMutation rm = RowMutation.getRowMutation(batchMutationSuper); + validateCommand(rm.key(), rm.table(), rm.columnFamilyNames().toArray(new String[0])); return StorageProxy.insertBlocking(rm); } @@ -521,6 +538,15 @@ { logger_.debug("batch_insert_SuperColumn"); RowMutation rm = RowMutation.getRowMutation(batchMutationSuper); + try + { + validateCommand(rm.key(), rm.table(), rm.columnFamilyNames().toArray(new String[0])); + } + catch (InvalidRequestException e) + { + // it would be confusing to declare an exception in thrift that can't be returned to the client + throw new RuntimeException(e); + } StorageProxy.insert(rm); } Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/CqlResult_t.java URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/CqlResult_t.java?rev=768381&r1=768380&r2=768381&view=diff ============================================================================== --- incubator/cassandra/trunk/src/org/apache/cassandra/service/CqlResult_t.java (original) +++ incubator/cassandra/trunk/src/org/apache/cassandra/service/CqlResult_t.java Fri Apr 24 17:52:07 2009 @@ -299,25 +299,25 @@ case RESULTSET: if (field.type == TType.LIST) { { - TList _list40 = iprot.readListBegin(); - this.resultSet = new ArrayList<Map<String,String>>(_list40.size); - for (int _i41 = 0; _i41 < _list40.size; ++_i41) + TList _list22 = iprot.readListBegin(); + this.resultSet = new ArrayList<Map<String,String>>(_list22.size); + for (int _i23 = 0; _i23 < _list22.size; ++_i23) { - Map<String,String> _elem42; + Map<String,String> _elem24; { - TMap _map43 = iprot.readMapBegin(); - _elem42 = new HashMap<String,String>(2*_map43.size); - for (int _i44 = 0; _i44 < _map43.size; ++_i44) + TMap _map25 = iprot.readMapBegin(); + _elem24 = new HashMap<String,String>(2*_map25.size); + for (int _i26 = 0; _i26 < _map25.size; ++_i26) { - String _key45; - String _val46; - _key45 = iprot.readString(); - _val46 = iprot.readString(); - _elem42.put(_key45, _val46); + String _key27; + String _val28; + _key27 = iprot.readString(); + _val28 = iprot.readString(); + _elem24.put(_key27, _val28); } iprot.readMapEnd(); } - this.resultSet.add(_elem42); + this.resultSet.add(_elem24); } iprot.readListEnd(); } @@ -355,12 +355,12 @@ oprot.writeFieldBegin(RESULT_SET_FIELD_DESC); { oprot.writeListBegin(new TList(TType.MAP, this.resultSet.size())); - for (Map<String,String> _iter47 : this.resultSet) { + for (Map<String,String> _iter29 : this.resultSet) { { - oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, _iter47.size())); - for (Map.Entry<String, String> _iter48 : _iter47.entrySet()) { - oprot.writeString(_iter48.getKey()); - oprot.writeString(_iter48.getValue()); + oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, _iter29.size())); + for (Map.Entry<String, String> _iter30 : _iter29.entrySet()) { + oprot.writeString(_iter30.getKey()); + oprot.writeString(_iter30.getValue()); } oprot.writeMapEnd(); } Copied: incubator/cassandra/trunk/src/org/apache/cassandra/service/InvalidRequestException.java (from r768137, incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraException.java) URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/InvalidRequestException.java?p2=incubator/cassandra/trunk/src/org/apache/cassandra/service/InvalidRequestException.java&p1=incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraException.java&r1=768137&r2=768381&rev=768381&view=diff ============================================================================== --- incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraException.java (original) +++ incubator/cassandra/trunk/src/org/apache/cassandra/service/InvalidRequestException.java Fri Apr 24 17:52:07 2009 @@ -18,79 +18,79 @@ import org.apache.thrift.protocol.*; import org.apache.thrift.transport.*; -public class CassandraException extends Exception implements TBase, java.io.Serializable, Cloneable { - private static final TStruct STRUCT_DESC = new TStruct("CassandraException"); - private static final TField ERROR_FIELD_DESC = new TField("error", TType.STRING, (short)1); +public class InvalidRequestException extends Exception implements TBase, java.io.Serializable, Cloneable { + private static final TStruct STRUCT_DESC = new TStruct("InvalidRequestException"); + private static final TField WHY_FIELD_DESC = new TField("why", TType.STRING, (short)1); - public String error; - public static final int ERROR = 1; + public String why; + public static final int WHY = 1; private final Isset __isset = new Isset(); private static final class Isset implements java.io.Serializable { - public boolean error = false; + public boolean why = false; } public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{ - put(ERROR, new FieldMetaData("error", TFieldRequirementType.DEFAULT, + put(WHY, new FieldMetaData("why", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.STRING))); }}); static { - FieldMetaData.addStructMetaDataMap(CassandraException.class, metaDataMap); + FieldMetaData.addStructMetaDataMap(InvalidRequestException.class, metaDataMap); } - public CassandraException() { + public InvalidRequestException() { } - public CassandraException( - String error) + public InvalidRequestException( + String why) { this(); - this.error = error; - this.__isset.error = (error != null); + this.why = why; + this.__isset.why = (why != null); } /** * Performs a deep copy on <i>other</i>. */ - public CassandraException(CassandraException other) { - __isset.error = other.__isset.error; - if (other.error != null) { - this.error = other.error; + public InvalidRequestException(InvalidRequestException other) { + __isset.why = other.__isset.why; + if (other.why != null) { + this.why = other.why; } } @Override - public CassandraException clone() { - return new CassandraException(this); + public InvalidRequestException clone() { + return new InvalidRequestException(this); } - public String getError() { - return this.error; + public String getWhy() { + return this.why; } - public void setError(String error) { - this.error = error; - this.__isset.error = (error != null); + public void setWhy(String why) { + this.why = why; + this.__isset.why = (why != null); } - public void unsetError() { - this.__isset.error = false; + public void unsetWhy() { + this.__isset.why = false; } - // Returns true if field error is set (has been asigned a value) and false otherwise - public boolean isSetError() { - return this.__isset.error; + // Returns true if field why is set (has been asigned a value) and false otherwise + public boolean isSetWhy() { + return this.__isset.why; } - public void setErrorIsSet(boolean value) { - this.__isset.error = value; + public void setWhyIsSet(boolean value) { + this.__isset.why = value; } public void setFieldValue(int fieldID, Object value) { switch (fieldID) { - case ERROR: - setError((String)value); + case WHY: + setWhy((String)value); break; default: @@ -100,8 +100,8 @@ public Object getFieldValue(int fieldID) { switch (fieldID) { - case ERROR: - return getError(); + case WHY: + return getWhy(); default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); @@ -111,8 +111,8 @@ // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise public boolean isSet(int fieldID) { switch (fieldID) { - case ERROR: - return this.__isset.error; + case WHY: + return this.__isset.why; default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } @@ -122,21 +122,21 @@ public boolean equals(Object that) { if (that == null) return false; - if (that instanceof CassandraException) - return this.equals((CassandraException)that); + if (that instanceof InvalidRequestException) + return this.equals((InvalidRequestException)that); return false; } - public boolean equals(CassandraException that) { + public boolean equals(InvalidRequestException that) { if (that == null) return false; - boolean this_present_error = true && (this.error != null); - boolean that_present_error = true && (that.error != null); - if (this_present_error || that_present_error) { - if (!(this_present_error && that_present_error)) + boolean this_present_why = true && (this.why != null); + boolean that_present_why = true && (that.why != null); + if (this_present_why || that_present_why) { + if (!(this_present_why && that_present_why)) return false; - if (!this.error.equals(that.error)) + if (!this.why.equals(that.why)) return false; } @@ -159,10 +159,10 @@ } switch (field.id) { - case ERROR: + case WHY: if (field.type == TType.STRING) { - this.error = iprot.readString(); - this.__isset.error = true; + this.why = iprot.readString(); + this.__isset.why = true; } else { TProtocolUtil.skip(iprot, field.type); } @@ -184,9 +184,9 @@ validate(); oprot.writeStructBegin(STRUCT_DESC); - if (this.error != null) { - oprot.writeFieldBegin(ERROR_FIELD_DESC); - oprot.writeString(this.error); + if (this.why != null) { + oprot.writeFieldBegin(WHY_FIELD_DESC); + oprot.writeString(this.why); oprot.writeFieldEnd(); } oprot.writeFieldStop(); @@ -195,12 +195,12 @@ @Override public String toString() { - StringBuilder sb = new StringBuilder("CassandraException("); + StringBuilder sb = new StringBuilder("InvalidRequestException("); boolean first = true; if (!first) sb.append(", "); - sb.append("error:"); - sb.append(this.error); + sb.append("why:"); + sb.append(this.why); first = false; sb.append(")"); return sb.toString(); Added: incubator/cassandra/trunk/src/org/apache/cassandra/service/NotFoundException.java URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/NotFoundException.java?rev=768381&view=auto ============================================================================== --- incubator/cassandra/trunk/src/org/apache/cassandra/service/NotFoundException.java (added) +++ incubator/cassandra/trunk/src/org/apache/cassandra/service/NotFoundException.java Fri Apr 24 17:52:07 2009 @@ -0,0 +1,135 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + */ +package org.apache.cassandra.service; + +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Collections; +import org.apache.thrift.*; +import org.apache.thrift.meta_data.*; + +import org.apache.thrift.protocol.*; +import org.apache.thrift.transport.*; + +public class NotFoundException extends Exception implements TBase, java.io.Serializable, Cloneable { + private static final TStruct STRUCT_DESC = new TStruct("NotFoundException"); + + public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{ + }}); + + static { + FieldMetaData.addStructMetaDataMap(NotFoundException.class, metaDataMap); + } + + public NotFoundException() { + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public NotFoundException(NotFoundException other) { + } + + @Override + public NotFoundException clone() { + return new NotFoundException(this); + } + + public void setFieldValue(int fieldID, Object value) { + switch (fieldID) { + default: + throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); + } + } + + public Object getFieldValue(int fieldID) { + switch (fieldID) { + default: + throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); + } + } + + // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise + public boolean isSet(int fieldID) { + switch (fieldID) { + default: + throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); + } + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof NotFoundException) + return this.equals((NotFoundException)that); + return false; + } + + public boolean equals(NotFoundException that) { + if (that == null) + return false; + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public void read(TProtocol iprot) throws TException { + TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == TType.STOP) { + break; + } + switch (field.id) + { + default: + TProtocolUtil.skip(iprot, field.type); + break; + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + + // check for required fields of primitive type, which can't be checked in the validate method + validate(); + } + + public void write(TProtocol oprot) throws TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("NotFoundException("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws TException { + // check for required fields + // check that fields of type enum have valid values + } + +} + Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageProxy.java URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageProxy.java?rev=768381&r1=768380&r2=768381&view=diff ============================================================================== --- incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageProxy.java (original) +++ incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageProxy.java Fri Apr 24 17:52:07 2009 @@ -36,7 +36,6 @@ import org.apache.cassandra.db.RowMutation; import org.apache.cassandra.db.Table; import org.apache.cassandra.db.TouchMessage; -import org.apache.cassandra.db.ColumnFamilyNotDefinedException; import org.apache.cassandra.io.DataInputBuffer; import org.apache.cassandra.net.EndPoint; import org.apache.cassandra.net.IAsyncResult; @@ -88,13 +87,14 @@ */ public static void insert(RowMutation rm) { + // TODO check for valid Table, ColumnFamily + /* * Get the N nodes from storage service where the data needs to be * replicated * Construct a message for write * Send them asynchronously to the replicas. */ - assert rm.key() != null; try { @@ -116,8 +116,6 @@ public static boolean insertBlocking(RowMutation rm) { - assert rm.key() != null; - try { Message message = rm.makeRowMutationMessage(); @@ -308,9 +306,8 @@ * a specific set of column names from a given column family. */ public static Row readProtocol(ReadCommand command, StorageService.ConsistencyLevel consistencyLevel) - throws IOException, ColumnFamilyNotDefinedException, TimeoutException + throws IOException, TimeoutException { - assert command.key != null; long startTime = System.currentTimeMillis(); Row row = null; EndPoint[] endpoints = StorageService.instance().getNStorageEndPoint(command.key); @@ -622,7 +619,7 @@ * one of the other replicas (in the same data center if possible) till we get the data. In the event we get * the data we perform consistency checks and figure out if any repairs need to be done to the replicas. */ - private static Row weakReadLocal(ReadCommand command) throws IOException, ColumnFamilyNotDefinedException + private static Row weakReadLocal(ReadCommand command) throws IOException { logger_.debug("weakreadlocal for " + command); List<EndPoint> endpoints = StorageService.instance().getNLiveStorageEndPoint(command.key); Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_super_t.java URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_super_t.java?rev=768381&r1=768380&r2=768381&view=diff ============================================================================== --- incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_super_t.java (original) +++ incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_super_t.java Fri Apr 24 17:52:07 2009 @@ -23,7 +23,6 @@ private static final TField TABLE_FIELD_DESC = new TField("table", TType.STRING, (short)1); private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)2); private static final TField CFMAP_FIELD_DESC = new TField("cfmap", TType.MAP, (short)3); - private static final TField CFMAPDEL_FIELD_DESC = new TField("cfmapdel", TType.MAP, (short)4); public String table; public static final int TABLE = 1; @@ -31,15 +30,12 @@ public static final int KEY = 2; public Map<String,List<superColumn_t>> cfmap; public static final int CFMAP = 3; - public Map<String,List<superColumn_t>> cfmapdel; - public static final int CFMAPDEL = 4; private final Isset __isset = new Isset(); private static final class Isset implements java.io.Serializable { public boolean table = false; public boolean key = false; public boolean cfmap = false; - public boolean cfmapdel = false; } public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{ @@ -49,8 +45,6 @@ new FieldValueMetaData(TType.STRING))); put(CFMAP, new FieldMetaData("cfmap", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.MAP))); - put(CFMAPDEL, new FieldMetaData("cfmapdel", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.MAP))); }}); static { @@ -63,8 +57,7 @@ public batch_mutation_super_t( String table, String key, - Map<String,List<superColumn_t>> cfmap, - Map<String,List<superColumn_t>> cfmapdel) + Map<String,List<superColumn_t>> cfmap) { this(); this.table = table; @@ -73,8 +66,6 @@ this.__isset.key = (key != null); this.cfmap = cfmap; this.__isset.cfmap = (cfmap != null); - this.cfmapdel = cfmapdel; - this.__isset.cfmapdel = (cfmapdel != null); } /** @@ -93,10 +84,6 @@ if (other.cfmap != null) { this.cfmap = other.cfmap; } - __isset.cfmapdel = other.__isset.cfmapdel; - if (other.cfmapdel != null) { - this.cfmapdel = other.cfmapdel; - } } @Override @@ -183,41 +170,6 @@ this.__isset.cfmap = value; } - public int getCfmapdelSize() { - return (this.cfmapdel == null) ? 0 : this.cfmapdel.size(); - } - - public void putToCfmapdel(String key, List<superColumn_t> val) { - if (this.cfmapdel == null) { - this.cfmapdel = new HashMap<String,List<superColumn_t>>(); - } - this.cfmapdel.put(key, val); - this.__isset.cfmapdel = true; - } - - public Map<String,List<superColumn_t>> getCfmapdel() { - return this.cfmapdel; - } - - public void setCfmapdel(Map<String,List<superColumn_t>> cfmapdel) { - this.cfmapdel = cfmapdel; - this.__isset.cfmapdel = (cfmapdel != null); - } - - public void unsetCfmapdel() { - this.cfmapdel = null; - this.__isset.cfmapdel = false; - } - - // Returns true if field cfmapdel is set (has been asigned a value) and false otherwise - public boolean isSetCfmapdel() { - return this.__isset.cfmapdel; - } - - public void setCfmapdelIsSet(boolean value) { - this.__isset.cfmapdel = value; - } - public void setFieldValue(int fieldID, Object value) { switch (fieldID) { case TABLE: @@ -232,10 +184,6 @@ setCfmap((Map<String,List<superColumn_t>>)value); break; - case CFMAPDEL: - setCfmapdel((Map<String,List<superColumn_t>>)value); - break; - default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } @@ -252,9 +200,6 @@ case CFMAP: return getCfmap(); - case CFMAPDEL: - return getCfmapdel(); - default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } @@ -269,8 +214,6 @@ return this.__isset.key; case CFMAP: return this.__isset.cfmap; - case CFMAPDEL: - return this.__isset.cfmapdel; default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } @@ -316,15 +259,6 @@ return false; } - boolean this_present_cfmapdel = true && (this.cfmapdel != null); - boolean that_present_cfmapdel = true && (that.cfmapdel != null); - if (this_present_cfmapdel || that_present_cfmapdel) { - if (!(this_present_cfmapdel && that_present_cfmapdel)) - return false; - if (!this.cfmapdel.equals(that.cfmapdel)) - return false; - } - return true; } @@ -363,26 +297,26 @@ case CFMAP: if (field.type == TType.MAP) { { - TMap _map22 = iprot.readMapBegin(); - this.cfmap = new HashMap<String,List<superColumn_t>>(2*_map22.size); - for (int _i23 = 0; _i23 < _map22.size; ++_i23) + TMap _map13 = iprot.readMapBegin(); + this.cfmap = new HashMap<String,List<superColumn_t>>(2*_map13.size); + for (int _i14 = 0; _i14 < _map13.size; ++_i14) { - String _key24; - List<superColumn_t> _val25; - _key24 = iprot.readString(); + String _key15; + List<superColumn_t> _val16; + _key15 = iprot.readString(); { - TList _list26 = iprot.readListBegin(); - _val25 = new ArrayList<superColumn_t>(_list26.size); - for (int _i27 = 0; _i27 < _list26.size; ++_i27) + TList _list17 = iprot.readListBegin(); + _val16 = new ArrayList<superColumn_t>(_list17.size); + for (int _i18 = 0; _i18 < _list17.size; ++_i18) { - superColumn_t _elem28; - _elem28 = new superColumn_t(); - _elem28.read(iprot); - _val25.add(_elem28); + superColumn_t _elem19; + _elem19 = new superColumn_t(); + _elem19.read(iprot); + _val16.add(_elem19); } iprot.readListEnd(); } - this.cfmap.put(_key24, _val25); + this.cfmap.put(_key15, _val16); } iprot.readMapEnd(); } @@ -391,37 +325,6 @@ TProtocolUtil.skip(iprot, field.type); } break; - case CFMAPDEL: - if (field.type == TType.MAP) { - { - TMap _map29 = iprot.readMapBegin(); - this.cfmapdel = new HashMap<String,List<superColumn_t>>(2*_map29.size); - for (int _i30 = 0; _i30 < _map29.size; ++_i30) - { - String _key31; - List<superColumn_t> _val32; - _key31 = iprot.readString(); - { - TList _list33 = iprot.readListBegin(); - _val32 = new ArrayList<superColumn_t>(_list33.size); - for (int _i34 = 0; _i34 < _list33.size; ++_i34) - { - superColumn_t _elem35; - _elem35 = new superColumn_t(); - _elem35.read(iprot); - _val32.add(_elem35); - } - iprot.readListEnd(); - } - this.cfmapdel.put(_key31, _val32); - } - iprot.readMapEnd(); - } - this.__isset.cfmapdel = true; - } else { - TProtocolUtil.skip(iprot, field.type); - } - break; default: TProtocolUtil.skip(iprot, field.type); break; @@ -453,30 +356,12 @@ oprot.writeFieldBegin(CFMAP_FIELD_DESC); { oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, this.cfmap.size())); - for (Map.Entry<String, List<superColumn_t>> _iter36 : this.cfmap.entrySet()) { - oprot.writeString(_iter36.getKey()); + for (Map.Entry<String, List<superColumn_t>> _iter20 : this.cfmap.entrySet()) { + oprot.writeString(_iter20.getKey()); { - oprot.writeListBegin(new TList(TType.STRUCT, _iter36.getValue().size())); - for (superColumn_t _iter37 : _iter36.getValue()) { - _iter37.write(oprot); - } - oprot.writeListEnd(); - } - } - oprot.writeMapEnd(); - } - oprot.writeFieldEnd(); - } - if (this.cfmapdel != null) { - oprot.writeFieldBegin(CFMAPDEL_FIELD_DESC); - { - oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, this.cfmapdel.size())); - for (Map.Entry<String, List<superColumn_t>> _iter38 : this.cfmapdel.entrySet()) { - oprot.writeString(_iter38.getKey()); - { - oprot.writeListBegin(new TList(TType.STRUCT, _iter38.getValue().size())); - for (superColumn_t _iter39 : _iter38.getValue()) { - _iter39.write(oprot); + oprot.writeListBegin(new TList(TType.STRUCT, _iter20.getValue().size())); + for (superColumn_t _iter21 : _iter20.getValue()) { + _iter21.write(oprot); } oprot.writeListEnd(); } @@ -506,10 +391,6 @@ sb.append("cfmap:"); sb.append(this.cfmap); first = false; - if (!first) sb.append(", "); - sb.append("cfmapdel:"); - sb.append(this.cfmapdel); - first = false; sb.append(")"); return sb.toString(); } Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_t.java URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_t.java?rev=768381&r1=768380&r2=768381&view=diff ============================================================================== --- incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_t.java (original) +++ incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_t.java Fri Apr 24 17:52:07 2009 @@ -23,7 +23,6 @@ private static final TField TABLE_FIELD_DESC = new TField("table", TType.STRING, (short)1); private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)2); private static final TField CFMAP_FIELD_DESC = new TField("cfmap", TType.MAP, (short)3); - private static final TField CFMAPDEL_FIELD_DESC = new TField("cfmapdel", TType.MAP, (short)4); public String table; public static final int TABLE = 1; @@ -31,15 +30,12 @@ public static final int KEY = 2; public Map<String,List<column_t>> cfmap; public static final int CFMAP = 3; - public Map<String,List<column_t>> cfmapdel; - public static final int CFMAPDEL = 4; private final Isset __isset = new Isset(); private static final class Isset implements java.io.Serializable { public boolean table = false; public boolean key = false; public boolean cfmap = false; - public boolean cfmapdel = false; } public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{ @@ -49,8 +45,6 @@ new FieldValueMetaData(TType.STRING))); put(CFMAP, new FieldMetaData("cfmap", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.MAP))); - put(CFMAPDEL, new FieldMetaData("cfmapdel", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.MAP))); }}); static { @@ -63,8 +57,7 @@ public batch_mutation_t( String table, String key, - Map<String,List<column_t>> cfmap, - Map<String,List<column_t>> cfmapdel) + Map<String,List<column_t>> cfmap) { this(); this.table = table; @@ -73,8 +66,6 @@ this.__isset.key = (key != null); this.cfmap = cfmap; this.__isset.cfmap = (cfmap != null); - this.cfmapdel = cfmapdel; - this.__isset.cfmapdel = (cfmapdel != null); } /** @@ -93,10 +84,6 @@ if (other.cfmap != null) { this.cfmap = other.cfmap; } - __isset.cfmapdel = other.__isset.cfmapdel; - if (other.cfmapdel != null) { - this.cfmapdel = other.cfmapdel; - } } @Override @@ -183,41 +170,6 @@ this.__isset.cfmap = value; } - public int getCfmapdelSize() { - return (this.cfmapdel == null) ? 0 : this.cfmapdel.size(); - } - - public void putToCfmapdel(String key, List<column_t> val) { - if (this.cfmapdel == null) { - this.cfmapdel = new HashMap<String,List<column_t>>(); - } - this.cfmapdel.put(key, val); - this.__isset.cfmapdel = true; - } - - public Map<String,List<column_t>> getCfmapdel() { - return this.cfmapdel; - } - - public void setCfmapdel(Map<String,List<column_t>> cfmapdel) { - this.cfmapdel = cfmapdel; - this.__isset.cfmapdel = (cfmapdel != null); - } - - public void unsetCfmapdel() { - this.cfmapdel = null; - this.__isset.cfmapdel = false; - } - - // Returns true if field cfmapdel is set (has been asigned a value) and false otherwise - public boolean isSetCfmapdel() { - return this.__isset.cfmapdel; - } - - public void setCfmapdelIsSet(boolean value) { - this.__isset.cfmapdel = value; - } - public void setFieldValue(int fieldID, Object value) { switch (fieldID) { case TABLE: @@ -232,10 +184,6 @@ setCfmap((Map<String,List<column_t>>)value); break; - case CFMAPDEL: - setCfmapdel((Map<String,List<column_t>>)value); - break; - default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } @@ -252,9 +200,6 @@ case CFMAP: return getCfmap(); - case CFMAPDEL: - return getCfmapdel(); - default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } @@ -269,8 +214,6 @@ return this.__isset.key; case CFMAP: return this.__isset.cfmap; - case CFMAPDEL: - return this.__isset.cfmapdel; default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } @@ -316,15 +259,6 @@ return false; } - boolean this_present_cfmapdel = true && (this.cfmapdel != null); - boolean that_present_cfmapdel = true && (that.cfmapdel != null); - if (this_present_cfmapdel || that_present_cfmapdel) { - if (!(this_present_cfmapdel && that_present_cfmapdel)) - return false; - if (!this.cfmapdel.equals(that.cfmapdel)) - return false; - } - return true; } @@ -391,37 +325,6 @@ TProtocolUtil.skip(iprot, field.type); } break; - case CFMAPDEL: - if (field.type == TType.MAP) { - { - TMap _map7 = iprot.readMapBegin(); - this.cfmapdel = new HashMap<String,List<column_t>>(2*_map7.size); - for (int _i8 = 0; _i8 < _map7.size; ++_i8) - { - String _key9; - List<column_t> _val10; - _key9 = iprot.readString(); - { - TList _list11 = iprot.readListBegin(); - _val10 = new ArrayList<column_t>(_list11.size); - for (int _i12 = 0; _i12 < _list11.size; ++_i12) - { - column_t _elem13; - _elem13 = new column_t(); - _elem13.read(iprot); - _val10.add(_elem13); - } - iprot.readListEnd(); - } - this.cfmapdel.put(_key9, _val10); - } - iprot.readMapEnd(); - } - this.__isset.cfmapdel = true; - } else { - TProtocolUtil.skip(iprot, field.type); - } - break; default: TProtocolUtil.skip(iprot, field.type); break; @@ -453,30 +356,12 @@ oprot.writeFieldBegin(CFMAP_FIELD_DESC); { oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, this.cfmap.size())); - for (Map.Entry<String, List<column_t>> _iter14 : this.cfmap.entrySet()) { - oprot.writeString(_iter14.getKey()); + for (Map.Entry<String, List<column_t>> _iter7 : this.cfmap.entrySet()) { + oprot.writeString(_iter7.getKey()); { - oprot.writeListBegin(new TList(TType.STRUCT, _iter14.getValue().size())); - for (column_t _iter15 : _iter14.getValue()) { - _iter15.write(oprot); - } - oprot.writeListEnd(); - } - } - oprot.writeMapEnd(); - } - oprot.writeFieldEnd(); - } - if (this.cfmapdel != null) { - oprot.writeFieldBegin(CFMAPDEL_FIELD_DESC); - { - oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, this.cfmapdel.size())); - for (Map.Entry<String, List<column_t>> _iter16 : this.cfmapdel.entrySet()) { - oprot.writeString(_iter16.getKey()); - { - oprot.writeListBegin(new TList(TType.STRUCT, _iter16.getValue().size())); - for (column_t _iter17 : _iter16.getValue()) { - _iter17.write(oprot); + oprot.writeListBegin(new TList(TType.STRUCT, _iter7.getValue().size())); + for (column_t _iter8 : _iter7.getValue()) { + _iter8.write(oprot); } oprot.writeListEnd(); } @@ -506,10 +391,6 @@ sb.append("cfmap:"); sb.append(this.cfmap); first = false; - if (!first) sb.append(", "); - sb.append("cfmapdel:"); - sb.append(this.cfmapdel); - first = false; sb.append(")"); return sb.toString(); } Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/superColumn_t.java URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/superColumn_t.java?rev=768381&r1=768380&r2=768381&view=diff ============================================================================== --- incubator/cassandra/trunk/src/org/apache/cassandra/service/superColumn_t.java (original) +++ incubator/cassandra/trunk/src/org/apache/cassandra/service/superColumn_t.java Fri Apr 24 17:52:07 2009 @@ -245,14 +245,14 @@ case COLUMNS: if (field.type == TType.LIST) { { - TList _list18 = iprot.readListBegin(); - this.columns = new ArrayList<column_t>(_list18.size); - for (int _i19 = 0; _i19 < _list18.size; ++_i19) + TList _list9 = iprot.readListBegin(); + this.columns = new ArrayList<column_t>(_list9.size); + for (int _i10 = 0; _i10 < _list9.size; ++_i10) { - column_t _elem20; - _elem20 = new column_t(); - _elem20.read(iprot); - this.columns.add(_elem20); + column_t _elem11; + _elem11 = new column_t(); + _elem11.read(iprot); + this.columns.add(_elem11); } iprot.readListEnd(); } @@ -287,8 +287,8 @@ oprot.writeFieldBegin(COLUMNS_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRUCT, this.columns.size())); - for (column_t _iter21 : this.columns) { - _iter21.write(oprot); + for (column_t _iter12 : this.columns) { + _iter12.write(oprot); } oprot.writeListEnd(); } Modified: incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=768381&r1=768380&r2=768381&view=diff ============================================================================== --- incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java (original) +++ incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java Fri Apr 24 17:52:07 2009 @@ -36,7 +36,7 @@ } @Test - public void testNameSort() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException + public void testNameSort() throws IOException, ExecutionException, InterruptedException { Table table = Table.open("Table1"); @@ -75,7 +75,7 @@ } @Test - public void testTimeSort() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException + public void testTimeSort() throws IOException, ExecutionException, InterruptedException { Table table = Table.open("Table1"); @@ -135,7 +135,7 @@ } } - private void validateTimeSort(Table table) throws IOException, ColumnFamilyNotDefinedException + private void validateTimeSort(Table table) throws IOException { for (int i = 900; i < 1000; ++i) { @@ -154,8 +154,7 @@ } } - private void validateNameSort(Table table) - throws ColumnFamilyNotDefinedException, IOException + private void validateNameSort(Table table) throws IOException { for (int i = 900; i < 1000; ++i) { @@ -191,7 +190,7 @@ } @Test - public void testRemoveColumn() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException + public void testRemoveColumn() throws IOException, ExecutionException, InterruptedException { Table table = Table.open("Table1"); ColumnFamilyStore store = table.getColumnFamilyStore("Standard1"); @@ -214,7 +213,7 @@ } @Test - public void testRemoveSubColumn() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException + public void testRemoveSubColumn() throws IOException, ExecutionException, InterruptedException { Table table = Table.open("Table1"); ColumnFamilyStore store = table.getColumnFamilyStore("Super1"); @@ -237,7 +236,7 @@ } @Test - public void testRemoveSuperColumn() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException + public void testRemoveSuperColumn() throws IOException, ExecutionException, InterruptedException { Table table = Table.open("Table1"); ColumnFamilyStore store = table.getColumnFamilyStore("Super1"); @@ -266,7 +265,7 @@ } @Test - public void testRemoveColumnFamily() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException + public void testRemoveColumnFamily() throws IOException, ExecutionException, InterruptedException { Table table = Table.open("Table1"); ColumnFamilyStore store = table.getColumnFamilyStore("Standard1"); @@ -289,7 +288,7 @@ } @Test - public void testRemoveColumnFamilyWithFlush1() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException + public void testRemoveColumnFamilyWithFlush1() throws IOException, ExecutionException, InterruptedException { Table table = Table.open("Table1"); ColumnFamilyStore store = table.getColumnFamilyStore("Standard1"); @@ -314,7 +313,7 @@ } @Test - public void testRemoveColumnFamilyWithFlush2() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException + public void testRemoveColumnFamilyWithFlush2() throws IOException, ExecutionException, InterruptedException { Table table = Table.open("Table1"); ColumnFamilyStore store = table.getColumnFamilyStore("Standard1"); @@ -390,7 +389,7 @@ } @Test - public void testCompaction() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException + public void testCompaction() throws IOException, ExecutionException, InterruptedException { Table table = Table.open("Table1"); ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
