All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.iotdb.mpp.rpc.thrift.THeartbeatReq Maven / Gradle / Ivy

The newest version!
/**
 * Autogenerated by Thrift Compiler (0.14.1)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.apache.iotdb.mpp.rpc.thrift;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2023-04-20")
public class THeartbeatReq implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("THeartbeatReq");

  private static final org.apache.thrift.protocol.TField HEARTBEAT_TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("heartbeatTimestamp", org.apache.thrift.protocol.TType.I64, (short)1);
  private static final org.apache.thrift.protocol.TField NEED_JUDGE_LEADER_FIELD_DESC = new org.apache.thrift.protocol.TField("needJudgeLeader", org.apache.thrift.protocol.TType.BOOL, (short)2);
  private static final org.apache.thrift.protocol.TField NEED_SAMPLING_LOAD_FIELD_DESC = new org.apache.thrift.protocol.TField("needSamplingLoad", org.apache.thrift.protocol.TType.BOOL, (short)3);

  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new THeartbeatReqStandardSchemeFactory();
  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new THeartbeatReqTupleSchemeFactory();

  public long heartbeatTimestamp; // required
  public boolean needJudgeLeader; // required
  public boolean needSamplingLoad; // 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 {
    HEARTBEAT_TIMESTAMP((short)1, "heartbeatTimestamp"),
    NEED_JUDGE_LEADER((short)2, "needJudgeLeader"),
    NEED_SAMPLING_LOAD((short)3, "needSamplingLoad");

    private static final java.util.Map byName = new java.util.HashMap();

    static {
      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // HEARTBEAT_TIMESTAMP
          return HEARTBEAT_TIMESTAMP;
        case 2: // NEED_JUDGE_LEADER
          return NEED_JUDGE_LEADER;
        case 3: // NEED_SAMPLING_LOAD
          return NEED_SAMPLING_LOAD;
        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 java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByName(java.lang.String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final java.lang.String _fieldName;

    _Fields(short thriftId, java.lang.String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public java.lang.String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __HEARTBEATTIMESTAMP_ISSET_ID = 0;
  private static final int __NEEDJUDGELEADER_ISSET_ID = 1;
  private static final int __NEEDSAMPLINGLOAD_ISSET_ID = 2;
  private byte __isset_bitfield = 0;
  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.HEARTBEAT_TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("heartbeatTimestamp", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.NEED_JUDGE_LEADER, new org.apache.thrift.meta_data.FieldMetaData("needJudgeLeader", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.NEED_SAMPLING_LOAD, new org.apache.thrift.meta_data.FieldMetaData("needSamplingLoad", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(THeartbeatReq.class, metaDataMap);
  }

  public THeartbeatReq() {
  }

  public THeartbeatReq(
    long heartbeatTimestamp,
    boolean needJudgeLeader,
    boolean needSamplingLoad)
  {
    this();
    this.heartbeatTimestamp = heartbeatTimestamp;
    setHeartbeatTimestampIsSet(true);
    this.needJudgeLeader = needJudgeLeader;
    setNeedJudgeLeaderIsSet(true);
    this.needSamplingLoad = needSamplingLoad;
    setNeedSamplingLoadIsSet(true);
  }

  /**
   * Performs a deep copy on other.
   */
  public THeartbeatReq(THeartbeatReq other) {
    __isset_bitfield = other.__isset_bitfield;
    this.heartbeatTimestamp = other.heartbeatTimestamp;
    this.needJudgeLeader = other.needJudgeLeader;
    this.needSamplingLoad = other.needSamplingLoad;
  }

  public THeartbeatReq deepCopy() {
    return new THeartbeatReq(this);
  }

  @Override
  public void clear() {
    setHeartbeatTimestampIsSet(false);
    this.heartbeatTimestamp = 0;
    setNeedJudgeLeaderIsSet(false);
    this.needJudgeLeader = false;
    setNeedSamplingLoadIsSet(false);
    this.needSamplingLoad = false;
  }

  public long getHeartbeatTimestamp() {
    return this.heartbeatTimestamp;
  }

  public THeartbeatReq setHeartbeatTimestamp(long heartbeatTimestamp) {
    this.heartbeatTimestamp = heartbeatTimestamp;
    setHeartbeatTimestampIsSet(true);
    return this;
  }

  public void unsetHeartbeatTimestamp() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __HEARTBEATTIMESTAMP_ISSET_ID);
  }

  /** Returns true if field heartbeatTimestamp is set (has been assigned a value) and false otherwise */
  public boolean isSetHeartbeatTimestamp() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __HEARTBEATTIMESTAMP_ISSET_ID);
  }

  public void setHeartbeatTimestampIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __HEARTBEATTIMESTAMP_ISSET_ID, value);
  }

  public boolean isNeedJudgeLeader() {
    return this.needJudgeLeader;
  }

  public THeartbeatReq setNeedJudgeLeader(boolean needJudgeLeader) {
    this.needJudgeLeader = needJudgeLeader;
    setNeedJudgeLeaderIsSet(true);
    return this;
  }

  public void unsetNeedJudgeLeader() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __NEEDJUDGELEADER_ISSET_ID);
  }

  /** Returns true if field needJudgeLeader is set (has been assigned a value) and false otherwise */
  public boolean isSetNeedJudgeLeader() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __NEEDJUDGELEADER_ISSET_ID);
  }

  public void setNeedJudgeLeaderIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __NEEDJUDGELEADER_ISSET_ID, value);
  }

  public boolean isNeedSamplingLoad() {
    return this.needSamplingLoad;
  }

  public THeartbeatReq setNeedSamplingLoad(boolean needSamplingLoad) {
    this.needSamplingLoad = needSamplingLoad;
    setNeedSamplingLoadIsSet(true);
    return this;
  }

  public void unsetNeedSamplingLoad() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __NEEDSAMPLINGLOAD_ISSET_ID);
  }

  /** Returns true if field needSamplingLoad is set (has been assigned a value) and false otherwise */
  public boolean isSetNeedSamplingLoad() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __NEEDSAMPLINGLOAD_ISSET_ID);
  }

  public void setNeedSamplingLoadIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __NEEDSAMPLINGLOAD_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case HEARTBEAT_TIMESTAMP:
      if (value == null) {
        unsetHeartbeatTimestamp();
      } else {
        setHeartbeatTimestamp((java.lang.Long)value);
      }
      break;

    case NEED_JUDGE_LEADER:
      if (value == null) {
        unsetNeedJudgeLeader();
      } else {
        setNeedJudgeLeader((java.lang.Boolean)value);
      }
      break;

    case NEED_SAMPLING_LOAD:
      if (value == null) {
        unsetNeedSamplingLoad();
      } else {
        setNeedSamplingLoad((java.lang.Boolean)value);
      }
      break;

    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
    case HEARTBEAT_TIMESTAMP:
      return getHeartbeatTimestamp();

    case NEED_JUDGE_LEADER:
      return isNeedJudgeLeader();

    case NEED_SAMPLING_LOAD:
      return isNeedSamplingLoad();

    }
    throw new java.lang.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 java.lang.IllegalArgumentException();
    }

    switch (field) {
    case HEARTBEAT_TIMESTAMP:
      return isSetHeartbeatTimestamp();
    case NEED_JUDGE_LEADER:
      return isSetNeedJudgeLeader();
    case NEED_SAMPLING_LOAD:
      return isSetNeedSamplingLoad();
    }
    throw new java.lang.IllegalStateException();
  }

  @Override
  public boolean equals(java.lang.Object that) {
    if (that instanceof THeartbeatReq)
      return this.equals((THeartbeatReq)that);
    return false;
  }

  public boolean equals(THeartbeatReq that) {
    if (that == null)
      return false;
    if (this == that)
      return true;

    boolean this_present_heartbeatTimestamp = true;
    boolean that_present_heartbeatTimestamp = true;
    if (this_present_heartbeatTimestamp || that_present_heartbeatTimestamp) {
      if (!(this_present_heartbeatTimestamp && that_present_heartbeatTimestamp))
        return false;
      if (this.heartbeatTimestamp != that.heartbeatTimestamp)
        return false;
    }

    boolean this_present_needJudgeLeader = true;
    boolean that_present_needJudgeLeader = true;
    if (this_present_needJudgeLeader || that_present_needJudgeLeader) {
      if (!(this_present_needJudgeLeader && that_present_needJudgeLeader))
        return false;
      if (this.needJudgeLeader != that.needJudgeLeader)
        return false;
    }

    boolean this_present_needSamplingLoad = true;
    boolean that_present_needSamplingLoad = true;
    if (this_present_needSamplingLoad || that_present_needSamplingLoad) {
      if (!(this_present_needSamplingLoad && that_present_needSamplingLoad))
        return false;
      if (this.needSamplingLoad != that.needSamplingLoad)
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int hashCode = 1;

    hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(heartbeatTimestamp);

    hashCode = hashCode * 8191 + ((needJudgeLeader) ? 131071 : 524287);

    hashCode = hashCode * 8191 + ((needSamplingLoad) ? 131071 : 524287);

    return hashCode;
  }

  @Override
  public int compareTo(THeartbeatReq other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetHeartbeatTimestamp(), other.isSetHeartbeatTimestamp());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetHeartbeatTimestamp()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.heartbeatTimestamp, other.heartbeatTimestamp);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetNeedJudgeLeader(), other.isSetNeedJudgeLeader());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNeedJudgeLeader()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.needJudgeLeader, other.needJudgeLeader);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetNeedSamplingLoad(), other.isSetNeedSamplingLoad());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNeedSamplingLoad()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.needSamplingLoad, other.needSamplingLoad);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  @org.apache.thrift.annotation.Nullable
  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    scheme(iprot).read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    scheme(oprot).write(oprot, this);
  }

  @Override
  public java.lang.String toString() {
    java.lang.StringBuilder sb = new java.lang.StringBuilder("THeartbeatReq(");
    boolean first = true;

    sb.append("heartbeatTimestamp:");
    sb.append(this.heartbeatTimestamp);
    first = false;
    if (!first) sb.append(", ");
    sb.append("needJudgeLeader:");
    sb.append(this.needJudgeLeader);
    first = false;
    if (!first) sb.append(", ");
    sb.append("needSamplingLoad:");
    sb.append(this.needSamplingLoad);
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // alas, we cannot check 'heartbeatTimestamp' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'needJudgeLeader' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'needSamplingLoad' because it's a primitive and you chose the non-beans generator.
    // check for sub-struct validity
  }

  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, java.lang.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_bitfield = 0;
      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 THeartbeatReqStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public THeartbeatReqStandardScheme getScheme() {
      return new THeartbeatReqStandardScheme();
    }
  }

  private static class THeartbeatReqStandardScheme extends org.apache.thrift.scheme.StandardScheme {

    public void read(org.apache.thrift.protocol.TProtocol iprot, THeartbeatReq 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: // HEARTBEAT_TIMESTAMP
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.heartbeatTimestamp = iprot.readI64();
              struct.setHeartbeatTimestampIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // NEED_JUDGE_LEADER
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.needJudgeLeader = iprot.readBool();
              struct.setNeedJudgeLeaderIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // NEED_SAMPLING_LOAD
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.needSamplingLoad = iprot.readBool();
              struct.setNeedSamplingLoadIsSet(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();

      // check for required fields of primitive type, which can't be checked in the validate method
      if (!struct.isSetHeartbeatTimestamp()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'heartbeatTimestamp' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetNeedJudgeLeader()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'needJudgeLeader' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetNeedSamplingLoad()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'needSamplingLoad' was not found in serialized data! Struct: " + toString());
      }
      struct.validate();
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot, THeartbeatReq struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(HEARTBEAT_TIMESTAMP_FIELD_DESC);
      oprot.writeI64(struct.heartbeatTimestamp);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(NEED_JUDGE_LEADER_FIELD_DESC);
      oprot.writeBool(struct.needJudgeLeader);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(NEED_SAMPLING_LOAD_FIELD_DESC);
      oprot.writeBool(struct.needSamplingLoad);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class THeartbeatReqTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public THeartbeatReqTupleScheme getScheme() {
      return new THeartbeatReqTupleScheme();
    }
  }

  private static class THeartbeatReqTupleScheme extends org.apache.thrift.scheme.TupleScheme {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, THeartbeatReq struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      oprot.writeI64(struct.heartbeatTimestamp);
      oprot.writeBool(struct.needJudgeLeader);
      oprot.writeBool(struct.needSamplingLoad);
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, THeartbeatReq struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      struct.heartbeatTimestamp = iprot.readI64();
      struct.setHeartbeatTimestampIsSet(true);
      struct.needJudgeLeader = iprot.readBool();
      struct.setNeedJudgeLeaderIsSet(true);
      struct.needSamplingLoad = iprot.readBool();
      struct.setNeedSamplingLoadIsSet(true);
    }
  }

  private static  S scheme(org.apache.thrift.protocol.TProtocol proto) {
    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy