blob: 087ebb4772a6bc9aea55fd5c8cba843708ee3cc2 [file] [log] [blame]
/**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package backtype.storm.generated;
import org.apache.commons.lang.builder.HashCodeBuilder;
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.async.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;
public class StormTopology implements TBase<StormTopology, StormTopology._Fields>, java.io.Serializable, Cloneable {
private static final TStruct STRUCT_DESC = new TStruct("StormTopology");
private static final TField SPOUTS_FIELD_DESC = new TField("spouts", TType.MAP, (short)1);
private static final TField BOLTS_FIELD_DESC = new TField("bolts", TType.MAP, (short)2);
private static final TField STATE_SPOUTS_FIELD_DESC = new TField("state_spouts", TType.MAP, (short)3);
private Map<Integer,SpoutSpec> spouts;
private Map<Integer,Bolt> bolts;
private Map<Integer,StateSpoutSpec> state_spouts;
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements TFieldIdEnum {
SPOUTS((short)1, "spouts"),
BOLTS((short)2, "bolts"),
STATE_SPOUTS((short)3, "state_spouts");
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: // SPOUTS
return SPOUTS;
case 2: // BOLTS
return BOLTS;
case 3: // STATE_SPOUTS
return STATE_SPOUTS;
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
public static final Map<_Fields, FieldMetaData> metaDataMap;
static {
Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SPOUTS, new FieldMetaData("spouts", TFieldRequirementType.REQUIRED,
new MapMetaData(TType.MAP,
new FieldValueMetaData(TType.I32),
new StructMetaData(TType.STRUCT, SpoutSpec.class))));
tmpMap.put(_Fields.BOLTS, new FieldMetaData("bolts", TFieldRequirementType.REQUIRED,
new MapMetaData(TType.MAP,
new FieldValueMetaData(TType.I32),
new StructMetaData(TType.STRUCT, Bolt.class))));
tmpMap.put(_Fields.STATE_SPOUTS, new FieldMetaData("state_spouts", TFieldRequirementType.REQUIRED,
new MapMetaData(TType.MAP,
new FieldValueMetaData(TType.I32),
new StructMetaData(TType.STRUCT, StateSpoutSpec.class))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
FieldMetaData.addStructMetaDataMap(StormTopology.class, metaDataMap);
}
public StormTopology() {
}
public StormTopology(
Map<Integer,SpoutSpec> spouts,
Map<Integer,Bolt> bolts,
Map<Integer,StateSpoutSpec> state_spouts)
{
this();
this.spouts = spouts;
this.bolts = bolts;
this.state_spouts = state_spouts;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public StormTopology(StormTopology other) {
if (other.is_set_spouts()) {
Map<Integer,SpoutSpec> __this__spouts = new HashMap<Integer,SpoutSpec>();
for (Map.Entry<Integer, SpoutSpec> other_element : other.spouts.entrySet()) {
Integer other_element_key = other_element.getKey();
SpoutSpec other_element_value = other_element.getValue();
Integer __this__spouts_copy_key = other_element_key;
SpoutSpec __this__spouts_copy_value = new SpoutSpec(other_element_value);
__this__spouts.put(__this__spouts_copy_key, __this__spouts_copy_value);
}
this.spouts = __this__spouts;
}
if (other.is_set_bolts()) {
Map<Integer,Bolt> __this__bolts = new HashMap<Integer,Bolt>();
for (Map.Entry<Integer, Bolt> other_element : other.bolts.entrySet()) {
Integer other_element_key = other_element.getKey();
Bolt other_element_value = other_element.getValue();
Integer __this__bolts_copy_key = other_element_key;
Bolt __this__bolts_copy_value = new Bolt(other_element_value);
__this__bolts.put(__this__bolts_copy_key, __this__bolts_copy_value);
}
this.bolts = __this__bolts;
}
if (other.is_set_state_spouts()) {
Map<Integer,StateSpoutSpec> __this__state_spouts = new HashMap<Integer,StateSpoutSpec>();
for (Map.Entry<Integer, StateSpoutSpec> other_element : other.state_spouts.entrySet()) {
Integer other_element_key = other_element.getKey();
StateSpoutSpec other_element_value = other_element.getValue();
Integer __this__state_spouts_copy_key = other_element_key;
StateSpoutSpec __this__state_spouts_copy_value = new StateSpoutSpec(other_element_value);
__this__state_spouts.put(__this__state_spouts_copy_key, __this__state_spouts_copy_value);
}
this.state_spouts = __this__state_spouts;
}
}
public StormTopology deepCopy() {
return new StormTopology(this);
}
@Deprecated
public StormTopology clone() {
return new StormTopology(this);
}
public int get_spouts_size() {
return (this.spouts == null) ? 0 : this.spouts.size();
}
public void put_to_spouts(int key, SpoutSpec val) {
if (this.spouts == null) {
this.spouts = new HashMap<Integer,SpoutSpec>();
}
this.spouts.put(key, val);
}
public Map<Integer,SpoutSpec> get_spouts() {
return this.spouts;
}
public void set_spouts(Map<Integer,SpoutSpec> spouts) {
this.spouts = spouts;
}
public void unset_spouts() {
this.spouts = null;
}
/** Returns true if field spouts is set (has been asigned a value) and false otherwise */
public boolean is_set_spouts() {
return this.spouts != null;
}
public void set_spouts_isSet(boolean value) {
if (!value) {
this.spouts = null;
}
}
public int get_bolts_size() {
return (this.bolts == null) ? 0 : this.bolts.size();
}
public void put_to_bolts(int key, Bolt val) {
if (this.bolts == null) {
this.bolts = new HashMap<Integer,Bolt>();
}
this.bolts.put(key, val);
}
public Map<Integer,Bolt> get_bolts() {
return this.bolts;
}
public void set_bolts(Map<Integer,Bolt> bolts) {
this.bolts = bolts;
}
public void unset_bolts() {
this.bolts = null;
}
/** Returns true if field bolts is set (has been asigned a value) and false otherwise */
public boolean is_set_bolts() {
return this.bolts != null;
}
public void set_bolts_isSet(boolean value) {
if (!value) {
this.bolts = null;
}
}
public int get_state_spouts_size() {
return (this.state_spouts == null) ? 0 : this.state_spouts.size();
}
public void put_to_state_spouts(int key, StateSpoutSpec val) {
if (this.state_spouts == null) {
this.state_spouts = new HashMap<Integer,StateSpoutSpec>();
}
this.state_spouts.put(key, val);
}
public Map<Integer,StateSpoutSpec> get_state_spouts() {
return this.state_spouts;
}
public void set_state_spouts(Map<Integer,StateSpoutSpec> state_spouts) {
this.state_spouts = state_spouts;
}
public void unset_state_spouts() {
this.state_spouts = null;
}
/** Returns true if field state_spouts is set (has been asigned a value) and false otherwise */
public boolean is_set_state_spouts() {
return this.state_spouts != null;
}
public void set_state_spouts_isSet(boolean value) {
if (!value) {
this.state_spouts = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SPOUTS:
if (value == null) {
unset_spouts();
} else {
set_spouts((Map<Integer,SpoutSpec>)value);
}
break;
case BOLTS:
if (value == null) {
unset_bolts();
} else {
set_bolts((Map<Integer,Bolt>)value);
}
break;
case STATE_SPOUTS:
if (value == null) {
unset_state_spouts();
} else {
set_state_spouts((Map<Integer,StateSpoutSpec>)value);
}
break;
}
}
public void setFieldValue(int fieldID, Object value) {
setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
}
public Object getFieldValue(_Fields field) {
switch (field) {
case SPOUTS:
return get_spouts();
case BOLTS:
return get_bolts();
case STATE_SPOUTS:
return get_state_spouts();
}
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 SPOUTS:
return is_set_spouts();
case BOLTS:
return is_set_bolts();
case STATE_SPOUTS:
return is_set_state_spouts();
}
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 StormTopology)
return this.equals((StormTopology)that);
return false;
}
public boolean equals(StormTopology that) {
if (that == null)
return false;
boolean this_present_spouts = true && this.is_set_spouts();
boolean that_present_spouts = true && that.is_set_spouts();
if (this_present_spouts || that_present_spouts) {
if (!(this_present_spouts && that_present_spouts))
return false;
if (!this.spouts.equals(that.spouts))
return false;
}
boolean this_present_bolts = true && this.is_set_bolts();
boolean that_present_bolts = true && that.is_set_bolts();
if (this_present_bolts || that_present_bolts) {
if (!(this_present_bolts && that_present_bolts))
return false;
if (!this.bolts.equals(that.bolts))
return false;
}
boolean this_present_state_spouts = true && this.is_set_state_spouts();
boolean that_present_state_spouts = true && that.is_set_state_spouts();
if (this_present_state_spouts || that_present_state_spouts) {
if (!(this_present_state_spouts && that_present_state_spouts))
return false;
if (!this.state_spouts.equals(that.state_spouts))
return false;
}
return true;
}
@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_spouts = true && (is_set_spouts());
builder.append(present_spouts);
if (present_spouts)
builder.append(spouts);
boolean present_bolts = true && (is_set_bolts());
builder.append(present_bolts);
if (present_bolts)
builder.append(bolts);
boolean present_state_spouts = true && (is_set_state_spouts());
builder.append(present_state_spouts);
if (present_state_spouts)
builder.append(state_spouts);
return builder.toHashCode();
}
public int compareTo(StormTopology other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
StormTopology typedOther = (StormTopology)other;
lastComparison = Boolean.valueOf(is_set_spouts()).compareTo(typedOther.is_set_spouts());
if (lastComparison != 0) {
return lastComparison;
}
if (is_set_spouts()) { lastComparison = TBaseHelper.compareTo(this.spouts, typedOther.spouts);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(is_set_bolts()).compareTo(typedOther.is_set_bolts());
if (lastComparison != 0) {
return lastComparison;
}
if (is_set_bolts()) { lastComparison = TBaseHelper.compareTo(this.bolts, typedOther.bolts);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(is_set_state_spouts()).compareTo(typedOther.is_set_state_spouts());
if (lastComparison != 0) {
return lastComparison;
}
if (is_set_state_spouts()) { lastComparison = TBaseHelper.compareTo(this.state_spouts, typedOther.state_spouts);
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: // SPOUTS
if (field.type == TType.MAP) {
{
TMap _map18 = iprot.readMapBegin();
this.spouts = new HashMap<Integer,SpoutSpec>(2*_map18.size);
for (int _i19 = 0; _i19 < _map18.size; ++_i19)
{
int _key20;
SpoutSpec _val21;
_key20 = iprot.readI32();
_val21 = new SpoutSpec();
_val21.read(iprot);
this.spouts.put(_key20, _val21);
}
iprot.readMapEnd();
}
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // BOLTS
if (field.type == TType.MAP) {
{
TMap _map22 = iprot.readMapBegin();
this.bolts = new HashMap<Integer,Bolt>(2*_map22.size);
for (int _i23 = 0; _i23 < _map22.size; ++_i23)
{
int _key24;
Bolt _val25;
_key24 = iprot.readI32();
_val25 = new Bolt();
_val25.read(iprot);
this.bolts.put(_key24, _val25);
}
iprot.readMapEnd();
}
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // STATE_SPOUTS
if (field.type == TType.MAP) {
{
TMap _map26 = iprot.readMapBegin();
this.state_spouts = new HashMap<Integer,StateSpoutSpec>(2*_map26.size);
for (int _i27 = 0; _i27 < _map26.size; ++_i27)
{
int _key28;
StateSpoutSpec _val29;
_key28 = iprot.readI32();
_val29 = new StateSpoutSpec();
_val29.read(iprot);
this.state_spouts.put(_key28, _val29);
}
iprot.readMapEnd();
}
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
validate();
}
public void write(TProtocol oprot) throws TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.spouts != null) {
oprot.writeFieldBegin(SPOUTS_FIELD_DESC);
{
oprot.writeMapBegin(new TMap(TType.I32, TType.STRUCT, this.spouts.size()));
for (Map.Entry<Integer, SpoutSpec> _iter30 : this.spouts.entrySet())
{
oprot.writeI32(_iter30.getKey());
_iter30.getValue().write(oprot);
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
if (this.bolts != null) {
oprot.writeFieldBegin(BOLTS_FIELD_DESC);
{
oprot.writeMapBegin(new TMap(TType.I32, TType.STRUCT, this.bolts.size()));
for (Map.Entry<Integer, Bolt> _iter31 : this.bolts.entrySet())
{
oprot.writeI32(_iter31.getKey());
_iter31.getValue().write(oprot);
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
if (this.state_spouts != null) {
oprot.writeFieldBegin(STATE_SPOUTS_FIELD_DESC);
{
oprot.writeMapBegin(new TMap(TType.I32, TType.STRUCT, this.state_spouts.size()));
for (Map.Entry<Integer, StateSpoutSpec> _iter32 : this.state_spouts.entrySet())
{
oprot.writeI32(_iter32.getKey());
_iter32.getValue().write(oprot);
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("StormTopology(");
boolean first = true;
sb.append("spouts:");
if (this.spouts == null) {
sb.append("null");
} else {
sb.append(this.spouts);
}
first = false;
if (!first) sb.append(", ");
sb.append("bolts:");
if (this.bolts == null) {
sb.append("null");
} else {
sb.append(this.bolts);
}
first = false;
if (!first) sb.append(", ");
sb.append("state_spouts:");
if (this.state_spouts == null) {
sb.append("null");
} else {
sb.append(this.state_spouts);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
if (!is_set_spouts()) {
throw new TProtocolException("Required field 'spouts' is unset! Struct:" + toString());
}
if (!is_set_bolts()) {
throw new TProtocolException("Required field 'bolts' is unset! Struct:" + toString());
}
if (!is_set_state_spouts()) {
throw new TProtocolException("Required field 'state_spouts' is unset! Struct:" + toString());
}
}
}