/** * Autogenerated by Thrift Compiler (0.7.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING */ package org.apache.hadoop.thriftfs.api; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.EnumMap; import java.util.Set; import java.util.HashSet; import java.util.EnumSet; import java.util.Collections; import java.util.BitSet; import java.nio.ByteBuffer; import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TLocatedBlock implements org.apache.thrift.TBase<TLocatedBlock, TLocatedBlock._Fields>, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TLocatedBlock"); private static final org.apache.thrift.protocol.TField BLOCK_FIELD_DESC = new org.apache.thrift.protocol.TField("block", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.protocol.TField NAMESPACE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("namespaceId", org.apache.thrift.protocol.TType.I32, (short)2); private static final org.apache.thrift.protocol.TField DATA_TRANSFER_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("dataTransferVersion", org.apache.thrift.protocol.TType.I32, (short)3); private static final org.apache.thrift.protocol.TField LOCATION_FIELD_DESC = new org.apache.thrift.protocol.TField("location", org.apache.thrift.protocol.TType.LIST, (short)4); public TBlock block; // required public int namespaceId; // required public int dataTransferVersion; // required public List<TDatanodeID> location; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { BLOCK((short)1, "block"), NAMESPACE_ID((short)2, "namespaceId"), DATA_TRANSFER_VERSION((short)3, "dataTransferVersion"), LOCATION((short)4, "location"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // BLOCK return BLOCK; case 2: // NAMESPACE_ID return NAMESPACE_ID; case 3: // DATA_TRANSFER_VERSION return DATA_TRANSFER_VERSION; case 4: // LOCATION return LOCATION; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(String name) { return byName.get(name); } private final short _thriftId; private final String _fieldName; _Fields(short thriftId, String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public String getFieldName() { return _fieldName; } } // isset id assignments private static final int __NAMESPACEID_ISSET_ID = 0; private static final int __DATATRANSFERVERSION_ISSET_ID = 1; private BitSet __isset_bit_vector = new BitSet(2); public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.BLOCK, new org.apache.thrift.meta_data.FieldMetaData("block", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TBlock.class))); tmpMap.put(_Fields.NAMESPACE_ID, new org.apache.thrift.meta_data.FieldMetaData("namespaceId", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.DATA_TRANSFER_VERSION, new org.apache.thrift.meta_data.FieldMetaData("dataTransferVersion", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.LOCATION, new org.apache.thrift.meta_data.FieldMetaData("location", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TDatanodeID.class)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TLocatedBlock.class, metaDataMap); } public TLocatedBlock() { } public TLocatedBlock( TBlock block, int namespaceId, int dataTransferVersion, List<TDatanodeID> location) { this(); this.block = block; this.namespaceId = namespaceId; setNamespaceIdIsSet(true); this.dataTransferVersion = dataTransferVersion; setDataTransferVersionIsSet(true); this.location = location; } /** * Performs a deep copy on <i>other</i>. */ public TLocatedBlock(TLocatedBlock other) { __isset_bit_vector.clear(); __isset_bit_vector.or(other.__isset_bit_vector); if (other.isSetBlock()) { this.block = new TBlock(other.block); } this.namespaceId = other.namespaceId; this.dataTransferVersion = other.dataTransferVersion; if (other.isSetLocation()) { List<TDatanodeID> __this__location = new ArrayList<TDatanodeID>(); for (TDatanodeID other_element : other.location) { __this__location.add(new TDatanodeID(other_element)); } this.location = __this__location; } } public TLocatedBlock deepCopy() { return new TLocatedBlock(this); } @Override public void clear() { this.block = null; setNamespaceIdIsSet(false); this.namespaceId = 0; setDataTransferVersionIsSet(false); this.dataTransferVersion = 0; this.location = null; } public TBlock getBlock() { return this.block; } public TLocatedBlock setBlock(TBlock block) { this.block = block; return this; } public void unsetBlock() { this.block = null; } /** Returns true if field block is set (has been assigned a value) and false otherwise */ public boolean isSetBlock() { return this.block != null; } public void setBlockIsSet(boolean value) { if (!value) { this.block = null; } } public int getNamespaceId() { return this.namespaceId; } public TLocatedBlock setNamespaceId(int namespaceId) { this.namespaceId = namespaceId; setNamespaceIdIsSet(true); return this; } public void unsetNamespaceId() { __isset_bit_vector.clear(__NAMESPACEID_ISSET_ID); } /** Returns true if field namespaceId is set (has been assigned a value) and false otherwise */ public boolean isSetNamespaceId() { return __isset_bit_vector.get(__NAMESPACEID_ISSET_ID); } public void setNamespaceIdIsSet(boolean value) { __isset_bit_vector.set(__NAMESPACEID_ISSET_ID, value); } public int getDataTransferVersion() { return this.dataTransferVersion; } public TLocatedBlock setDataTransferVersion(int dataTransferVersion) { this.dataTransferVersion = dataTransferVersion; setDataTransferVersionIsSet(true); return this; } public void unsetDataTransferVersion() { __isset_bit_vector.clear(__DATATRANSFERVERSION_ISSET_ID); } /** Returns true if field dataTransferVersion is set (has been assigned a value) and false otherwise */ public boolean isSetDataTransferVersion() { return __isset_bit_vector.get(__DATATRANSFERVERSION_ISSET_ID); } public void setDataTransferVersionIsSet(boolean value) { __isset_bit_vector.set(__DATATRANSFERVERSION_ISSET_ID, value); } public int getLocationSize() { return (this.location == null) ? 0 : this.location.size(); } public java.util.Iterator<TDatanodeID> getLocationIterator() { return (this.location == null) ? null : this.location.iterator(); } public void addToLocation(TDatanodeID elem) { if (this.location == null) { this.location = new ArrayList<TDatanodeID>(); } this.location.add(elem); } public List<TDatanodeID> getLocation() { return this.location; } public TLocatedBlock setLocation(List<TDatanodeID> location) { this.location = location; return this; } public void unsetLocation() { this.location = null; } /** Returns true if field location is set (has been assigned a value) and false otherwise */ public boolean isSetLocation() { return this.location != null; } public void setLocationIsSet(boolean value) { if (!value) { this.location = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case BLOCK: if (value == null) { unsetBlock(); } else { setBlock((TBlock)value); } break; case NAMESPACE_ID: if (value == null) { unsetNamespaceId(); } else { setNamespaceId((Integer)value); } break; case DATA_TRANSFER_VERSION: if (value == null) { unsetDataTransferVersion(); } else { setDataTransferVersion((Integer)value); } break; case LOCATION: if (value == null) { unsetLocation(); } else { setLocation((List<TDatanodeID>)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case BLOCK: return getBlock(); case NAMESPACE_ID: return Integer.valueOf(getNamespaceId()); case DATA_TRANSFER_VERSION: return Integer.valueOf(getDataTransferVersion()); case LOCATION: return getLocation(); } throw new IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case BLOCK: return isSetBlock(); case NAMESPACE_ID: return isSetNamespaceId(); case DATA_TRANSFER_VERSION: return isSetDataTransferVersion(); case LOCATION: return isSetLocation(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TLocatedBlock) return this.equals((TLocatedBlock)that); return false; } public boolean equals(TLocatedBlock that) { if (that == null) return false; boolean this_present_block = true && this.isSetBlock(); boolean that_present_block = true && that.isSetBlock(); if (this_present_block || that_present_block) { if (!(this_present_block && that_present_block)) return false; if (!this.block.equals(that.block)) return false; } boolean this_present_namespaceId = true; boolean that_present_namespaceId = true; if (this_present_namespaceId || that_present_namespaceId) { if (!(this_present_namespaceId && that_present_namespaceId)) return false; if (this.namespaceId != that.namespaceId) return false; } boolean this_present_dataTransferVersion = true; boolean that_present_dataTransferVersion = true; if (this_present_dataTransferVersion || that_present_dataTransferVersion) { if (!(this_present_dataTransferVersion && that_present_dataTransferVersion)) return false; if (this.dataTransferVersion != that.dataTransferVersion) return false; } boolean this_present_location = true && this.isSetLocation(); boolean that_present_location = true && that.isSetLocation(); if (this_present_location || that_present_location) { if (!(this_present_location && that_present_location)) return false; if (!this.location.equals(that.location)) return false; } return true; } @Override public int hashCode() { return 0; } public int compareTo(TLocatedBlock other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; TLocatedBlock typedOther = (TLocatedBlock)other; lastComparison = Boolean.valueOf(isSetBlock()).compareTo(typedOther.isSetBlock()); if (lastComparison != 0) { return lastComparison; } if (isSetBlock()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.block, typedOther.block); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetNamespaceId()).compareTo(typedOther.isSetNamespaceId()); if (lastComparison != 0) { return lastComparison; } if (isSetNamespaceId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.namespaceId, typedOther.namespaceId); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetDataTransferVersion()).compareTo(typedOther.isSetDataTransferVersion()); if (lastComparison != 0) { return lastComparison; } if (isSetDataTransferVersion()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.dataTransferVersion, typedOther.dataTransferVersion); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetLocation()).compareTo(typedOther.isSetLocation()); if (lastComparison != 0) { return lastComparison; } if (isSetLocation()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.location, typedOther.location); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { 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: // BLOCK if (field.type == org.apache.thrift.protocol.TType.STRUCT) { this.block = new TBlock(); this.block.read(iprot); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); } break; case 2: // NAMESPACE_ID if (field.type == org.apache.thrift.protocol.TType.I32) { this.namespaceId = iprot.readI32(); setNamespaceIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); } break; case 3: // DATA_TRANSFER_VERSION if (field.type == org.apache.thrift.protocol.TType.I32) { this.dataTransferVersion = iprot.readI32(); setDataTransferVersionIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); } break; case 4: // LOCATION if (field.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); this.location = new ArrayList<TDatanodeID>(_list8.size); for (int _i9 = 0; _i9 < _list8.size; ++_i9) { TDatanodeID _elem10; // required _elem10 = new TDatanodeID(); _elem10.read(iprot); this.location.add(_elem10); } iprot.readListEnd(); } } 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(); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { validate(); oprot.writeStructBegin(STRUCT_DESC); if (this.block != null) { oprot.writeFieldBegin(BLOCK_FIELD_DESC); this.block.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldBegin(NAMESPACE_ID_FIELD_DESC); oprot.writeI32(this.namespaceId); oprot.writeFieldEnd(); oprot.writeFieldBegin(DATA_TRANSFER_VERSION_FIELD_DESC); oprot.writeI32(this.dataTransferVersion); oprot.writeFieldEnd(); if (this.location != null) { oprot.writeFieldBegin(LOCATION_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.location.size())); for (TDatanodeID _iter11 : this.location) { _iter11.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { StringBuilder sb = new StringBuilder("TLocatedBlock("); boolean first = true; sb.append("block:"); if (this.block == null) { sb.append("null"); } else { sb.append(this.block); } first = false; if (!first) sb.append(", "); sb.append("namespaceId:"); sb.append(this.namespaceId); first = false; if (!first) sb.append(", "); sb.append("dataTransferVersion:"); sb.append(this.dataTransferVersion); first = false; if (!first) sb.append(", "); sb.append("location:"); if (this.location == null) { sb.append("null"); } else { sb.append(this.location); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bit_vector = new BitSet(1); read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } }