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

org.apache.iotdb.common.rpc.thrift.TThrottleQuota 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.common.rpc.thrift;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2024-09-12")
public class TThrottleQuota 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("TThrottleQuota");

  private static final org.apache.thrift.protocol.TField THROTTLE_LIMIT_FIELD_DESC = new org.apache.thrift.protocol.TField("throttleLimit", org.apache.thrift.protocol.TType.MAP, (short)1);
  private static final org.apache.thrift.protocol.TField MEM_LIMIT_FIELD_DESC = new org.apache.thrift.protocol.TField("memLimit", org.apache.thrift.protocol.TType.I64, (short)2);
  private static final org.apache.thrift.protocol.TField CPU_LIMIT_FIELD_DESC = new org.apache.thrift.protocol.TField("cpuLimit", org.apache.thrift.protocol.TType.I32, (short)3);

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

  public @org.apache.thrift.annotation.Nullable java.util.Map throttleLimit; // optional
  public long memLimit; // optional
  public int cpuLimit; // optional

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    THROTTLE_LIMIT((short)1, "throttleLimit"),
    MEM_LIMIT((short)2, "memLimit"),
    CPU_LIMIT((short)3, "cpuLimit");

    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: // THROTTLE_LIMIT
          return THROTTLE_LIMIT;
        case 2: // MEM_LIMIT
          return MEM_LIMIT;
        case 3: // CPU_LIMIT
          return CPU_LIMIT;
        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 __MEMLIMIT_ISSET_ID = 0;
  private static final int __CPULIMIT_ISSET_ID = 1;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.THROTTLE_LIMIT,_Fields.MEM_LIMIT,_Fields.CPU_LIMIT};
  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.THROTTLE_LIMIT, new org.apache.thrift.meta_data.FieldMetaData("throttleLimit", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
            new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, ThrottleType.class), 
            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TTimedQuota.class))));
    tmpMap.put(_Fields.MEM_LIMIT, new org.apache.thrift.meta_data.FieldMetaData("memLimit", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.CPU_LIMIT, new org.apache.thrift.meta_data.FieldMetaData("cpuLimit", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TThrottleQuota.class, metaDataMap);
  }

  public TThrottleQuota() {
  }

  /**
   * Performs a deep copy on other.
   */
  public TThrottleQuota(TThrottleQuota other) {
    __isset_bitfield = other.__isset_bitfield;
    if (other.isSetThrottleLimit()) {
      java.util.Map __this__throttleLimit = new java.util.EnumMap(ThrottleType.class);
      for (java.util.Map.Entry other_element : other.throttleLimit.entrySet()) {

        ThrottleType other_element_key = other_element.getKey();
        TTimedQuota other_element_value = other_element.getValue();

        ThrottleType __this__throttleLimit_copy_key = other_element_key;

        TTimedQuota __this__throttleLimit_copy_value = new TTimedQuota(other_element_value);

        __this__throttleLimit.put(__this__throttleLimit_copy_key, __this__throttleLimit_copy_value);
      }
      this.throttleLimit = __this__throttleLimit;
    }
    this.memLimit = other.memLimit;
    this.cpuLimit = other.cpuLimit;
  }

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

  @Override
  public void clear() {
    this.throttleLimit = null;
    setMemLimitIsSet(false);
    this.memLimit = 0;
    setCpuLimitIsSet(false);
    this.cpuLimit = 0;
  }

  public int getThrottleLimitSize() {
    return (this.throttleLimit == null) ? 0 : this.throttleLimit.size();
  }

  public void putToThrottleLimit(ThrottleType key, TTimedQuota val) {
    if (this.throttleLimit == null) {
      this.throttleLimit = new java.util.EnumMap(ThrottleType.class);
    }
    this.throttleLimit.put(key, val);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Map getThrottleLimit() {
    return this.throttleLimit;
  }

  public TThrottleQuota setThrottleLimit(@org.apache.thrift.annotation.Nullable java.util.Map throttleLimit) {
    this.throttleLimit = throttleLimit;
    return this;
  }

  public void unsetThrottleLimit() {
    this.throttleLimit = null;
  }

  /** Returns true if field throttleLimit is set (has been assigned a value) and false otherwise */
  public boolean isSetThrottleLimit() {
    return this.throttleLimit != null;
  }

  public void setThrottleLimitIsSet(boolean value) {
    if (!value) {
      this.throttleLimit = null;
    }
  }

  public long getMemLimit() {
    return this.memLimit;
  }

  public TThrottleQuota setMemLimit(long memLimit) {
    this.memLimit = memLimit;
    setMemLimitIsSet(true);
    return this;
  }

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

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

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

  public int getCpuLimit() {
    return this.cpuLimit;
  }

  public TThrottleQuota setCpuLimit(int cpuLimit) {
    this.cpuLimit = cpuLimit;
    setCpuLimitIsSet(true);
    return this;
  }

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

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

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

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case THROTTLE_LIMIT:
      if (value == null) {
        unsetThrottleLimit();
      } else {
        setThrottleLimit((java.util.Map)value);
      }
      break;

    case MEM_LIMIT:
      if (value == null) {
        unsetMemLimit();
      } else {
        setMemLimit((java.lang.Long)value);
      }
      break;

    case CPU_LIMIT:
      if (value == null) {
        unsetCpuLimit();
      } else {
        setCpuLimit((java.lang.Integer)value);
      }
      break;

    }
  }

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

    case MEM_LIMIT:
      return getMemLimit();

    case CPU_LIMIT:
      return getCpuLimit();

    }
    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 THROTTLE_LIMIT:
      return isSetThrottleLimit();
    case MEM_LIMIT:
      return isSetMemLimit();
    case CPU_LIMIT:
      return isSetCpuLimit();
    }
    throw new java.lang.IllegalStateException();
  }

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

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

    boolean this_present_throttleLimit = true && this.isSetThrottleLimit();
    boolean that_present_throttleLimit = true && that.isSetThrottleLimit();
    if (this_present_throttleLimit || that_present_throttleLimit) {
      if (!(this_present_throttleLimit && that_present_throttleLimit))
        return false;
      if (!this.throttleLimit.equals(that.throttleLimit))
        return false;
    }

    boolean this_present_memLimit = true && this.isSetMemLimit();
    boolean that_present_memLimit = true && that.isSetMemLimit();
    if (this_present_memLimit || that_present_memLimit) {
      if (!(this_present_memLimit && that_present_memLimit))
        return false;
      if (this.memLimit != that.memLimit)
        return false;
    }

    boolean this_present_cpuLimit = true && this.isSetCpuLimit();
    boolean that_present_cpuLimit = true && that.isSetCpuLimit();
    if (this_present_cpuLimit || that_present_cpuLimit) {
      if (!(this_present_cpuLimit && that_present_cpuLimit))
        return false;
      if (this.cpuLimit != that.cpuLimit)
        return false;
    }

    return true;
  }

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

    hashCode = hashCode * 8191 + ((isSetThrottleLimit()) ? 131071 : 524287);
    if (isSetThrottleLimit())
      hashCode = hashCode * 8191 + throttleLimit.hashCode();

    hashCode = hashCode * 8191 + ((isSetMemLimit()) ? 131071 : 524287);
    if (isSetMemLimit())
      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(memLimit);

    hashCode = hashCode * 8191 + ((isSetCpuLimit()) ? 131071 : 524287);
    if (isSetCpuLimit())
      hashCode = hashCode * 8191 + cpuLimit;

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetThrottleLimit(), other.isSetThrottleLimit());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetThrottleLimit()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.throttleLimit, other.throttleLimit);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetMemLimit(), other.isSetMemLimit());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMemLimit()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.memLimit, other.memLimit);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetCpuLimit(), other.isSetCpuLimit());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCpuLimit()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cpuLimit, other.cpuLimit);
      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("TThrottleQuota(");
    boolean first = true;

    if (isSetThrottleLimit()) {
      sb.append("throttleLimit:");
      if (this.throttleLimit == null) {
        sb.append("null");
      } else {
        sb.append(this.throttleLimit);
      }
      first = false;
    }
    if (isSetMemLimit()) {
      if (!first) sb.append(", ");
      sb.append("memLimit:");
      sb.append(this.memLimit);
      first = false;
    }
    if (isSetCpuLimit()) {
      if (!first) sb.append(", ");
      sb.append("cpuLimit:");
      sb.append(this.cpuLimit);
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // 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 TThrottleQuotaStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public TThrottleQuotaStandardScheme getScheme() {
      return new TThrottleQuotaStandardScheme();
    }
  }

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

    public void read(org.apache.thrift.protocol.TProtocol iprot, TThrottleQuota 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: // THROTTLE_LIMIT
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map66 = iprot.readMapBegin();
                struct.throttleLimit = new java.util.EnumMap(ThrottleType.class);
                @org.apache.thrift.annotation.Nullable ThrottleType _key67;
                @org.apache.thrift.annotation.Nullable TTimedQuota _val68;
                for (int _i69 = 0; _i69 < _map66.size; ++_i69)
                {
                  _key67 = org.apache.iotdb.common.rpc.thrift.ThrottleType.findByValue(iprot.readI32());
                  _val68 = new TTimedQuota();
                  _val68.read(iprot);
                  if (_key67 != null)
                  {
                    struct.throttleLimit.put(_key67, _val68);
                  }
                }
                iprot.readMapEnd();
              }
              struct.setThrottleLimitIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // MEM_LIMIT
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.memLimit = iprot.readI64();
              struct.setMemLimitIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // CPU_LIMIT
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.cpuLimit = iprot.readI32();
              struct.setCpuLimitIsSet(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
      struct.validate();
    }

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

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.throttleLimit != null) {
        if (struct.isSetThrottleLimit()) {
          oprot.writeFieldBegin(THROTTLE_LIMIT_FIELD_DESC);
          {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, struct.throttleLimit.size()));
            for (java.util.Map.Entry _iter70 : struct.throttleLimit.entrySet())
            {
              oprot.writeI32(_iter70.getKey().getValue());
              _iter70.getValue().write(oprot);
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.isSetMemLimit()) {
        oprot.writeFieldBegin(MEM_LIMIT_FIELD_DESC);
        oprot.writeI64(struct.memLimit);
        oprot.writeFieldEnd();
      }
      if (struct.isSetCpuLimit()) {
        oprot.writeFieldBegin(CPU_LIMIT_FIELD_DESC);
        oprot.writeI32(struct.cpuLimit);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

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

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

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TThrottleQuota struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet optionals = new java.util.BitSet();
      if (struct.isSetThrottleLimit()) {
        optionals.set(0);
      }
      if (struct.isSetMemLimit()) {
        optionals.set(1);
      }
      if (struct.isSetCpuLimit()) {
        optionals.set(2);
      }
      oprot.writeBitSet(optionals, 3);
      if (struct.isSetThrottleLimit()) {
        {
          oprot.writeI32(struct.throttleLimit.size());
          for (java.util.Map.Entry _iter71 : struct.throttleLimit.entrySet())
          {
            oprot.writeI32(_iter71.getKey().getValue());
            _iter71.getValue().write(oprot);
          }
        }
      }
      if (struct.isSetMemLimit()) {
        oprot.writeI64(struct.memLimit);
      }
      if (struct.isSetCpuLimit()) {
        oprot.writeI32(struct.cpuLimit);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TThrottleQuota struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(3);
      if (incoming.get(0)) {
        {
          org.apache.thrift.protocol.TMap _map72 = iprot.readMapBegin(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT); 
          struct.throttleLimit = new java.util.EnumMap(ThrottleType.class);
          @org.apache.thrift.annotation.Nullable ThrottleType _key73;
          @org.apache.thrift.annotation.Nullable TTimedQuota _val74;
          for (int _i75 = 0; _i75 < _map72.size; ++_i75)
          {
            _key73 = org.apache.iotdb.common.rpc.thrift.ThrottleType.findByValue(iprot.readI32());
            _val74 = new TTimedQuota();
            _val74.read(iprot);
            if (_key73 != null)
            {
              struct.throttleLimit.put(_key73, _val74);
            }
          }
        }
        struct.setThrottleLimitIsSet(true);
      }
      if (incoming.get(1)) {
        struct.memLimit = iprot.readI64();
        struct.setMemLimitIsSet(true);
      }
      if (incoming.get(2)) {
        struct.cpuLimit = iprot.readI32();
        struct.setCpuLimitIsSet(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