View Javadoc

1   /**
2    * Autogenerated by Thrift Compiler (0.8.0)
3    *
4    * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5    *  @generated
6    */
7   package org.apache.hadoop.hbase.thrift.generated;
8   
9   import org.apache.thrift.scheme.IScheme;
10  import org.apache.thrift.scheme.SchemeFactory;
11  import org.apache.thrift.scheme.StandardScheme;
12  
13  import org.apache.thrift.scheme.TupleScheme;
14  import org.apache.thrift.protocol.TTupleProtocol;
15  import java.util.List;
16  import java.util.ArrayList;
17  import java.util.Map;
18  import java.util.HashMap;
19  import java.util.EnumMap;
20  import java.util.Set;
21  import java.util.HashSet;
22  import java.util.EnumSet;
23  import java.util.Collections;
24  import java.util.BitSet;
25  import java.nio.ByteBuffer;
26  import java.util.Arrays;
27  import org.slf4j.Logger;
28  import org.slf4j.LoggerFactory;
29  
30  /**
31   * An IOError exception signals that an error occurred communicating
32   * to the Hbase master or an Hbase region server.  Also used to return
33   * more general Hbase error conditions.
34   */
35  public class IOError extends Exception implements org.apache.thrift.TBase<IOError, IOError._Fields>, java.io.Serializable, Cloneable {
36    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("IOError");
37  
38    private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
39  
40    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
41    static {
42      schemes.put(StandardScheme.class, new IOErrorStandardSchemeFactory());
43      schemes.put(TupleScheme.class, new IOErrorTupleSchemeFactory());
44    }
45  
46    public String message; // required
47  
48    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
49    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
50      MESSAGE((short)1, "message");
51  
52      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
53  
54      static {
55        for (_Fields field : EnumSet.allOf(_Fields.class)) {
56          byName.put(field.getFieldName(), field);
57        }
58      }
59  
60      /**
61       * Find the _Fields constant that matches fieldId, or null if its not found.
62       */
63      public static _Fields findByThriftId(int fieldId) {
64        switch(fieldId) {
65          case 1: // MESSAGE
66            return MESSAGE;
67          default:
68            return null;
69        }
70      }
71  
72      /**
73       * Find the _Fields constant that matches fieldId, throwing an exception
74       * if it is not found.
75       */
76      public static _Fields findByThriftIdOrThrow(int fieldId) {
77        _Fields fields = findByThriftId(fieldId);
78        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
79        return fields;
80      }
81  
82      /**
83       * Find the _Fields constant that matches name, or null if its not found.
84       */
85      public static _Fields findByName(String name) {
86        return byName.get(name);
87      }
88  
89      private final short _thriftId;
90      private final String _fieldName;
91  
92      _Fields(short thriftId, String fieldName) {
93        _thriftId = thriftId;
94        _fieldName = fieldName;
95      }
96  
97      public short getThriftFieldId() {
98        return _thriftId;
99      }
100 
101     public String getFieldName() {
102       return _fieldName;
103     }
104   }
105 
106   // isset id assignments
107   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
108   static {
109     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
110     tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.DEFAULT, 
111         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
112     metaDataMap = Collections.unmodifiableMap(tmpMap);
113     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(IOError.class, metaDataMap);
114   }
115 
116   public IOError() {
117   }
118 
119   public IOError(
120     String message)
121   {
122     this();
123     this.message = message;
124   }
125 
126   /**
127    * Performs a deep copy on <i>other</i>.
128    */
129   public IOError(IOError other) {
130     if (other.isSetMessage()) {
131       this.message = other.message;
132     }
133   }
134 
135   public IOError deepCopy() {
136     return new IOError(this);
137   }
138 
139   @Override
140   public void clear() {
141     this.message = null;
142   }
143 
144   public String getMessage() {
145     return this.message;
146   }
147 
148   public IOError setMessage(String message) {
149     this.message = message;
150     return this;
151   }
152 
153   public void unsetMessage() {
154     this.message = null;
155   }
156 
157   /** Returns true if field message is set (has been assigned a value) and false otherwise */
158   public boolean isSetMessage() {
159     return this.message != null;
160   }
161 
162   public void setMessageIsSet(boolean value) {
163     if (!value) {
164       this.message = null;
165     }
166   }
167 
168   public void setFieldValue(_Fields field, Object value) {
169     switch (field) {
170     case MESSAGE:
171       if (value == null) {
172         unsetMessage();
173       } else {
174         setMessage((String)value);
175       }
176       break;
177 
178     }
179   }
180 
181   public Object getFieldValue(_Fields field) {
182     switch (field) {
183     case MESSAGE:
184       return getMessage();
185 
186     }
187     throw new IllegalStateException();
188   }
189 
190   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
191   public boolean isSet(_Fields field) {
192     if (field == null) {
193       throw new IllegalArgumentException();
194     }
195 
196     switch (field) {
197     case MESSAGE:
198       return isSetMessage();
199     }
200     throw new IllegalStateException();
201   }
202 
203   @Override
204   public boolean equals(Object that) {
205     if (that == null)
206       return false;
207     if (that instanceof IOError)
208       return this.equals((IOError)that);
209     return false;
210   }
211 
212   public boolean equals(IOError that) {
213     if (that == null)
214       return false;
215 
216     boolean this_present_message = true && this.isSetMessage();
217     boolean that_present_message = true && that.isSetMessage();
218     if (this_present_message || that_present_message) {
219       if (!(this_present_message && that_present_message))
220         return false;
221       if (!this.message.equals(that.message))
222         return false;
223     }
224 
225     return true;
226   }
227 
228   @Override
229   public int hashCode() {
230     return 0;
231   }
232 
233   public int compareTo(IOError other) {
234     if (!getClass().equals(other.getClass())) {
235       return getClass().getName().compareTo(other.getClass().getName());
236     }
237 
238     int lastComparison = 0;
239     IOError typedOther = (IOError)other;
240 
241     lastComparison = Boolean.valueOf(isSetMessage()).compareTo(typedOther.isSetMessage());
242     if (lastComparison != 0) {
243       return lastComparison;
244     }
245     if (isSetMessage()) {
246       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, typedOther.message);
247       if (lastComparison != 0) {
248         return lastComparison;
249       }
250     }
251     return 0;
252   }
253 
254   public _Fields fieldForId(int fieldId) {
255     return _Fields.findByThriftId(fieldId);
256   }
257 
258   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
259     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
260   }
261 
262   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
263     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
264   }
265 
266   @Override
267   public String toString() {
268     StringBuilder sb = new StringBuilder("IOError(");
269     boolean first = true;
270 
271     sb.append("message:");
272     if (this.message == null) {
273       sb.append("null");
274     } else {
275       sb.append(this.message);
276     }
277     first = false;
278     sb.append(")");
279     return sb.toString();
280   }
281 
282   public void validate() throws org.apache.thrift.TException {
283     // check for required fields
284   }
285 
286   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
287     try {
288       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
289     } catch (org.apache.thrift.TException te) {
290       throw new java.io.IOException(te);
291     }
292   }
293 
294   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
295     try {
296       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
297     } catch (org.apache.thrift.TException te) {
298       throw new java.io.IOException(te);
299     }
300   }
301 
302   private static class IOErrorStandardSchemeFactory implements SchemeFactory {
303     public IOErrorStandardScheme getScheme() {
304       return new IOErrorStandardScheme();
305     }
306   }
307 
308   private static class IOErrorStandardScheme extends StandardScheme<IOError> {
309 
310     public void read(org.apache.thrift.protocol.TProtocol iprot, IOError struct) throws org.apache.thrift.TException {
311       org.apache.thrift.protocol.TField schemeField;
312       iprot.readStructBegin();
313       while (true)
314       {
315         schemeField = iprot.readFieldBegin();
316         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
317           break;
318         }
319         switch (schemeField.id) {
320           case 1: // MESSAGE
321             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
322               struct.message = iprot.readString();
323               struct.setMessageIsSet(true);
324             } else { 
325               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
326             }
327             break;
328           default:
329             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
330         }
331         iprot.readFieldEnd();
332       }
333       iprot.readStructEnd();
334 
335       // check for required fields of primitive type, which can't be checked in the validate method
336       struct.validate();
337     }
338 
339     public void write(org.apache.thrift.protocol.TProtocol oprot, IOError struct) throws org.apache.thrift.TException {
340       struct.validate();
341 
342       oprot.writeStructBegin(STRUCT_DESC);
343       if (struct.message != null) {
344         oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
345         oprot.writeString(struct.message);
346         oprot.writeFieldEnd();
347       }
348       oprot.writeFieldStop();
349       oprot.writeStructEnd();
350     }
351 
352   }
353 
354   private static class IOErrorTupleSchemeFactory implements SchemeFactory {
355     public IOErrorTupleScheme getScheme() {
356       return new IOErrorTupleScheme();
357     }
358   }
359 
360   private static class IOErrorTupleScheme extends TupleScheme<IOError> {
361 
362     @Override
363     public void write(org.apache.thrift.protocol.TProtocol prot, IOError struct) throws org.apache.thrift.TException {
364       TTupleProtocol oprot = (TTupleProtocol) prot;
365       BitSet optionals = new BitSet();
366       if (struct.isSetMessage()) {
367         optionals.set(0);
368       }
369       oprot.writeBitSet(optionals, 1);
370       if (struct.isSetMessage()) {
371         oprot.writeString(struct.message);
372       }
373     }
374 
375     @Override
376     public void read(org.apache.thrift.protocol.TProtocol prot, IOError struct) throws org.apache.thrift.TException {
377       TTupleProtocol iprot = (TTupleProtocol) prot;
378       BitSet incoming = iprot.readBitSet(1);
379       if (incoming.get(0)) {
380         struct.message = iprot.readString();
381         struct.setMessageIsSet(true);
382       }
383     }
384   }
385 
386 }
387