/**
* 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.corona;
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;
/**
* Standard set of resources offered by a computer
*/
public class ComputeSpecs implements org.apache.thrift.TBase<ComputeSpecs, ComputeSpecs._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ComputeSpecs");
private static final org.apache.thrift.protocol.TField NUM_CPUS_FIELD_DESC = new org.apache.thrift.protocol.TField("numCpus", org.apache.thrift.protocol.TType.I16, (short)1);
private static final org.apache.thrift.protocol.TField NETWORK_MBPS_FIELD_DESC = new org.apache.thrift.protocol.TField("networkMBps", org.apache.thrift.protocol.TType.I16, (short)2);
private static final org.apache.thrift.protocol.TField MEMORY_MB_FIELD_DESC = new org.apache.thrift.protocol.TField("memoryMB", org.apache.thrift.protocol.TType.I32, (short)3);
private static final org.apache.thrift.protocol.TField DISK_GB_FIELD_DESC = new org.apache.thrift.protocol.TField("diskGB", org.apache.thrift.protocol.TType.I32, (short)4);
public short numCpus; // required
public short networkMBps; // required
public int memoryMB; // required
public int diskGB; // 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 {
NUM_CPUS((short)1, "numCpus"),
NETWORK_MBPS((short)2, "networkMBps"),
MEMORY_MB((short)3, "memoryMB"),
DISK_GB((short)4, "diskGB");
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: // NUM_CPUS
return NUM_CPUS;
case 2: // NETWORK_MBPS
return NETWORK_MBPS;
case 3: // MEMORY_MB
return MEMORY_MB;
case 4: // DISK_GB
return DISK_GB;
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 __NUMCPUS_ISSET_ID = 0;
private static final int __NETWORKMBPS_ISSET_ID = 1;
private static final int __MEMORYMB_ISSET_ID = 2;
private static final int __DISKGB_ISSET_ID = 3;
private BitSet __isset_bit_vector = new BitSet(4);
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.NUM_CPUS, new org.apache.thrift.meta_data.FieldMetaData("numCpus", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16)));
tmpMap.put(_Fields.NETWORK_MBPS, new org.apache.thrift.meta_data.FieldMetaData("networkMBps", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16)));
tmpMap.put(_Fields.MEMORY_MB, new org.apache.thrift.meta_data.FieldMetaData("memoryMB", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.DISK_GB, new org.apache.thrift.meta_data.FieldMetaData("diskGB", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ComputeSpecs.class, metaDataMap);
}
public ComputeSpecs() {
}
public ComputeSpecs(
short numCpus)
{
this();
this.numCpus = numCpus;
setNumCpusIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public ComputeSpecs(ComputeSpecs other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
this.numCpus = other.numCpus;
this.networkMBps = other.networkMBps;
this.memoryMB = other.memoryMB;
this.diskGB = other.diskGB;
}
public ComputeSpecs deepCopy() {
return new ComputeSpecs(this);
}
@Override
public void clear() {
setNumCpusIsSet(false);
this.numCpus = 0;
setNetworkMBpsIsSet(false);
this.networkMBps = 0;
setMemoryMBIsSet(false);
this.memoryMB = 0;
setDiskGBIsSet(false);
this.diskGB = 0;
}
public short getNumCpus() {
return this.numCpus;
}
public ComputeSpecs setNumCpus(short numCpus) {
this.numCpus = numCpus;
setNumCpusIsSet(true);
return this;
}
public void unsetNumCpus() {
__isset_bit_vector.clear(__NUMCPUS_ISSET_ID);
}
/** Returns true if field numCpus is set (has been assigned a value) and false otherwise */
public boolean isSetNumCpus() {
return __isset_bit_vector.get(__NUMCPUS_ISSET_ID);
}
public void setNumCpusIsSet(boolean value) {
__isset_bit_vector.set(__NUMCPUS_ISSET_ID, value);
}
public short getNetworkMBps() {
return this.networkMBps;
}
public ComputeSpecs setNetworkMBps(short networkMBps) {
this.networkMBps = networkMBps;
setNetworkMBpsIsSet(true);
return this;
}
public void unsetNetworkMBps() {
__isset_bit_vector.clear(__NETWORKMBPS_ISSET_ID);
}
/** Returns true if field networkMBps is set (has been assigned a value) and false otherwise */
public boolean isSetNetworkMBps() {
return __isset_bit_vector.get(__NETWORKMBPS_ISSET_ID);
}
public void setNetworkMBpsIsSet(boolean value) {
__isset_bit_vector.set(__NETWORKMBPS_ISSET_ID, value);
}
public int getMemoryMB() {
return this.memoryMB;
}
public ComputeSpecs setMemoryMB(int memoryMB) {
this.memoryMB = memoryMB;
setMemoryMBIsSet(true);
return this;
}
public void unsetMemoryMB() {
__isset_bit_vector.clear(__MEMORYMB_ISSET_ID);
}
/** Returns true if field memoryMB is set (has been assigned a value) and false otherwise */
public boolean isSetMemoryMB() {
return __isset_bit_vector.get(__MEMORYMB_ISSET_ID);
}
public void setMemoryMBIsSet(boolean value) {
__isset_bit_vector.set(__MEMORYMB_ISSET_ID, value);
}
public int getDiskGB() {
return this.diskGB;
}
public ComputeSpecs setDiskGB(int diskGB) {
this.diskGB = diskGB;
setDiskGBIsSet(true);
return this;
}
public void unsetDiskGB() {
__isset_bit_vector.clear(__DISKGB_ISSET_ID);
}
/** Returns true if field diskGB is set (has been assigned a value) and false otherwise */
public boolean isSetDiskGB() {
return __isset_bit_vector.get(__DISKGB_ISSET_ID);
}
public void setDiskGBIsSet(boolean value) {
__isset_bit_vector.set(__DISKGB_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case NUM_CPUS:
if (value == null) {
unsetNumCpus();
} else {
setNumCpus((Short)value);
}
break;
case NETWORK_MBPS:
if (value == null) {
unsetNetworkMBps();
} else {
setNetworkMBps((Short)value);
}
break;
case MEMORY_MB:
if (value == null) {
unsetMemoryMB();
} else {
setMemoryMB((Integer)value);
}
break;
case DISK_GB:
if (value == null) {
unsetDiskGB();
} else {
setDiskGB((Integer)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case NUM_CPUS:
return Short.valueOf(getNumCpus());
case NETWORK_MBPS:
return Short.valueOf(getNetworkMBps());
case MEMORY_MB:
return Integer.valueOf(getMemoryMB());
case DISK_GB:
return Integer.valueOf(getDiskGB());
}
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 NUM_CPUS:
return isSetNumCpus();
case NETWORK_MBPS:
return isSetNetworkMBps();
case MEMORY_MB:
return isSetMemoryMB();
case DISK_GB:
return isSetDiskGB();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof ComputeSpecs)
return this.equals((ComputeSpecs)that);
return false;
}
public boolean equals(ComputeSpecs that) {
if (that == null)
return false;
boolean this_present_numCpus = true;
boolean that_present_numCpus = true;
if (this_present_numCpus || that_present_numCpus) {
if (!(this_present_numCpus && that_present_numCpus))
return false;
if (this.numCpus != that.numCpus)
return false;
}
boolean this_present_networkMBps = true && this.isSetNetworkMBps();
boolean that_present_networkMBps = true && that.isSetNetworkMBps();
if (this_present_networkMBps || that_present_networkMBps) {
if (!(this_present_networkMBps && that_present_networkMBps))
return false;
if (this.networkMBps != that.networkMBps)
return false;
}
boolean this_present_memoryMB = true && this.isSetMemoryMB();
boolean that_present_memoryMB = true && that.isSetMemoryMB();
if (this_present_memoryMB || that_present_memoryMB) {
if (!(this_present_memoryMB && that_present_memoryMB))
return false;
if (this.memoryMB != that.memoryMB)
return false;
}
boolean this_present_diskGB = true && this.isSetDiskGB();
boolean that_present_diskGB = true && that.isSetDiskGB();
if (this_present_diskGB || that_present_diskGB) {
if (!(this_present_diskGB && that_present_diskGB))
return false;
if (this.diskGB != that.diskGB)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(ComputeSpecs other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
ComputeSpecs typedOther = (ComputeSpecs)other;
lastComparison = Boolean.valueOf(isSetNumCpus()).compareTo(typedOther.isSetNumCpus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetNumCpus()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.numCpus, typedOther.numCpus);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetNetworkMBps()).compareTo(typedOther.isSetNetworkMBps());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetNetworkMBps()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.networkMBps, typedOther.networkMBps);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetMemoryMB()).compareTo(typedOther.isSetMemoryMB());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMemoryMB()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.memoryMB, typedOther.memoryMB);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetDiskGB()).compareTo(typedOther.isSetDiskGB());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetDiskGB()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.diskGB, typedOther.diskGB);
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: // NUM_CPUS
if (field.type == org.apache.thrift.protocol.TType.I16) {
this.numCpus = iprot.readI16();
setNumCpusIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // NETWORK_MBPS
if (field.type == org.apache.thrift.protocol.TType.I16) {
this.networkMBps = iprot.readI16();
setNetworkMBpsIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // MEMORY_MB
if (field.type == org.apache.thrift.protocol.TType.I32) {
this.memoryMB = iprot.readI32();
setMemoryMBIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 4: // DISK_GB
if (field.type == org.apache.thrift.protocol.TType.I32) {
this.diskGB = iprot.readI32();
setDiskGBIsSet(true);
} 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
if (!isSetNumCpus()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'numCpus' was not found in serialized data! Struct: " + toString());
}
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(NUM_CPUS_FIELD_DESC);
oprot.writeI16(this.numCpus);
oprot.writeFieldEnd();
if (isSetNetworkMBps()) {
oprot.writeFieldBegin(NETWORK_MBPS_FIELD_DESC);
oprot.writeI16(this.networkMBps);
oprot.writeFieldEnd();
}
if (isSetMemoryMB()) {
oprot.writeFieldBegin(MEMORY_MB_FIELD_DESC);
oprot.writeI32(this.memoryMB);
oprot.writeFieldEnd();
}
if (isSetDiskGB()) {
oprot.writeFieldBegin(DISK_GB_FIELD_DESC);
oprot.writeI32(this.diskGB);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("ComputeSpecs(");
boolean first = true;
sb.append("numCpus:");
sb.append(this.numCpus);
first = false;
if (isSetNetworkMBps()) {
if (!first) sb.append(", ");
sb.append("networkMBps:");
sb.append(this.networkMBps);
first = false;
}
if (isSetMemoryMB()) {
if (!first) sb.append(", ");
sb.append("memoryMB:");
sb.append(this.memoryMB);
first = false;
}
if (isSetDiskGB()) {
if (!first) sb.append(", ");
sb.append("diskGB:");
sb.append(this.diskGB);
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// alas, we cannot check 'numCpus' because it's a primitive and you chose the non-beans generator.
}
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);
}
}
}