/** * 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. */ /** * Autogenerated by Thrift Compiler (0.9.2) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package backtype.storm.generated; import org.apache.thrift.scheme.IScheme; import org.apache.thrift.scheme.SchemeFactory; import org.apache.thrift.scheme.StandardScheme; import org.apache.thrift.scheme.TupleScheme; import org.apache.thrift.protocol.TTupleProtocol; import org.apache.thrift.protocol.TProtocolException; import org.apache.thrift.EncodingUtils; import org.apache.thrift.TException; import org.apache.thrift.async.AsyncMethodCallback; import org.apache.thrift.server.AbstractNonblockingServer.*; 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 javax.annotation.Generated; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) @Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-2-22") public class SupervisorWorkers implements org.apache.thrift.TBase<SupervisorWorkers, SupervisorWorkers._Fields>, java.io.Serializable, Cloneable, Comparable<SupervisorWorkers> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SupervisorWorkers"); private static final org.apache.thrift.protocol.TField SUPERVISOR_FIELD_DESC = new org.apache.thrift.protocol.TField("supervisor", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.protocol.TField WORKERS_FIELD_DESC = new org.apache.thrift.protocol.TField("workers", org.apache.thrift.protocol.TType.LIST, (short)2); private static final org.apache.thrift.protocol.TField WORKER_METRIC_FIELD_DESC = new org.apache.thrift.protocol.TField("workerMetric", org.apache.thrift.protocol.TType.MAP, (short)3); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new SupervisorWorkersStandardSchemeFactory()); schemes.put(TupleScheme.class, new SupervisorWorkersTupleSchemeFactory()); } private SupervisorSummary supervisor; // required private List<WorkerSummary> workers; // required private Map<String,MetricInfo> workerMetric; // 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 { SUPERVISOR((short)1, "supervisor"), WORKERS((short)2, "workers"), WORKER_METRIC((short)3, "workerMetric"); 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: // SUPERVISOR return SUPERVISOR; case 2: // WORKERS return WORKERS; case 3: // WORKER_METRIC return WORKER_METRIC; 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, 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.SUPERVISOR, new org.apache.thrift.meta_data.FieldMetaData("supervisor", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, SupervisorSummary.class))); tmpMap.put(_Fields.WORKERS, new org.apache.thrift.meta_data.FieldMetaData("workers", org.apache.thrift.TFieldRequirementType.REQUIRED, 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, WorkerSummary.class)))); tmpMap.put(_Fields.WORKER_METRIC, new org.apache.thrift.meta_data.FieldMetaData("workerMetric", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, MetricInfo.class)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(SupervisorWorkers.class, metaDataMap); } public SupervisorWorkers() { } public SupervisorWorkers( SupervisorSummary supervisor, List<WorkerSummary> workers, Map<String,MetricInfo> workerMetric) { this(); this.supervisor = supervisor; this.workers = workers; this.workerMetric = workerMetric; } /** * Performs a deep copy on <i>other</i>. */ public SupervisorWorkers(SupervisorWorkers other) { if (other.is_set_supervisor()) { this.supervisor = new SupervisorSummary(other.supervisor); } if (other.is_set_workers()) { List<WorkerSummary> __this__workers = new ArrayList<WorkerSummary>(other.workers.size()); for (WorkerSummary other_element : other.workers) { __this__workers.add(new WorkerSummary(other_element)); } this.workers = __this__workers; } if (other.is_set_workerMetric()) { Map<String,MetricInfo> __this__workerMetric = new HashMap<String,MetricInfo>(other.workerMetric.size()); for (Map.Entry<String, MetricInfo> other_element : other.workerMetric.entrySet()) { String other_element_key = other_element.getKey(); MetricInfo other_element_value = other_element.getValue(); String __this__workerMetric_copy_key = other_element_key; MetricInfo __this__workerMetric_copy_value = new MetricInfo(other_element_value); __this__workerMetric.put(__this__workerMetric_copy_key, __this__workerMetric_copy_value); } this.workerMetric = __this__workerMetric; } } public SupervisorWorkers deepCopy() { return new SupervisorWorkers(this); } @Override public void clear() { this.supervisor = null; this.workers = null; this.workerMetric = null; } public SupervisorSummary get_supervisor() { return this.supervisor; } public void set_supervisor(SupervisorSummary supervisor) { this.supervisor = supervisor; } public void unset_supervisor() { this.supervisor = null; } /** Returns true if field supervisor is set (has been assigned a value) and false otherwise */ public boolean is_set_supervisor() { return this.supervisor != null; } public void set_supervisor_isSet(boolean value) { if (!value) { this.supervisor = null; } } public int get_workers_size() { return (this.workers == null) ? 0 : this.workers.size(); } public java.util.Iterator<WorkerSummary> get_workers_iterator() { return (this.workers == null) ? null : this.workers.iterator(); } public void add_to_workers(WorkerSummary elem) { if (this.workers == null) { this.workers = new ArrayList<WorkerSummary>(); } this.workers.add(elem); } public List<WorkerSummary> get_workers() { return this.workers; } public void set_workers(List<WorkerSummary> workers) { this.workers = workers; } public void unset_workers() { this.workers = null; } /** Returns true if field workers is set (has been assigned a value) and false otherwise */ public boolean is_set_workers() { return this.workers != null; } public void set_workers_isSet(boolean value) { if (!value) { this.workers = null; } } public int get_workerMetric_size() { return (this.workerMetric == null) ? 0 : this.workerMetric.size(); } public void put_to_workerMetric(String key, MetricInfo val) { if (this.workerMetric == null) { this.workerMetric = new HashMap<String,MetricInfo>(); } this.workerMetric.put(key, val); } public Map<String,MetricInfo> get_workerMetric() { return this.workerMetric; } public void set_workerMetric(Map<String,MetricInfo> workerMetric) { this.workerMetric = workerMetric; } public void unset_workerMetric() { this.workerMetric = null; } /** Returns true if field workerMetric is set (has been assigned a value) and false otherwise */ public boolean is_set_workerMetric() { return this.workerMetric != null; } public void set_workerMetric_isSet(boolean value) { if (!value) { this.workerMetric = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case SUPERVISOR: if (value == null) { unset_supervisor(); } else { set_supervisor((SupervisorSummary)value); } break; case WORKERS: if (value == null) { unset_workers(); } else { set_workers((List<WorkerSummary>)value); } break; case WORKER_METRIC: if (value == null) { unset_workerMetric(); } else { set_workerMetric((Map<String,MetricInfo>)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case SUPERVISOR: return get_supervisor(); case WORKERS: return get_workers(); case WORKER_METRIC: return get_workerMetric(); } 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 SUPERVISOR: return is_set_supervisor(); case WORKERS: return is_set_workers(); case WORKER_METRIC: return is_set_workerMetric(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof SupervisorWorkers) return this.equals((SupervisorWorkers)that); return false; } public boolean equals(SupervisorWorkers that) { if (that == null) return false; boolean this_present_supervisor = true && this.is_set_supervisor(); boolean that_present_supervisor = true && that.is_set_supervisor(); if (this_present_supervisor || that_present_supervisor) { if (!(this_present_supervisor && that_present_supervisor)) return false; if (!this.supervisor.equals(that.supervisor)) return false; } boolean this_present_workers = true && this.is_set_workers(); boolean that_present_workers = true && that.is_set_workers(); if (this_present_workers || that_present_workers) { if (!(this_present_workers && that_present_workers)) return false; if (!this.workers.equals(that.workers)) return false; } boolean this_present_workerMetric = true && this.is_set_workerMetric(); boolean that_present_workerMetric = true && that.is_set_workerMetric(); if (this_present_workerMetric || that_present_workerMetric) { if (!(this_present_workerMetric && that_present_workerMetric)) return false; if (!this.workerMetric.equals(that.workerMetric)) return false; } return true; } @Override public int hashCode() { List<Object> list = new ArrayList<Object>(); boolean present_supervisor = true && (is_set_supervisor()); list.add(present_supervisor); if (present_supervisor) list.add(supervisor); boolean present_workers = true && (is_set_workers()); list.add(present_workers); if (present_workers) list.add(workers); boolean present_workerMetric = true && (is_set_workerMetric()); list.add(present_workerMetric); if (present_workerMetric) list.add(workerMetric); return list.hashCode(); } @Override public int compareTo(SupervisorWorkers other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(is_set_supervisor()).compareTo(other.is_set_supervisor()); if (lastComparison != 0) { return lastComparison; } if (is_set_supervisor()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.supervisor, other.supervisor); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(is_set_workers()).compareTo(other.is_set_workers()); if (lastComparison != 0) { return lastComparison; } if (is_set_workers()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.workers, other.workers); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(is_set_workerMetric()).compareTo(other.is_set_workerMetric()); if (lastComparison != 0) { return lastComparison; } if (is_set_workerMetric()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.workerMetric, other.workerMetric); 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 { schemes.get(iprot.getScheme()).getScheme().read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { schemes.get(oprot.getScheme()).getScheme().write(oprot, this); } @Override public String toString() { StringBuilder sb = new StringBuilder("SupervisorWorkers("); boolean first = true; sb.append("supervisor:"); if (this.supervisor == null) { sb.append("null"); } else { sb.append(this.supervisor); } first = false; if (!first) sb.append(", "); sb.append("workers:"); if (this.workers == null) { sb.append("null"); } else { sb.append(this.workers); } first = false; if (!first) sb.append(", "); sb.append("workerMetric:"); if (this.workerMetric == null) { sb.append("null"); } else { sb.append(this.workerMetric); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if (!is_set_supervisor()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'supervisor' is unset! Struct:" + toString()); } if (!is_set_workers()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'workers' is unset! Struct:" + toString()); } if (!is_set_workerMetric()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'workerMetric' is unset! Struct:" + toString()); } // check for sub-struct validity if (supervisor != null) { supervisor.validate(); } } 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 { 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); } } private static class SupervisorWorkersStandardSchemeFactory implements SchemeFactory { public SupervisorWorkersStandardScheme getScheme() { return new SupervisorWorkersStandardScheme(); } } private static class SupervisorWorkersStandardScheme extends StandardScheme<SupervisorWorkers> { public void read(org.apache.thrift.protocol.TProtocol iprot, SupervisorWorkers struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // SUPERVISOR if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.supervisor = new SupervisorSummary(); struct.supervisor.read(iprot); struct.set_supervisor_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // WORKERS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list136 = iprot.readListBegin(); struct.workers = new ArrayList<WorkerSummary>(_list136.size); WorkerSummary _elem137; for (int _i138 = 0; _i138 < _list136.size; ++_i138) { _elem137 = new WorkerSummary(); _elem137.read(iprot); struct.workers.add(_elem137); } iprot.readListEnd(); } struct.set_workers_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // WORKER_METRIC if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { org.apache.thrift.protocol.TMap _map139 = iprot.readMapBegin(); struct.workerMetric = new HashMap<String,MetricInfo>(2*_map139.size); String _key140; MetricInfo _val141; for (int _i142 = 0; _i142 < _map139.size; ++_i142) { _key140 = iprot.readString(); _val141 = new MetricInfo(); _val141.read(iprot); struct.workerMetric.put(_key140, _val141); } iprot.readMapEnd(); } struct.set_workerMetric_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, SupervisorWorkers struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.supervisor != null) { oprot.writeFieldBegin(SUPERVISOR_FIELD_DESC); struct.supervisor.write(oprot); oprot.writeFieldEnd(); } if (struct.workers != null) { oprot.writeFieldBegin(WORKERS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.workers.size())); for (WorkerSummary _iter143 : struct.workers) { _iter143.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } if (struct.workerMetric != null) { oprot.writeFieldBegin(WORKER_METRIC_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, struct.workerMetric.size())); for (Map.Entry<String, MetricInfo> _iter144 : struct.workerMetric.entrySet()) { oprot.writeString(_iter144.getKey()); _iter144.getValue().write(oprot); } oprot.writeMapEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class SupervisorWorkersTupleSchemeFactory implements SchemeFactory { public SupervisorWorkersTupleScheme getScheme() { return new SupervisorWorkersTupleScheme(); } } private static class SupervisorWorkersTupleScheme extends TupleScheme<SupervisorWorkers> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, SupervisorWorkers struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; struct.supervisor.write(oprot); { oprot.writeI32(struct.workers.size()); for (WorkerSummary _iter145 : struct.workers) { _iter145.write(oprot); } } { oprot.writeI32(struct.workerMetric.size()); for (Map.Entry<String, MetricInfo> _iter146 : struct.workerMetric.entrySet()) { oprot.writeString(_iter146.getKey()); _iter146.getValue().write(oprot); } } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, SupervisorWorkers struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.supervisor = new SupervisorSummary(); struct.supervisor.read(iprot); struct.set_supervisor_isSet(true); { org.apache.thrift.protocol.TList _list147 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.workers = new ArrayList<WorkerSummary>(_list147.size); WorkerSummary _elem148; for (int _i149 = 0; _i149 < _list147.size; ++_i149) { _elem148 = new WorkerSummary(); _elem148.read(iprot); struct.workers.add(_elem148); } } struct.set_workers_isSet(true); { org.apache.thrift.protocol.TMap _map150 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.workerMetric = new HashMap<String,MetricInfo>(2*_map150.size); String _key151; MetricInfo _val152; for (int _i153 = 0; _i153 < _map150.size; ++_i153) { _key151 = iprot.readString(); _val152 = new MetricInfo(); _val152.read(iprot); struct.workerMetric.put(_key151, _val152); } } struct.set_workerMetric_isSet(true); } } }