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

org.apache.tephra.distributed.thrift.TTransactionConflictException Maven / Gradle / Ivy

There is a newer version: 4.15.0-HBase-1.5
Show newest version
/*
 * 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.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.apache.tephra.distributed.thrift;

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 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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TTransactionConflictException extends TException implements org.apache.thrift.TBase, java.io.Serializable, Cloneable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TTransactionConflictException");

  private static final org.apache.thrift.protocol.TField TRANSACTION_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("transactionId", org.apache.thrift.protocol.TType.I64, (short)1);
  private static final org.apache.thrift.protocol.TField CONFLICTING_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("conflictingKey", org.apache.thrift.protocol.TType.STRING, (short)2);
  private static final org.apache.thrift.protocol.TField CONFLICTING_CLIENT_FIELD_DESC = new org.apache.thrift.protocol.TField("conflictingClient", org.apache.thrift.protocol.TType.STRING, (short)3);

  private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>();
  static {
    schemes.put(StandardScheme.class, new TTransactionConflictExceptionStandardSchemeFactory());
    schemes.put(TupleScheme.class, new TTransactionConflictExceptionTupleSchemeFactory());
  }

  public long transactionId; // required
  public String conflictingKey; // required
  public String conflictingClient; // 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 {
    TRANSACTION_ID((short)1, "transactionId"),
    CONFLICTING_KEY((short)2, "conflictingKey"),
    CONFLICTING_CLIENT((short)3, "conflictingClient");

    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: // TRANSACTION_ID
          return TRANSACTION_ID;
        case 2: // CONFLICTING_KEY
          return CONFLICTING_KEY;
        case 3: // CONFLICTING_CLIENT
          return CONFLICTING_CLIENT;
        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 __TRANSACTIONID_ISSET_ID = 0;
  private byte __isset_bitfield = 0;
  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.TRANSACTION_ID, new org.apache.thrift.meta_data.FieldMetaData("transactionId", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.CONFLICTING_KEY, new org.apache.thrift.meta_data.FieldMetaData("conflictingKey", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.CONFLICTING_CLIENT, new org.apache.thrift.meta_data.FieldMetaData("conflictingClient", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TTransactionConflictException.class, metaDataMap);
  }

  public TTransactionConflictException() {
  }

  public TTransactionConflictException(
    long transactionId,
    String conflictingKey,
    String conflictingClient)
  {
    this();
    this.transactionId = transactionId;
    setTransactionIdIsSet(true);
    this.conflictingKey = conflictingKey;
    this.conflictingClient = conflictingClient;
  }

  /**
   * Performs a deep copy on other.
   */
  public TTransactionConflictException(TTransactionConflictException other) {
    __isset_bitfield = other.__isset_bitfield;
    this.transactionId = other.transactionId;
    if (other.isSetConflictingKey()) {
      this.conflictingKey = other.conflictingKey;
    }
    if (other.isSetConflictingClient()) {
      this.conflictingClient = other.conflictingClient;
    }
  }

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

  @Override
  public void clear() {
    setTransactionIdIsSet(false);
    this.transactionId = 0;
    this.conflictingKey = null;
    this.conflictingClient = null;
  }

  public long getTransactionId() {
    return this.transactionId;
  }

  public TTransactionConflictException setTransactionId(long transactionId) {
    this.transactionId = transactionId;
    setTransactionIdIsSet(true);
    return this;
  }

  public void unsetTransactionId() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TRANSACTIONID_ISSET_ID);
  }

  /** Returns true if field transactionId is set (has been assigned a value) and false otherwise */
  public boolean isSetTransactionId() {
    return EncodingUtils.testBit(__isset_bitfield, __TRANSACTIONID_ISSET_ID);
  }

  public void setTransactionIdIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TRANSACTIONID_ISSET_ID, value);
  }

  public String getConflictingKey() {
    return this.conflictingKey;
  }

  public TTransactionConflictException setConflictingKey(String conflictingKey) {
    this.conflictingKey = conflictingKey;
    return this;
  }

  public void unsetConflictingKey() {
    this.conflictingKey = null;
  }

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

  public void setConflictingKeyIsSet(boolean value) {
    if (!value) {
      this.conflictingKey = null;
    }
  }

  public String getConflictingClient() {
    return this.conflictingClient;
  }

  public TTransactionConflictException setConflictingClient(String conflictingClient) {
    this.conflictingClient = conflictingClient;
    return this;
  }

  public void unsetConflictingClient() {
    this.conflictingClient = null;
  }

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

  public void setConflictingClientIsSet(boolean value) {
    if (!value) {
      this.conflictingClient = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case TRANSACTION_ID:
      if (value == null) {
        unsetTransactionId();
      } else {
        setTransactionId((Long)value);
      }
      break;

    case CONFLICTING_KEY:
      if (value == null) {
        unsetConflictingKey();
      } else {
        setConflictingKey((String)value);
      }
      break;

    case CONFLICTING_CLIENT:
      if (value == null) {
        unsetConflictingClient();
      } else {
        setConflictingClient((String)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case TRANSACTION_ID:
      return Long.valueOf(getTransactionId());

    case CONFLICTING_KEY:
      return getConflictingKey();

    case CONFLICTING_CLIENT:
      return getConflictingClient();

    }
    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 TRANSACTION_ID:
      return isSetTransactionId();
    case CONFLICTING_KEY:
      return isSetConflictingKey();
    case CONFLICTING_CLIENT:
      return isSetConflictingClient();
    }
    throw new IllegalStateException();
  }

  @Override
  public boolean equals(Object that) {
    if (that == null)
      return false;
    if (that instanceof TTransactionConflictException)
      return this.equals((TTransactionConflictException)that);
    return false;
  }

  public boolean equals(TTransactionConflictException that) {
    if (that == null)
      return false;

    boolean this_present_transactionId = true;
    boolean that_present_transactionId = true;
    if (this_present_transactionId || that_present_transactionId) {
      if (!(this_present_transactionId && that_present_transactionId))
        return false;
      if (this.transactionId != that.transactionId)
        return false;
    }

    boolean this_present_conflictingKey = true && this.isSetConflictingKey();
    boolean that_present_conflictingKey = true && that.isSetConflictingKey();
    if (this_present_conflictingKey || that_present_conflictingKey) {
      if (!(this_present_conflictingKey && that_present_conflictingKey))
        return false;
      if (!this.conflictingKey.equals(that.conflictingKey))
        return false;
    }

    boolean this_present_conflictingClient = true && this.isSetConflictingClient();
    boolean that_present_conflictingClient = true && that.isSetConflictingClient();
    if (this_present_conflictingClient || that_present_conflictingClient) {
      if (!(this_present_conflictingClient && that_present_conflictingClient))
        return false;
      if (!this.conflictingClient.equals(that.conflictingClient))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    return 0;
  }

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

    int lastComparison = 0;
    TTransactionConflictException typedOther = (TTransactionConflictException)other;

    lastComparison = Boolean.valueOf(isSetTransactionId()).compareTo(typedOther.isSetTransactionId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetTransactionId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.transactionId, typedOther.transactionId);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetConflictingKey()).compareTo(typedOther.isSetConflictingKey());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetConflictingKey()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.conflictingKey, typedOther.conflictingKey);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetConflictingClient()).compareTo(typedOther.isSetConflictingClient());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetConflictingClient()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.conflictingClient, typedOther.conflictingClient);
      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("TTransactionConflictException(");
    boolean first = true;

    sb.append("transactionId:");
    sb.append(this.transactionId);
    first = false;
    if (!first) sb.append(", ");
    sb.append("conflictingKey:");
    if (this.conflictingKey == null) {
      sb.append("null");
    } else {
      sb.append(this.conflictingKey);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("conflictingClient:");
    if (this.conflictingClient == null) {
      sb.append("null");
    } else {
      sb.append(this.conflictingClient);
    }
    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, 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 TTransactionConflictExceptionStandardSchemeFactory implements SchemeFactory {
    public TTransactionConflictExceptionStandardScheme getScheme() {
      return new TTransactionConflictExceptionStandardScheme();
    }
  }

  private static class TTransactionConflictExceptionStandardScheme extends StandardScheme {

    public void read(org.apache.thrift.protocol.TProtocol iprot, TTransactionConflictException 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: // TRANSACTION_ID
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.transactionId = iprot.readI64();
              struct.setTransactionIdIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // CONFLICTING_KEY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.conflictingKey = iprot.readString();
              struct.setConflictingKeyIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // CONFLICTING_CLIENT
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.conflictingClient = iprot.readString();
              struct.setConflictingClientIsSet(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, TTransactionConflictException struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(TRANSACTION_ID_FIELD_DESC);
      oprot.writeI64(struct.transactionId);
      oprot.writeFieldEnd();
      if (struct.conflictingKey != null) {
        oprot.writeFieldBegin(CONFLICTING_KEY_FIELD_DESC);
        oprot.writeString(struct.conflictingKey);
        oprot.writeFieldEnd();
      }
      if (struct.conflictingClient != null) {
        oprot.writeFieldBegin(CONFLICTING_CLIENT_FIELD_DESC);
        oprot.writeString(struct.conflictingClient);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class TTransactionConflictExceptionTupleSchemeFactory implements SchemeFactory {
    public TTransactionConflictExceptionTupleScheme getScheme() {
      return new TTransactionConflictExceptionTupleScheme();
    }
  }

  private static class TTransactionConflictExceptionTupleScheme extends TupleScheme {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TTransactionConflictException struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      BitSet optionals = new BitSet();
      if (struct.isSetTransactionId()) {
        optionals.set(0);
      }
      if (struct.isSetConflictingKey()) {
        optionals.set(1);
      }
      if (struct.isSetConflictingClient()) {
        optionals.set(2);
      }
      oprot.writeBitSet(optionals, 3);
      if (struct.isSetTransactionId()) {
        oprot.writeI64(struct.transactionId);
      }
      if (struct.isSetConflictingKey()) {
        oprot.writeString(struct.conflictingKey);
      }
      if (struct.isSetConflictingClient()) {
        oprot.writeString(struct.conflictingClient);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TTransactionConflictException struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      BitSet incoming = iprot.readBitSet(3);
      if (incoming.get(0)) {
        struct.transactionId = iprot.readI64();
        struct.setTransactionIdIsSet(true);
      }
      if (incoming.get(1)) {
        struct.conflictingKey = iprot.readString();
        struct.setConflictingKeyIsSet(true);
      }
      if (incoming.get(2)) {
        struct.conflictingClient = iprot.readString();
        struct.setConflictingClientIsSet(true);
      }
    }
  }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy