Updated Branches: refs/heads/trunk ec361ab00 -> b153d4564
Upgrade thrift version to 0.9.0 Patch by jfarrell; reviewed by tjake for CASSANDRA-3719 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b153d456 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b153d456 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b153d456 Branch: refs/heads/trunk Commit: b153d45644b1af0e645fcb3cdc1c835949289e41 Parents: ec361ab Author: Jake Luciani <j...@apache.org> Authored: Mon Jan 14 15:14:04 2013 -0500 Committer: Jake Luciani <j...@apache.org> Committed: Mon Jan 14 15:14:04 2013 -0500 ---------------------------------------------------------------------- CHANGES.txt | 2 +- build.xml | 2 +- .../cassandra/thrift/AuthenticationException.java | 133 +- .../cassandra/thrift/AuthenticationRequest.java | 189 +- .../cassandra/thrift/AuthorizationException.java | 133 +- .../org/apache/cassandra/thrift/Cassandra.java |16484 ++++++++++----- .../org/apache/cassandra/thrift/CfDef.java | 1751 +- .../org/apache/cassandra/thrift/CfSplit.java | 203 +- .../org/apache/cassandra/thrift/Column.java | 271 +- .../org/apache/cassandra/thrift/ColumnDef.java | 344 +- .../cassandra/thrift/ColumnOrSuperColumn.java | 295 +- .../org/apache/cassandra/thrift/ColumnParent.java | 176 +- .../org/apache/cassandra/thrift/ColumnPath.java | 217 +- .../org/apache/cassandra/thrift/Compression.java | 3 +- .../apache/cassandra/thrift/ConsistencyLevel.java | 3 +- .../org/apache/cassandra/thrift/Constants.java | 49 - .../org/apache/cassandra/thrift/CounterColumn.java | 175 +- .../cassandra/thrift/CounterSuperColumn.java | 211 +- .../org/apache/cassandra/thrift/CqlMetadata.java | 331 +- .../apache/cassandra/thrift/CqlPreparedResult.java | 368 +- .../org/apache/cassandra/thrift/CqlResult.java | 326 +- .../org/apache/cassandra/thrift/CqlResultType.java | 3 +- .../org/apache/cassandra/thrift/CqlRow.java | 211 +- .../org/apache/cassandra/thrift/Deletion.java | 246 +- .../apache/cassandra/thrift/EndpointDetails.java | 218 +- .../org/apache/cassandra/thrift/IndexClause.java | 255 +- .../apache/cassandra/thrift/IndexExpression.java | 187 +- .../org/apache/cassandra/thrift/IndexOperator.java | 3 +- .../org/apache/cassandra/thrift/IndexType.java | 3 +- .../cassandra/thrift/InvalidRequestException.java | 133 +- .../org/apache/cassandra/thrift/KeyCount.java | 175 +- .../org/apache/cassandra/thrift/KeyRange.java | 408 +- .../org/apache/cassandra/thrift/KeySlice.java | 211 +- .../org/apache/cassandra/thrift/KsDef.java | 437 +- .../org/apache/cassandra/thrift/Mutation.java | 201 +- .../apache/cassandra/thrift/NotFoundException.java | 104 +- .../thrift/SchemaDisagreementException.java | 104 +- .../apache/cassandra/thrift/SlicePredicate.java | 244 +- .../org/apache/cassandra/thrift/SliceRange.java | 240 +- .../org/apache/cassandra/thrift/SuperColumn.java | 211 +- .../apache/cassandra/thrift/TimedOutException.java | 204 +- .../org/apache/cassandra/thrift/TokenRange.java | 423 +- .../cassandra/thrift/UnavailableException.java | 104 +- .../cassandra/thrift/cassandraConstants.java | 59 + lib/libthrift-0.7.0.jar | Bin 301547 -> 0 bytes lib/libthrift-0.9.0.jar | Bin 0 -> 347531 bytes lib/licenses/libthrift-0.7.txt | 202 - lib/licenses/libthrift-0.9.txt | 202 + src/java/org/apache/cassandra/cli/CliMain.java | 8 +- src/java/org/apache/cassandra/db/SystemTable.java | 4 +- .../cassandra/hadoop/ColumnFamilyInputFormat.java | 8 +- .../cassandra/hadoop/pig/CassandraStorage.java | 6 +- .../apache/cassandra/service/StorageService.java | 4 +- .../apache/cassandra/thrift/CassandraServer.java | 2 +- .../apache/cassandra/thrift/CustomTHsHaServer.java | 304 +- src/java/org/apache/cassandra/tools/Shuffle.java | 8 +- 56 files changed, 18037 insertions(+), 8761 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/b153d456/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index d71b77c..93d7ecd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,7 +3,7 @@ * add default_tim_to_live (CASSANDRA-3974) * add memtable_flush_period_in_ms (CASSANDRA-4237) * replace supercolumns internally by composites (CASSANDRA-3237) - + * upgrade thrift to 0.9.0 (CASSANDRA-3719) 1.2.1 * add inter_dc_tcp_nodelay setting (CASSANDRA-5148) http://git-wip-us.apache.org/repos/asf/cassandra/blob/b153d456/build.xml ---------------------------------------------------------------------- diff --git a/build.xml b/build.xml index eb681eb..d73abc7 100644 --- a/build.xml +++ b/build.xml @@ -356,7 +356,7 @@ <exclusion groupId="org.apache.velocity" artifactId="velocity"/> </dependency> - <dependency groupId="org.apache.thrift" artifactId="libthrift" version="0.7.0"/> + <dependency groupId="org.apache.thrift" artifactId="libthrift" version="0.9.0"/> <dependency groupId="com.thoughtworks.paranamer" artifactId="paranamer-ant" version="2.1"/> <dependency groupId="junit" artifactId="junit" version="4.6" /> http://git-wip-us.apache.org/repos/asf/cassandra/blob/b153d456/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationException.java ---------------------------------------------------------------------- diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationException.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationException.java index 5d88cd9..8127883 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationException.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationException.java @@ -1,7 +1,8 @@ /** - * Autogenerated by Thrift Compiler (0.7.0) + * 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; /* @@ -27,6 +28,15 @@ package org.apache.cassandra.thrift; 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; @@ -45,11 +55,17 @@ import org.slf4j.LoggerFactory; /** * invalid authentication request (invalid keyspace, user does not exist, or credentials invalid) */ -public class AuthenticationException extends Exception implements org.apache.thrift.TBase<AuthenticationException, AuthenticationException._Fields>, java.io.Serializable, Cloneable { +public class AuthenticationException extends TException implements org.apache.thrift.TBase<AuthenticationException, AuthenticationException._Fields>, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AuthenticationException"); private static final org.apache.thrift.protocol.TField WHY_FIELD_DESC = new org.apache.thrift.protocol.TField("why", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new AuthenticationExceptionStandardSchemeFactory()); + schemes.put(TupleScheme.class, new AuthenticationExceptionTupleSchemeFactory()); + } + public String why; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ @@ -111,7 +127,6 @@ public class AuthenticationException extends Exception implements org.apache.thr } // 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); @@ -271,44 +286,11 @@ public class AuthenticationException extends Exception implements org.apache.thr } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField field; - iprot.readStructBegin(); - while (true) - { - field = iprot.readFieldBegin(); - if (field.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (field.id) { - case 1: // WHY - if (field.type == org.apache.thrift.protocol.TType.STRING) { - this.why = iprot.readString(); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - validate(); + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (this.why != null) { - oprot.writeFieldBegin(WHY_FIELD_DESC); - oprot.writeString(this.why); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); } @Override @@ -332,6 +314,7 @@ public class AuthenticationException extends Exception implements org.apache.thr if (why == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'why' was not present! Struct: " + toString()); } + // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { @@ -350,5 +333,79 @@ public class AuthenticationException extends Exception implements org.apache.thr } } + private static class AuthenticationExceptionStandardSchemeFactory implements SchemeFactory { + public AuthenticationExceptionStandardScheme getScheme() { + return new AuthenticationExceptionStandardScheme(); + } + } + + private static class AuthenticationExceptionStandardScheme extends StandardScheme<AuthenticationException> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, AuthenticationException 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: // WHY + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.why = iprot.readString(); + struct.setWhyIsSet(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, AuthenticationException struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.why != null) { + oprot.writeFieldBegin(WHY_FIELD_DESC); + oprot.writeString(struct.why); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class AuthenticationExceptionTupleSchemeFactory implements SchemeFactory { + public AuthenticationExceptionTupleScheme getScheme() { + return new AuthenticationExceptionTupleScheme(); + } + } + + private static class AuthenticationExceptionTupleScheme extends TupleScheme<AuthenticationException> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, AuthenticationException struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.why); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, AuthenticationException struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.why = iprot.readString(); + struct.setWhyIsSet(true); + } + } + } http://git-wip-us.apache.org/repos/asf/cassandra/blob/b153d456/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationRequest.java ---------------------------------------------------------------------- diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationRequest.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationRequest.java index 0f68426..707c6b9 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationRequest.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationRequest.java @@ -1,7 +1,8 @@ /** - * Autogenerated by Thrift Compiler (0.7.0) + * 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; /* @@ -27,6 +28,15 @@ package org.apache.cassandra.thrift; 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; @@ -50,6 +60,12 @@ public class AuthenticationRequest implements org.apache.thrift.TBase<Authentica private static final org.apache.thrift.protocol.TField CREDENTIALS_FIELD_DESC = new org.apache.thrift.protocol.TField("credentials", org.apache.thrift.protocol.TType.MAP, (short)1); + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new AuthenticationRequestStandardSchemeFactory()); + schemes.put(TupleScheme.class, new AuthenticationRequestTupleSchemeFactory()); + } + public Map<String,String> credentials; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ @@ -111,7 +127,6 @@ public class AuthenticationRequest implements org.apache.thrift.TBase<Authentica } // 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); @@ -296,64 +311,11 @@ public class AuthenticationRequest implements org.apache.thrift.TBase<Authentica } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField field; - iprot.readStructBegin(); - while (true) - { - field = iprot.readFieldBegin(); - if (field.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (field.id) { - case 1: // CREDENTIALS - if (field.type == org.apache.thrift.protocol.TType.MAP) { - { - org.apache.thrift.protocol.TMap _map36 = iprot.readMapBegin(); - this.credentials = new HashMap<String,String>(2*_map36.size); - for (int _i37 = 0; _i37 < _map36.size; ++_i37) - { - String _key38; // required - String _val39; // required - _key38 = iprot.readString(); - _val39 = iprot.readString(); - this.credentials.put(_key38, _val39); - } - iprot.readMapEnd(); - } - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - validate(); + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (this.credentials != null) { - oprot.writeFieldBegin(CREDENTIALS_FIELD_DESC); - { - oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, this.credentials.size())); - for (Map.Entry<String, String> _iter40 : this.credentials.entrySet()) - { - oprot.writeString(_iter40.getKey()); - oprot.writeString(_iter40.getValue()); - } - oprot.writeMapEnd(); - } - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); } @Override @@ -377,6 +339,7 @@ public class AuthenticationRequest implements org.apache.thrift.TBase<Authentica if (credentials == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'credentials' was not present! Struct: " + toString()); } + // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { @@ -395,5 +358,117 @@ public class AuthenticationRequest implements org.apache.thrift.TBase<Authentica } } + private static class AuthenticationRequestStandardSchemeFactory implements SchemeFactory { + public AuthenticationRequestStandardScheme getScheme() { + return new AuthenticationRequestStandardScheme(); + } + } + + private static class AuthenticationRequestStandardScheme extends StandardScheme<AuthenticationRequest> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, AuthenticationRequest 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: // CREDENTIALS + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map72 = iprot.readMapBegin(); + struct.credentials = new HashMap<String,String>(2*_map72.size); + for (int _i73 = 0; _i73 < _map72.size; ++_i73) + { + String _key74; // required + String _val75; // required + _key74 = iprot.readString(); + _val75 = iprot.readString(); + struct.credentials.put(_key74, _val75); + } + iprot.readMapEnd(); + } + struct.setCredentialsIsSet(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, AuthenticationRequest struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.credentials != null) { + oprot.writeFieldBegin(CREDENTIALS_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.credentials.size())); + for (Map.Entry<String, String> _iter76 : struct.credentials.entrySet()) + { + oprot.writeString(_iter76.getKey()); + oprot.writeString(_iter76.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class AuthenticationRequestTupleSchemeFactory implements SchemeFactory { + public AuthenticationRequestTupleScheme getScheme() { + return new AuthenticationRequestTupleScheme(); + } + } + + private static class AuthenticationRequestTupleScheme extends TupleScheme<AuthenticationRequest> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, AuthenticationRequest struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + { + oprot.writeI32(struct.credentials.size()); + for (Map.Entry<String, String> _iter77 : struct.credentials.entrySet()) + { + oprot.writeString(_iter77.getKey()); + oprot.writeString(_iter77.getValue()); + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, AuthenticationRequest struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + { + org.apache.thrift.protocol.TMap _map78 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.credentials = new HashMap<String,String>(2*_map78.size); + for (int _i79 = 0; _i79 < _map78.size; ++_i79) + { + String _key80; // required + String _val81; // required + _key80 = iprot.readString(); + _val81 = iprot.readString(); + struct.credentials.put(_key80, _val81); + } + } + struct.setCredentialsIsSet(true); + } + } + } http://git-wip-us.apache.org/repos/asf/cassandra/blob/b153d456/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthorizationException.java ---------------------------------------------------------------------- diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthorizationException.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthorizationException.java index 76bc061..f3a8506 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthorizationException.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthorizationException.java @@ -1,7 +1,8 @@ /** - * Autogenerated by Thrift Compiler (0.7.0) + * 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; /* @@ -27,6 +28,15 @@ package org.apache.cassandra.thrift; 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; @@ -45,11 +55,17 @@ import org.slf4j.LoggerFactory; /** * invalid authorization request (user does not have access to keyspace) */ -public class AuthorizationException extends Exception implements org.apache.thrift.TBase<AuthorizationException, AuthorizationException._Fields>, java.io.Serializable, Cloneable { +public class AuthorizationException extends TException implements org.apache.thrift.TBase<AuthorizationException, AuthorizationException._Fields>, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AuthorizationException"); private static final org.apache.thrift.protocol.TField WHY_FIELD_DESC = new org.apache.thrift.protocol.TField("why", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new AuthorizationExceptionStandardSchemeFactory()); + schemes.put(TupleScheme.class, new AuthorizationExceptionTupleSchemeFactory()); + } + public String why; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ @@ -111,7 +127,6 @@ public class AuthorizationException extends Exception implements org.apache.thri } // 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); @@ -271,44 +286,11 @@ public class AuthorizationException extends Exception implements org.apache.thri } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField field; - iprot.readStructBegin(); - while (true) - { - field = iprot.readFieldBegin(); - if (field.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (field.id) { - case 1: // WHY - if (field.type == org.apache.thrift.protocol.TType.STRING) { - this.why = iprot.readString(); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - validate(); + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (this.why != null) { - oprot.writeFieldBegin(WHY_FIELD_DESC); - oprot.writeString(this.why); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); } @Override @@ -332,6 +314,7 @@ public class AuthorizationException extends Exception implements org.apache.thri if (why == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'why' was not present! Struct: " + toString()); } + // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { @@ -350,5 +333,79 @@ public class AuthorizationException extends Exception implements org.apache.thri } } + private static class AuthorizationExceptionStandardSchemeFactory implements SchemeFactory { + public AuthorizationExceptionStandardScheme getScheme() { + return new AuthorizationExceptionStandardScheme(); + } + } + + private static class AuthorizationExceptionStandardScheme extends StandardScheme<AuthorizationException> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, AuthorizationException 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: // WHY + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.why = iprot.readString(); + struct.setWhyIsSet(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, AuthorizationException struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.why != null) { + oprot.writeFieldBegin(WHY_FIELD_DESC); + oprot.writeString(struct.why); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class AuthorizationExceptionTupleSchemeFactory implements SchemeFactory { + public AuthorizationExceptionTupleScheme getScheme() { + return new AuthorizationExceptionTupleScheme(); + } + } + + private static class AuthorizationExceptionTupleScheme extends TupleScheme<AuthorizationException> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, AuthorizationException struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.why); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, AuthorizationException struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.why = iprot.readString(); + struct.setWhyIsSet(true); + } + } + }