View Javadoc

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