com.twitter.zipkin.thriftjava.Endpoint Maven / Gradle / Ivy
 The newest version!
        
        /**
 * Copyright 2015-2016 The OpenZipkin Authors
 *
 * Licensed 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.3)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.twitter.zipkin.thriftjava;
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"})
/**
 * Indicates the network context of a service recording an annotation with two
 * exceptions.
 * 
 * When a BinaryAnnotation, and key is CLIENT_ADDR or SERVER_ADDR,
 * the endpoint indicates the source or destination of an RPC. This exception
 * allows zipkin to display network context of uninstrumented services, or
 * clients such as web browsers.
 */
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-10-26")
public class Endpoint 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("Endpoint");
  private static final org.apache.thrift.protocol.TField IPV4_FIELD_DESC = new org.apache.thrift.protocol.TField("ipv4", org.apache.thrift.protocol.TType.I32, (short)1);
  private static final org.apache.thrift.protocol.TField PORT_FIELD_DESC = new org.apache.thrift.protocol.TField("port", org.apache.thrift.protocol.TType.I16, (short)2);
  private static final org.apache.thrift.protocol.TField SERVICE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("service_name", org.apache.thrift.protocol.TType.STRING, (short)3);
  private static final org.apache.thrift.protocol.TField IPV6_FIELD_DESC = new org.apache.thrift.protocol.TField("ipv6", org.apache.thrift.protocol.TType.STRING, (short)4);
  private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>();
  static {
    schemes.put(StandardScheme.class, new EndpointStandardSchemeFactory());
    schemes.put(TupleScheme.class, new EndpointTupleSchemeFactory());
  }
  /**
   * IPv4 host address packed into 4 bytes.
   * 
   * Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4
   */
  public int ipv4; // required
  /**
   * IPv4 port or 0, if unknown.
   * 
   * Note: this is to be treated as an unsigned integer, so watch for negatives.
   */
  public short port; // required
  /**
   * Classifier of a source or destination in lowercase, such as "zipkin-web".
   * 
   * This is the primary parameter for trace lookup, so should be intuitive as
   * possible, for example, matching names in service discovery.
   * 
   * Conventionally, when the service name isn't known, service_name = "unknown".
   * However, it is also permissible to set service_name = "" (empty string).
   * The difference in the latter usage is that the span will not be queryable
   * by service name unless more information is added to the span with non-empty
   * service name, e.g. an additional annotation from the server.
   * 
   * Particularly clients may not have a reliable service name at ingest. One
   * approach is to set service_name to "" at ingest, and later assign a
   * better label based on binary annotations, such as user agent.
   */
  public String service_name; // required
  /**
   * IPv6 host address packed into 16 bytes. Ex Inet6Address.getBytes()
   */
  public ByteBuffer ipv6; // 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 {
    /**
     * IPv4 host address packed into 4 bytes.
     * 
     * Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4
     */
    IPV4((short)1, "ipv4"),
    /**
     * IPv4 port or 0, if unknown.
     * 
     * Note: this is to be treated as an unsigned integer, so watch for negatives.
     */
    PORT((short)2, "port"),
    /**
     * Classifier of a source or destination in lowercase, such as "zipkin-web".
     * 
     * This is the primary parameter for trace lookup, so should be intuitive as
     * possible, for example, matching names in service discovery.
     * 
     * Conventionally, when the service name isn't known, service_name = "unknown".
     * However, it is also permissible to set service_name = "" (empty string).
     * The difference in the latter usage is that the span will not be queryable
     * by service name unless more information is added to the span with non-empty
     * service name, e.g. an additional annotation from the server.
     * 
     * Particularly clients may not have a reliable service name at ingest. One
     * approach is to set service_name to "" at ingest, and later assign a
     * better label based on binary annotations, such as user agent.
     */
    SERVICE_NAME((short)3, "service_name"),
    /**
     * IPv6 host address packed into 16 bytes. Ex Inet6Address.getBytes()
     */
    IPV6((short)4, "ipv6");
    private static final Map byName = new HashMap();
    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: // IPV4
          return IPV4;
        case 2: // PORT
          return PORT;
        case 3: // SERVICE_NAME
          return SERVICE_NAME;
        case 4: // IPV6
          return IPV6;
        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 __IPV4_ISSET_ID = 0;
  private static final int __PORT_ISSET_ID = 1;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.IPV6};
  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.IPV4, new org.apache.thrift.meta_data.FieldMetaData("ipv4", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.PORT, new org.apache.thrift.meta_data.FieldMetaData("port", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16)));
    tmpMap.put(_Fields.SERVICE_NAME, new org.apache.thrift.meta_data.FieldMetaData("service_name", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.IPV6, new org.apache.thrift.meta_data.FieldMetaData("ipv6", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Endpoint.class, metaDataMap);
  }
  public Endpoint() {
  }
  public Endpoint(
    int ipv4,
    short port,
    String service_name)
  {
    this();
    this.ipv4 = ipv4;
    setIpv4IsSet(true);
    this.port = port;
    setPortIsSet(true);
    this.service_name = service_name;
  }
  /**
   * Performs a deep copy on other.
   */
  public Endpoint(Endpoint other) {
    __isset_bitfield = other.__isset_bitfield;
    this.ipv4 = other.ipv4;
    this.port = other.port;
    if (other.isSetService_name()) {
      this.service_name = other.service_name;
    }
    if (other.isSetIpv6()) {
      this.ipv6 = org.apache.thrift.TBaseHelper.copyBinary(other.ipv6);
    }
  }
  public Endpoint deepCopy() {
    return new Endpoint(this);
  }
  @Override
  public void clear() {
    setIpv4IsSet(false);
    this.ipv4 = 0;
    setPortIsSet(false);
    this.port = 0;
    this.service_name = null;
    this.ipv6 = null;
  }
  /**
   * IPv4 host address packed into 4 bytes.
   * 
   * Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4
   */
  public int getIpv4() {
    return this.ipv4;
  }
  /**
   * IPv4 host address packed into 4 bytes.
   * 
   * Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4
   */
  public Endpoint setIpv4(int ipv4) {
    this.ipv4 = ipv4;
    setIpv4IsSet(true);
    return this;
  }
  public void unsetIpv4() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __IPV4_ISSET_ID);
  }
  /** Returns true if field ipv4 is set (has been assigned a value) and false otherwise */
  public boolean isSetIpv4() {
    return EncodingUtils.testBit(__isset_bitfield, __IPV4_ISSET_ID);
  }
  public void setIpv4IsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __IPV4_ISSET_ID, value);
  }
  /**
   * IPv4 port or 0, if unknown.
   * 
   * Note: this is to be treated as an unsigned integer, so watch for negatives.
   */
  public short getPort() {
    return this.port;
  }
  /**
   * IPv4 port or 0, if unknown.
   * 
   * Note: this is to be treated as an unsigned integer, so watch for negatives.
   */
  public Endpoint setPort(short port) {
    this.port = port;
    setPortIsSet(true);
    return this;
  }
  public void unsetPort() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PORT_ISSET_ID);
  }
  /** Returns true if field port is set (has been assigned a value) and false otherwise */
  public boolean isSetPort() {
    return EncodingUtils.testBit(__isset_bitfield, __PORT_ISSET_ID);
  }
  public void setPortIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PORT_ISSET_ID, value);
  }
  /**
   * Classifier of a source or destination in lowercase, such as "zipkin-web".
   * 
   * This is the primary parameter for trace lookup, so should be intuitive as
   * possible, for example, matching names in service discovery.
   * 
   * Conventionally, when the service name isn't known, service_name = "unknown".
   * However, it is also permissible to set service_name = "" (empty string).
   * The difference in the latter usage is that the span will not be queryable
   * by service name unless more information is added to the span with non-empty
   * service name, e.g. an additional annotation from the server.
   * 
   * Particularly clients may not have a reliable service name at ingest. One
   * approach is to set service_name to "" at ingest, and later assign a
   * better label based on binary annotations, such as user agent.
   */
  public String getService_name() {
    return this.service_name;
  }
  /**
   * Classifier of a source or destination in lowercase, such as "zipkin-web".
   * 
   * This is the primary parameter for trace lookup, so should be intuitive as
   * possible, for example, matching names in service discovery.
   * 
   * Conventionally, when the service name isn't known, service_name = "unknown".
   * However, it is also permissible to set service_name = "" (empty string).
   * The difference in the latter usage is that the span will not be queryable
   * by service name unless more information is added to the span with non-empty
   * service name, e.g. an additional annotation from the server.
   * 
   * Particularly clients may not have a reliable service name at ingest. One
   * approach is to set service_name to "" at ingest, and later assign a
   * better label based on binary annotations, such as user agent.
   */
  public Endpoint setService_name(String service_name) {
    this.service_name = service_name;
    return this;
  }
  public void unsetService_name() {
    this.service_name = null;
  }
  /** Returns true if field service_name is set (has been assigned a value) and false otherwise */
  public boolean isSetService_name() {
    return this.service_name != null;
  }
  public void setService_nameIsSet(boolean value) {
    if (!value) {
      this.service_name = null;
    }
  }
  /**
   * IPv6 host address packed into 16 bytes. Ex Inet6Address.getBytes()
   */
  public byte[] getIpv6() {
    setIpv6(org.apache.thrift.TBaseHelper.rightSize(ipv6));
    return ipv6 == null ? null : ipv6.array();
  }
  public ByteBuffer bufferForIpv6() {
    return org.apache.thrift.TBaseHelper.copyBinary(ipv6);
  }
  /**
   * IPv6 host address packed into 16 bytes. Ex Inet6Address.getBytes()
   */
  public Endpoint setIpv6(byte[] ipv6) {
    this.ipv6 = ipv6 == null ? (ByteBuffer)null : ByteBuffer.wrap(Arrays.copyOf(ipv6, ipv6.length));
    return this;
  }
  public Endpoint setIpv6(ByteBuffer ipv6) {
    this.ipv6 = org.apache.thrift.TBaseHelper.copyBinary(ipv6);
    return this;
  }
  public void unsetIpv6() {
    this.ipv6 = null;
  }
  /** Returns true if field ipv6 is set (has been assigned a value) and false otherwise */
  public boolean isSetIpv6() {
    return this.ipv6 != null;
  }
  public void setIpv6IsSet(boolean value) {
    if (!value) {
      this.ipv6 = null;
    }
  }
  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case IPV4:
      if (value == null) {
        unsetIpv4();
      } else {
        setIpv4((Integer)value);
      }
      break;
    case PORT:
      if (value == null) {
        unsetPort();
      } else {
        setPort((Short)value);
      }
      break;
    case SERVICE_NAME:
      if (value == null) {
        unsetService_name();
      } else {
        setService_name((String)value);
      }
      break;
    case IPV6:
      if (value == null) {
        unsetIpv6();
      } else {
        setIpv6((ByteBuffer)value);
      }
      break;
    }
  }
  public Object getFieldValue(_Fields field) {
    switch (field) {
    case IPV4:
      return getIpv4();
    case PORT:
      return getPort();
    case SERVICE_NAME:
      return getService_name();
    case IPV6:
      return getIpv6();
    }
    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 IPV4:
      return isSetIpv4();
    case PORT:
      return isSetPort();
    case SERVICE_NAME:
      return isSetService_name();
    case IPV6:
      return isSetIpv6();
    }
    throw new IllegalStateException();
  }
  @Override
  public boolean equals(Object that) {
    if (that == null)
      return false;
    if (that instanceof Endpoint)
      return this.equals((Endpoint)that);
    return false;
  }
  public boolean equals(Endpoint that) {
    if (that == null)
      return false;
    boolean this_present_ipv4 = true;
    boolean that_present_ipv4 = true;
    if (this_present_ipv4 || that_present_ipv4) {
      if (!(this_present_ipv4 && that_present_ipv4))
        return false;
      if (this.ipv4 != that.ipv4)
        return false;
    }
    boolean this_present_port = true;
    boolean that_present_port = true;
    if (this_present_port || that_present_port) {
      if (!(this_present_port && that_present_port))
        return false;
      if (this.port != that.port)
        return false;
    }
    boolean this_present_service_name = true && this.isSetService_name();
    boolean that_present_service_name = true && that.isSetService_name();
    if (this_present_service_name || that_present_service_name) {
      if (!(this_present_service_name && that_present_service_name))
        return false;
      if (!this.service_name.equals(that.service_name))
        return false;
    }
    boolean this_present_ipv6 = true && this.isSetIpv6();
    boolean that_present_ipv6 = true && that.isSetIpv6();
    if (this_present_ipv6 || that_present_ipv6) {
      if (!(this_present_ipv6 && that_present_ipv6))
        return false;
      if (!this.ipv6.equals(that.ipv6))
        return false;
    }
    return true;
  }
  @Override
  public int hashCode() {
    List          © 2015 - 2025 Weber Informatics LLC | Privacy Policy