Added: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/CfDef.java URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/CfDef.java?rev=931201&view=auto ============================================================================== --- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/CfDef.java (added) +++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/CfDef.java Tue Apr 6 16:02:10 2010 @@ -0,0 +1,939 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + */ +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 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.util.Arrays; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.thrift.*; +import org.apache.thrift.meta_data.*; +import org.apache.thrift.protocol.*; + +public class CfDef implements TBase<CfDef._Fields>, java.io.Serializable, Cloneable, Comparable<CfDef> { + private static final TStruct STRUCT_DESC = new TStruct("CfDef"); + + private static final TField TABLE_FIELD_DESC = new TField("table", TType.STRING, (short)1); + private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)2); + private static final TField COLUMN_TYPE_FIELD_DESC = new TField("column_type", TType.STRING, (short)3); + private static final TField COMPARATOR_TYPE_FIELD_DESC = new TField("comparator_type", TType.STRING, (short)4); + private static final TField SUBCOMPARATOR_TYPE_FIELD_DESC = new TField("subcomparator_type", TType.STRING, (short)5); + private static final TField COMMENT_FIELD_DESC = new TField("comment", TType.STRING, (short)6); + private static final TField ROW_CACHE_SIZE_FIELD_DESC = new TField("row_cache_size", TType.DOUBLE, (short)7); + private static final TField KEY_CACHE_SIZE_FIELD_DESC = new TField("key_cache_size", TType.DOUBLE, (short)8); + + public String table; + public String name; + public String column_type; + public String comparator_type; + public String subcomparator_type; + public String comment; + public double row_cache_size; + public double key_cache_size; + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements TFieldIdEnum { + TABLE((short)1, "table"), + NAME((short)2, "name"), + COLUMN_TYPE((short)3, "column_type"), + COMPARATOR_TYPE((short)4, "comparator_type"), + SUBCOMPARATOR_TYPE((short)5, "subcomparator_type"), + COMMENT((short)6, "comment"), + ROW_CACHE_SIZE((short)7, "row_cache_size"), + KEY_CACHE_SIZE((short)8, "key_cache_size"); + + private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>(); + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byId.put((int)field._thriftId, field); + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + return byId.get(fieldId); + } + + /** + * 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 + private static final int __ROW_CACHE_SIZE_ISSET_ID = 0; + private static final int __KEY_CACHE_SIZE_ISSET_ID = 1; + private BitSet __isset_bit_vector = new BitSet(2); + + public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{ + put(_Fields.TABLE, new FieldMetaData("table", TFieldRequirementType.REQUIRED, + new FieldValueMetaData(TType.STRING))); + put(_Fields.NAME, new FieldMetaData("name", TFieldRequirementType.REQUIRED, + new FieldValueMetaData(TType.STRING))); + put(_Fields.COLUMN_TYPE, new FieldMetaData("column_type", TFieldRequirementType.OPTIONAL, + new FieldValueMetaData(TType.STRING))); + put(_Fields.COMPARATOR_TYPE, new FieldMetaData("comparator_type", TFieldRequirementType.OPTIONAL, + new FieldValueMetaData(TType.STRING))); + put(_Fields.SUBCOMPARATOR_TYPE, new FieldMetaData("subcomparator_type", TFieldRequirementType.OPTIONAL, + new FieldValueMetaData(TType.STRING))); + put(_Fields.COMMENT, new FieldMetaData("comment", TFieldRequirementType.OPTIONAL, + new FieldValueMetaData(TType.STRING))); + put(_Fields.ROW_CACHE_SIZE, new FieldMetaData("row_cache_size", TFieldRequirementType.OPTIONAL, + new FieldValueMetaData(TType.DOUBLE))); + put(_Fields.KEY_CACHE_SIZE, new FieldMetaData("key_cache_size", TFieldRequirementType.OPTIONAL, + new FieldValueMetaData(TType.DOUBLE))); + }}); + + static { + FieldMetaData.addStructMetaDataMap(CfDef.class, metaDataMap); + } + + public CfDef() { + this.column_type = "Standard"; + + this.comparator_type = "BytesType"; + + this.subcomparator_type = ""; + + this.comment = ""; + + this.row_cache_size = (double)0; + + this.key_cache_size = (double)200000; + + } + + public CfDef( + String table, + String name) + { + this(); + this.table = table; + this.name = name; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public CfDef(CfDef other) { + __isset_bit_vector.clear(); + __isset_bit_vector.or(other.__isset_bit_vector); + if (other.isSetTable()) { + this.table = other.table; + } + if (other.isSetName()) { + this.name = other.name; + } + if (other.isSetColumn_type()) { + this.column_type = other.column_type; + } + if (other.isSetComparator_type()) { + this.comparator_type = other.comparator_type; + } + if (other.isSetSubcomparator_type()) { + this.subcomparator_type = other.subcomparator_type; + } + if (other.isSetComment()) { + this.comment = other.comment; + } + this.row_cache_size = other.row_cache_size; + this.key_cache_size = other.key_cache_size; + } + + public CfDef deepCopy() { + return new CfDef(this); + } + + @Deprecated + public CfDef clone() { + return new CfDef(this); + } + + public String getTable() { + return this.table; + } + + public CfDef setTable(String table) { + this.table = table; + return this; + } + + public void unsetTable() { + this.table = null; + } + + /** Returns true if field table is set (has been asigned a value) and false otherwise */ + public boolean isSetTable() { + return this.table != null; + } + + public void setTableIsSet(boolean value) { + if (!value) { + this.table = null; + } + } + + public String getName() { + return this.name; + } + + public CfDef setName(String name) { + this.name = name; + return this; + } + + public void unsetName() { + this.name = null; + } + + /** Returns true if field name is set (has been asigned a value) and false otherwise */ + public boolean isSetName() { + return this.name != null; + } + + public void setNameIsSet(boolean value) { + if (!value) { + this.name = null; + } + } + + public String getColumn_type() { + return this.column_type; + } + + public CfDef setColumn_type(String column_type) { + this.column_type = column_type; + return this; + } + + public void unsetColumn_type() { + this.column_type = null; + } + + /** Returns true if field column_type is set (has been asigned a value) and false otherwise */ + public boolean isSetColumn_type() { + return this.column_type != null; + } + + public void setColumn_typeIsSet(boolean value) { + if (!value) { + this.column_type = null; + } + } + + public String getComparator_type() { + return this.comparator_type; + } + + public CfDef setComparator_type(String comparator_type) { + this.comparator_type = comparator_type; + return this; + } + + public void unsetComparator_type() { + this.comparator_type = null; + } + + /** Returns true if field comparator_type is set (has been asigned a value) and false otherwise */ + public boolean isSetComparator_type() { + return this.comparator_type != null; + } + + public void setComparator_typeIsSet(boolean value) { + if (!value) { + this.comparator_type = null; + } + } + + public String getSubcomparator_type() { + return this.subcomparator_type; + } + + public CfDef setSubcomparator_type(String subcomparator_type) { + this.subcomparator_type = subcomparator_type; + return this; + } + + public void unsetSubcomparator_type() { + this.subcomparator_type = null; + } + + /** Returns true if field subcomparator_type is set (has been asigned a value) and false otherwise */ + public boolean isSetSubcomparator_type() { + return this.subcomparator_type != null; + } + + public void setSubcomparator_typeIsSet(boolean value) { + if (!value) { + this.subcomparator_type = null; + } + } + + public String getComment() { + return this.comment; + } + + public CfDef setComment(String comment) { + this.comment = comment; + return this; + } + + public void unsetComment() { + this.comment = null; + } + + /** Returns true if field comment is set (has been asigned a value) and false otherwise */ + public boolean isSetComment() { + return this.comment != null; + } + + public void setCommentIsSet(boolean value) { + if (!value) { + this.comment = null; + } + } + + public double getRow_cache_size() { + return this.row_cache_size; + } + + public CfDef setRow_cache_size(double row_cache_size) { + this.row_cache_size = row_cache_size; + setRow_cache_sizeIsSet(true); + return this; + } + + public void unsetRow_cache_size() { + __isset_bit_vector.clear(__ROW_CACHE_SIZE_ISSET_ID); + } + + /** Returns true if field row_cache_size is set (has been asigned a value) and false otherwise */ + public boolean isSetRow_cache_size() { + return __isset_bit_vector.get(__ROW_CACHE_SIZE_ISSET_ID); + } + + public void setRow_cache_sizeIsSet(boolean value) { + __isset_bit_vector.set(__ROW_CACHE_SIZE_ISSET_ID, value); + } + + public double getKey_cache_size() { + return this.key_cache_size; + } + + public CfDef setKey_cache_size(double key_cache_size) { + this.key_cache_size = key_cache_size; + setKey_cache_sizeIsSet(true); + return this; + } + + public void unsetKey_cache_size() { + __isset_bit_vector.clear(__KEY_CACHE_SIZE_ISSET_ID); + } + + /** Returns true if field key_cache_size is set (has been asigned a value) and false otherwise */ + public boolean isSetKey_cache_size() { + return __isset_bit_vector.get(__KEY_CACHE_SIZE_ISSET_ID); + } + + public void setKey_cache_sizeIsSet(boolean value) { + __isset_bit_vector.set(__KEY_CACHE_SIZE_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case TABLE: + if (value == null) { + unsetTable(); + } else { + setTable((String)value); + } + break; + + case NAME: + if (value == null) { + unsetName(); + } else { + setName((String)value); + } + break; + + case COLUMN_TYPE: + if (value == null) { + unsetColumn_type(); + } else { + setColumn_type((String)value); + } + break; + + case COMPARATOR_TYPE: + if (value == null) { + unsetComparator_type(); + } else { + setComparator_type((String)value); + } + break; + + case SUBCOMPARATOR_TYPE: + if (value == null) { + unsetSubcomparator_type(); + } else { + setSubcomparator_type((String)value); + } + break; + + case COMMENT: + if (value == null) { + unsetComment(); + } else { + setComment((String)value); + } + break; + + case ROW_CACHE_SIZE: + if (value == null) { + unsetRow_cache_size(); + } else { + setRow_cache_size((Double)value); + } + break; + + case KEY_CACHE_SIZE: + if (value == null) { + unsetKey_cache_size(); + } else { + setKey_cache_size((Double)value); + } + break; + + } + } + + public void setFieldValue(int fieldID, Object value) { + setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value); + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case TABLE: + return getTable(); + + case NAME: + return getName(); + + case COLUMN_TYPE: + return getColumn_type(); + + case COMPARATOR_TYPE: + return getComparator_type(); + + case SUBCOMPARATOR_TYPE: + return getSubcomparator_type(); + + case COMMENT: + return getComment(); + + case ROW_CACHE_SIZE: + return new Double(getRow_cache_size()); + + case KEY_CACHE_SIZE: + return new Double(getKey_cache_size()); + + } + throw new IllegalStateException(); + } + + public Object getFieldValue(int fieldId) { + return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId)); + } + + /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + switch (field) { + case TABLE: + return isSetTable(); + case NAME: + return isSetName(); + case COLUMN_TYPE: + return isSetColumn_type(); + case COMPARATOR_TYPE: + return isSetComparator_type(); + case SUBCOMPARATOR_TYPE: + return isSetSubcomparator_type(); + case COMMENT: + return isSetComment(); + case ROW_CACHE_SIZE: + return isSetRow_cache_size(); + case KEY_CACHE_SIZE: + return isSetKey_cache_size(); + } + throw new IllegalStateException(); + } + + public boolean isSet(int fieldID) { + return isSet(_Fields.findByThriftIdOrThrow(fieldID)); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CfDef) + return this.equals((CfDef)that); + return false; + } + + public boolean equals(CfDef that) { + if (that == null) + return false; + + boolean this_present_table = true && this.isSetTable(); + boolean that_present_table = true && that.isSetTable(); + if (this_present_table || that_present_table) { + if (!(this_present_table && that_present_table)) + return false; + if (!this.table.equals(that.table)) + 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_column_type = true && this.isSetColumn_type(); + boolean that_present_column_type = true && that.isSetColumn_type(); + if (this_present_column_type || that_present_column_type) { + if (!(this_present_column_type && that_present_column_type)) + return false; + if (!this.column_type.equals(that.column_type)) + return false; + } + + boolean this_present_comparator_type = true && this.isSetComparator_type(); + boolean that_present_comparator_type = true && that.isSetComparator_type(); + if (this_present_comparator_type || that_present_comparator_type) { + if (!(this_present_comparator_type && that_present_comparator_type)) + return false; + if (!this.comparator_type.equals(that.comparator_type)) + return false; + } + + boolean this_present_subcomparator_type = true && this.isSetSubcomparator_type(); + boolean that_present_subcomparator_type = true && that.isSetSubcomparator_type(); + if (this_present_subcomparator_type || that_present_subcomparator_type) { + if (!(this_present_subcomparator_type && that_present_subcomparator_type)) + return false; + if (!this.subcomparator_type.equals(that.subcomparator_type)) + return false; + } + + boolean this_present_comment = true && this.isSetComment(); + boolean that_present_comment = true && that.isSetComment(); + if (this_present_comment || that_present_comment) { + if (!(this_present_comment && that_present_comment)) + return false; + if (!this.comment.equals(that.comment)) + return false; + } + + boolean this_present_row_cache_size = true && this.isSetRow_cache_size(); + boolean that_present_row_cache_size = true && that.isSetRow_cache_size(); + if (this_present_row_cache_size || that_present_row_cache_size) { + if (!(this_present_row_cache_size && that_present_row_cache_size)) + return false; + if (this.row_cache_size != that.row_cache_size) + return false; + } + + boolean this_present_key_cache_size = true && this.isSetKey_cache_size(); + boolean that_present_key_cache_size = true && that.isSetKey_cache_size(); + if (this_present_key_cache_size || that_present_key_cache_size) { + if (!(this_present_key_cache_size && that_present_key_cache_size)) + return false; + if (this.key_cache_size != that.key_cache_size) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(CfDef other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + CfDef typedOther = (CfDef)other; + + lastComparison = Boolean.valueOf(isSetTable()).compareTo(typedOther.isSetTable()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTable()) { lastComparison = TBaseHelper.compareTo(table, typedOther.table); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetName()).compareTo(typedOther.isSetName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetName()) { lastComparison = TBaseHelper.compareTo(name, typedOther.name); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetColumn_type()).compareTo(typedOther.isSetColumn_type()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetColumn_type()) { lastComparison = TBaseHelper.compareTo(column_type, typedOther.column_type); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetComparator_type()).compareTo(typedOther.isSetComparator_type()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetComparator_type()) { lastComparison = TBaseHelper.compareTo(comparator_type, typedOther.comparator_type); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSubcomparator_type()).compareTo(typedOther.isSetSubcomparator_type()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSubcomparator_type()) { lastComparison = TBaseHelper.compareTo(subcomparator_type, typedOther.subcomparator_type); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetComment()).compareTo(typedOther.isSetComment()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetComment()) { lastComparison = TBaseHelper.compareTo(comment, typedOther.comment); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetRow_cache_size()).compareTo(typedOther.isSetRow_cache_size()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetRow_cache_size()) { lastComparison = TBaseHelper.compareTo(row_cache_size, typedOther.row_cache_size); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetKey_cache_size()).compareTo(typedOther.isSetKey_cache_size()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetKey_cache_size()) { lastComparison = TBaseHelper.compareTo(key_cache_size, typedOther.key_cache_size); + if (lastComparison != 0) { + return lastComparison; + } + } + 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) { + case 1: // TABLE + if (field.type == TType.STRING) { + this.table = iprot.readString(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: // NAME + if (field.type == TType.STRING) { + this.name = iprot.readString(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 3: // COLUMN_TYPE + if (field.type == TType.STRING) { + this.column_type = iprot.readString(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 4: // COMPARATOR_TYPE + if (field.type == TType.STRING) { + this.comparator_type = iprot.readString(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 5: // SUBCOMPARATOR_TYPE + if (field.type == TType.STRING) { + this.subcomparator_type = iprot.readString(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 6: // COMMENT + if (field.type == TType.STRING) { + this.comment = iprot.readString(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 7: // ROW_CACHE_SIZE + if (field.type == TType.DOUBLE) { + this.row_cache_size = iprot.readDouble(); + setRow_cache_sizeIsSet(true); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 8: // KEY_CACHE_SIZE + if (field.type == TType.DOUBLE) { + this.key_cache_size = iprot.readDouble(); + setKey_cache_sizeIsSet(true); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + default: + 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(); + } + + public void write(TProtocol oprot) throws TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (this.table != null) { + oprot.writeFieldBegin(TABLE_FIELD_DESC); + oprot.writeString(this.table); + oprot.writeFieldEnd(); + } + if (this.name != null) { + oprot.writeFieldBegin(NAME_FIELD_DESC); + oprot.writeString(this.name); + oprot.writeFieldEnd(); + } + if (this.column_type != null) { + if (isSetColumn_type()) { + oprot.writeFieldBegin(COLUMN_TYPE_FIELD_DESC); + oprot.writeString(this.column_type); + oprot.writeFieldEnd(); + } + } + if (this.comparator_type != null) { + if (isSetComparator_type()) { + oprot.writeFieldBegin(COMPARATOR_TYPE_FIELD_DESC); + oprot.writeString(this.comparator_type); + oprot.writeFieldEnd(); + } + } + if (this.subcomparator_type != null) { + if (isSetSubcomparator_type()) { + oprot.writeFieldBegin(SUBCOMPARATOR_TYPE_FIELD_DESC); + oprot.writeString(this.subcomparator_type); + oprot.writeFieldEnd(); + } + } + if (this.comment != null) { + if (isSetComment()) { + oprot.writeFieldBegin(COMMENT_FIELD_DESC); + oprot.writeString(this.comment); + oprot.writeFieldEnd(); + } + } + if (isSetRow_cache_size()) { + oprot.writeFieldBegin(ROW_CACHE_SIZE_FIELD_DESC); + oprot.writeDouble(this.row_cache_size); + oprot.writeFieldEnd(); + } + if (isSetKey_cache_size()) { + oprot.writeFieldBegin(KEY_CACHE_SIZE_FIELD_DESC); + oprot.writeDouble(this.key_cache_size); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CfDef("); + boolean first = true; + + sb.append("table:"); + if (this.table == null) { + sb.append("null"); + } else { + sb.append(this.table); + } + first = false; + if (!first) sb.append(", "); + sb.append("name:"); + if (this.name == null) { + sb.append("null"); + } else { + sb.append(this.name); + } + first = false; + if (isSetColumn_type()) { + if (!first) sb.append(", "); + sb.append("column_type:"); + if (this.column_type == null) { + sb.append("null"); + } else { + sb.append(this.column_type); + } + first = false; + } + if (isSetComparator_type()) { + if (!first) sb.append(", "); + sb.append("comparator_type:"); + if (this.comparator_type == null) { + sb.append("null"); + } else { + sb.append(this.comparator_type); + } + first = false; + } + if (isSetSubcomparator_type()) { + if (!first) sb.append(", "); + sb.append("subcomparator_type:"); + if (this.subcomparator_type == null) { + sb.append("null"); + } else { + sb.append(this.subcomparator_type); + } + first = false; + } + if (isSetComment()) { + if (!first) sb.append(", "); + sb.append("comment:"); + if (this.comment == null) { + sb.append("null"); + } else { + sb.append(this.comment); + } + first = false; + } + if (isSetRow_cache_size()) { + if (!first) sb.append(", "); + sb.append("row_cache_size:"); + sb.append(this.row_cache_size); + first = false; + } + if (isSetKey_cache_size()) { + if (!first) sb.append(", "); + sb.append("key_cache_size:"); + sb.append(this.key_cache_size); + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws TException { + // check for required fields + if (table == null) { + throw new TProtocolException("Required field 'table' was not present! Struct: " + toString()); + } + if (name == null) { + throw new TProtocolException("Required field 'name' was not present! Struct: " + toString()); + } + } + +} +
Added: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java?rev=931201&view=auto ============================================================================== --- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java (added) +++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java Tue Apr 6 16:02:10 2010 @@ -0,0 +1,716 @@ +/** + * Autogenerated by Thrift + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + */ +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 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.util.Arrays; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.thrift.*; +import org.apache.thrift.meta_data.*; +import org.apache.thrift.protocol.*; + +public class KsDef implements TBase<KsDef._Fields>, java.io.Serializable, Cloneable, Comparable<KsDef> { + private static final TStruct STRUCT_DESC = new TStruct("KsDef"); + + private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)1); + private static final TField STRATEGY_CLASS_FIELD_DESC = new TField("strategy_class", TType.STRING, (short)2); + private static final TField REPLICATION_FACTOR_FIELD_DESC = new TField("replication_factor", TType.I32, (short)3); + private static final TField SNITCH_CLASS_FIELD_DESC = new TField("snitch_class", TType.STRING, (short)4); + private static final TField CF_DEFS_FIELD_DESC = new TField("cf_defs", TType.LIST, (short)5); + + public String name; + public String strategy_class; + public int replication_factor; + public String snitch_class; + public List<CfDef> cf_defs; + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements TFieldIdEnum { + NAME((short)1, "name"), + STRATEGY_CLASS((short)2, "strategy_class"), + REPLICATION_FACTOR((short)3, "replication_factor"), + SNITCH_CLASS((short)4, "snitch_class"), + CF_DEFS((short)5, "cf_defs"); + + private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>(); + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byId.put((int)field._thriftId, field); + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + return byId.get(fieldId); + } + + /** + * 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 + private static final int __REPLICATION_FACTOR_ISSET_ID = 0; + private BitSet __isset_bit_vector = new BitSet(1); + + public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{ + put(_Fields.NAME, new FieldMetaData("name", TFieldRequirementType.REQUIRED, + new FieldValueMetaData(TType.STRING))); + put(_Fields.STRATEGY_CLASS, new FieldMetaData("strategy_class", TFieldRequirementType.REQUIRED, + new FieldValueMetaData(TType.STRING))); + put(_Fields.REPLICATION_FACTOR, new FieldMetaData("replication_factor", TFieldRequirementType.REQUIRED, + new FieldValueMetaData(TType.I32))); + put(_Fields.SNITCH_CLASS, new FieldMetaData("snitch_class", TFieldRequirementType.REQUIRED, + new FieldValueMetaData(TType.STRING))); + put(_Fields.CF_DEFS, new FieldMetaData("cf_defs", TFieldRequirementType.REQUIRED, + new ListMetaData(TType.LIST, + new StructMetaData(TType.STRUCT, CfDef.class)))); + }}); + + static { + FieldMetaData.addStructMetaDataMap(KsDef.class, metaDataMap); + } + + public KsDef() { + } + + public KsDef( + String name, + String strategy_class, + int replication_factor, + String snitch_class, + List<CfDef> cf_defs) + { + this(); + this.name = name; + this.strategy_class = strategy_class; + this.replication_factor = replication_factor; + setReplication_factorIsSet(true); + this.snitch_class = snitch_class; + this.cf_defs = cf_defs; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public KsDef(KsDef other) { + __isset_bit_vector.clear(); + __isset_bit_vector.or(other.__isset_bit_vector); + if (other.isSetName()) { + this.name = other.name; + } + if (other.isSetStrategy_class()) { + this.strategy_class = other.strategy_class; + } + this.replication_factor = other.replication_factor; + if (other.isSetSnitch_class()) { + this.snitch_class = other.snitch_class; + } + if (other.isSetCf_defs()) { + List<CfDef> __this__cf_defs = new ArrayList<CfDef>(); + for (CfDef other_element : other.cf_defs) { + __this__cf_defs.add(new CfDef(other_element)); + } + this.cf_defs = __this__cf_defs; + } + } + + public KsDef deepCopy() { + return new KsDef(this); + } + + @Deprecated + public KsDef clone() { + return new KsDef(this); + } + + public String getName() { + return this.name; + } + + public KsDef setName(String name) { + this.name = name; + return this; + } + + public void unsetName() { + this.name = null; + } + + /** Returns true if field name is set (has been asigned a value) and false otherwise */ + public boolean isSetName() { + return this.name != null; + } + + public void setNameIsSet(boolean value) { + if (!value) { + this.name = null; + } + } + + public String getStrategy_class() { + return this.strategy_class; + } + + public KsDef setStrategy_class(String strategy_class) { + this.strategy_class = strategy_class; + return this; + } + + public void unsetStrategy_class() { + this.strategy_class = null; + } + + /** Returns true if field strategy_class is set (has been asigned a value) and false otherwise */ + public boolean isSetStrategy_class() { + return this.strategy_class != null; + } + + public void setStrategy_classIsSet(boolean value) { + if (!value) { + this.strategy_class = null; + } + } + + public int getReplication_factor() { + return this.replication_factor; + } + + public KsDef setReplication_factor(int replication_factor) { + this.replication_factor = replication_factor; + setReplication_factorIsSet(true); + return this; + } + + public void unsetReplication_factor() { + __isset_bit_vector.clear(__REPLICATION_FACTOR_ISSET_ID); + } + + /** Returns true if field replication_factor is set (has been asigned a value) and false otherwise */ + public boolean isSetReplication_factor() { + return __isset_bit_vector.get(__REPLICATION_FACTOR_ISSET_ID); + } + + public void setReplication_factorIsSet(boolean value) { + __isset_bit_vector.set(__REPLICATION_FACTOR_ISSET_ID, value); + } + + public String getSnitch_class() { + return this.snitch_class; + } + + public KsDef setSnitch_class(String snitch_class) { + this.snitch_class = snitch_class; + return this; + } + + public void unsetSnitch_class() { + this.snitch_class = null; + } + + /** Returns true if field snitch_class is set (has been asigned a value) and false otherwise */ + public boolean isSetSnitch_class() { + return this.snitch_class != null; + } + + public void setSnitch_classIsSet(boolean value) { + if (!value) { + this.snitch_class = null; + } + } + + public int getCf_defsSize() { + return (this.cf_defs == null) ? 0 : this.cf_defs.size(); + } + + public java.util.Iterator<CfDef> getCf_defsIterator() { + return (this.cf_defs == null) ? null : this.cf_defs.iterator(); + } + + public void addToCf_defs(CfDef elem) { + if (this.cf_defs == null) { + this.cf_defs = new ArrayList<CfDef>(); + } + this.cf_defs.add(elem); + } + + public List<CfDef> getCf_defs() { + return this.cf_defs; + } + + public KsDef setCf_defs(List<CfDef> cf_defs) { + this.cf_defs = cf_defs; + return this; + } + + public void unsetCf_defs() { + this.cf_defs = null; + } + + /** Returns true if field cf_defs is set (has been asigned a value) and false otherwise */ + public boolean isSetCf_defs() { + return this.cf_defs != null; + } + + public void setCf_defsIsSet(boolean value) { + if (!value) { + this.cf_defs = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case NAME: + if (value == null) { + unsetName(); + } else { + setName((String)value); + } + break; + + case STRATEGY_CLASS: + if (value == null) { + unsetStrategy_class(); + } else { + setStrategy_class((String)value); + } + break; + + case REPLICATION_FACTOR: + if (value == null) { + unsetReplication_factor(); + } else { + setReplication_factor((Integer)value); + } + break; + + case SNITCH_CLASS: + if (value == null) { + unsetSnitch_class(); + } else { + setSnitch_class((String)value); + } + break; + + case CF_DEFS: + if (value == null) { + unsetCf_defs(); + } else { + setCf_defs((List<CfDef>)value); + } + break; + + } + } + + public void setFieldValue(int fieldID, Object value) { + setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value); + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case NAME: + return getName(); + + case STRATEGY_CLASS: + return getStrategy_class(); + + case REPLICATION_FACTOR: + return new Integer(getReplication_factor()); + + case SNITCH_CLASS: + return getSnitch_class(); + + case CF_DEFS: + return getCf_defs(); + + } + throw new IllegalStateException(); + } + + public Object getFieldValue(int fieldId) { + return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId)); + } + + /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + switch (field) { + case NAME: + return isSetName(); + case STRATEGY_CLASS: + return isSetStrategy_class(); + case REPLICATION_FACTOR: + return isSetReplication_factor(); + case SNITCH_CLASS: + return isSetSnitch_class(); + case CF_DEFS: + return isSetCf_defs(); + } + throw new IllegalStateException(); + } + + public boolean isSet(int fieldID) { + return isSet(_Fields.findByThriftIdOrThrow(fieldID)); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof KsDef) + return this.equals((KsDef)that); + return false; + } + + public boolean equals(KsDef 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_strategy_class = true && this.isSetStrategy_class(); + boolean that_present_strategy_class = true && that.isSetStrategy_class(); + if (this_present_strategy_class || that_present_strategy_class) { + if (!(this_present_strategy_class && that_present_strategy_class)) + return false; + if (!this.strategy_class.equals(that.strategy_class)) + return false; + } + + boolean this_present_replication_factor = true; + boolean that_present_replication_factor = true; + if (this_present_replication_factor || that_present_replication_factor) { + if (!(this_present_replication_factor && that_present_replication_factor)) + return false; + if (this.replication_factor != that.replication_factor) + return false; + } + + boolean this_present_snitch_class = true && this.isSetSnitch_class(); + boolean that_present_snitch_class = true && that.isSetSnitch_class(); + if (this_present_snitch_class || that_present_snitch_class) { + if (!(this_present_snitch_class && that_present_snitch_class)) + return false; + if (!this.snitch_class.equals(that.snitch_class)) + return false; + } + + boolean this_present_cf_defs = true && this.isSetCf_defs(); + boolean that_present_cf_defs = true && that.isSetCf_defs(); + if (this_present_cf_defs || that_present_cf_defs) { + if (!(this_present_cf_defs && that_present_cf_defs)) + return false; + if (!this.cf_defs.equals(that.cf_defs)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(KsDef other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + KsDef typedOther = (KsDef)other; + + lastComparison = Boolean.valueOf(isSetName()).compareTo(typedOther.isSetName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetName()) { lastComparison = TBaseHelper.compareTo(name, typedOther.name); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetStrategy_class()).compareTo(typedOther.isSetStrategy_class()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStrategy_class()) { lastComparison = TBaseHelper.compareTo(strategy_class, typedOther.strategy_class); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetReplication_factor()).compareTo(typedOther.isSetReplication_factor()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetReplication_factor()) { lastComparison = TBaseHelper.compareTo(replication_factor, typedOther.replication_factor); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSnitch_class()).compareTo(typedOther.isSetSnitch_class()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSnitch_class()) { lastComparison = TBaseHelper.compareTo(snitch_class, typedOther.snitch_class); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCf_defs()).compareTo(typedOther.isSetCf_defs()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCf_defs()) { lastComparison = TBaseHelper.compareTo(cf_defs, typedOther.cf_defs); + if (lastComparison != 0) { + return lastComparison; + } + } + 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) { + case 1: // NAME + if (field.type == TType.STRING) { + this.name = iprot.readString(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: // STRATEGY_CLASS + if (field.type == TType.STRING) { + this.strategy_class = iprot.readString(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 3: // REPLICATION_FACTOR + if (field.type == TType.I32) { + this.replication_factor = iprot.readI32(); + setReplication_factorIsSet(true); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 4: // SNITCH_CLASS + if (field.type == TType.STRING) { + this.snitch_class = iprot.readString(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 5: // CF_DEFS + if (field.type == TType.LIST) { + { + TList _list25 = iprot.readListBegin(); + this.cf_defs = new ArrayList<CfDef>(_list25.size); + for (int _i26 = 0; _i26 < _list25.size; ++_i26) + { + CfDef _elem27; + _elem27 = new CfDef(); + _elem27.read(iprot); + this.cf_defs.add(_elem27); + } + iprot.readListEnd(); + } + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + default: + 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 + if (!isSetReplication_factor()) { + throw new TProtocolException("Required field 'replication_factor' was not found in serialized data! Struct: " + toString()); + } + validate(); + } + + public void write(TProtocol oprot) throws TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (this.name != null) { + oprot.writeFieldBegin(NAME_FIELD_DESC); + oprot.writeString(this.name); + oprot.writeFieldEnd(); + } + if (this.strategy_class != null) { + oprot.writeFieldBegin(STRATEGY_CLASS_FIELD_DESC); + oprot.writeString(this.strategy_class); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(REPLICATION_FACTOR_FIELD_DESC); + oprot.writeI32(this.replication_factor); + oprot.writeFieldEnd(); + if (this.snitch_class != null) { + oprot.writeFieldBegin(SNITCH_CLASS_FIELD_DESC); + oprot.writeString(this.snitch_class); + oprot.writeFieldEnd(); + } + if (this.cf_defs != null) { + oprot.writeFieldBegin(CF_DEFS_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.STRUCT, this.cf_defs.size())); + for (CfDef _iter28 : this.cf_defs) + { + _iter28.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("KsDef("); + 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("strategy_class:"); + if (this.strategy_class == null) { + sb.append("null"); + } else { + sb.append(this.strategy_class); + } + first = false; + if (!first) sb.append(", "); + sb.append("replication_factor:"); + sb.append(this.replication_factor); + first = false; + if (!first) sb.append(", "); + sb.append("snitch_class:"); + if (this.snitch_class == null) { + sb.append("null"); + } else { + sb.append(this.snitch_class); + } + first = false; + if (!first) sb.append(", "); + sb.append("cf_defs:"); + if (this.cf_defs == null) { + sb.append("null"); + } else { + sb.append(this.cf_defs); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws TException { + // check for required fields + if (name == null) { + throw new TProtocolException("Required field 'name' was not present! Struct: " + toString()); + } + if (strategy_class == null) { + throw new TProtocolException("Required field 'strategy_class' was not present! Struct: " + toString()); + } + // alas, we cannot check 'replication_factor' because it's a primitive and you chose the non-beans generator. + if (snitch_class == null) { + throw new TProtocolException("Required field 'snitch_class' was not present! Struct: " + toString()); + } + if (cf_defs == null) { + throw new TProtocolException("Required field 'cf_defs' was not present! Struct: " + toString()); + } + } + +} + Modified: cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java?rev=931201&r1=931200&r2=931201&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java Tue Apr 6 16:02:10 2010 @@ -674,7 +674,37 @@ public class CassandraServer implements if (loginDone.get() == AccessLevel.NONE) throw new InvalidRequestException("Your login access level was not sufficient to do " + level + " operations"); if (loginDone.get().getValue() >= level.getValue()) throw new InvalidRequestException("Your login access level was not sufficient to do " + level + " operations"); } - + + public void system_add_column_family(CfDef cf_def) throws InvalidRequestException, TException + { + checkLoginAuthorized(AccessLevel.FULL); + } + + public void system_drop_column_family(String keyspace, String column_family) throws InvalidRequestException, TException + { + checkLoginAuthorized(AccessLevel.FULL); + } + + public void system_rename_column_family(String keyspace, String old_name, String new_name) throws InvalidRequestException, TException + { + checkLoginAuthorized(AccessLevel.FULL); + } + + public void system_add_keyspace(KsDef ks_def) throws InvalidRequestException, TException + { + checkLoginAuthorized(AccessLevel.FULL); + } + + public void system_drop_keyspace(String keyspace) throws InvalidRequestException, TException + { + checkLoginAuthorized(AccessLevel.FULL); + } + + public void system_rename_keyspace(String old_name, String new_name) throws InvalidRequestException, TException + { + checkLoginAuthorized(AccessLevel.FULL); + } + // main method moved to CassandraDaemon } \ No newline at end of file
