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.master.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 TabletSplit implements org.apache.thrift.TBase<TabletSplit, TabletSplit._Fields>, java.io.Serializable, Cloneable {
50    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TabletSplit");
51  
52    private static final org.apache.thrift.protocol.TField OLD_TABLET_FIELD_DESC = new org.apache.thrift.protocol.TField("oldTablet", org.apache.thrift.protocol.TType.STRUCT, (short)1);
53    private static final org.apache.thrift.protocol.TField NEW_TABLETS_FIELD_DESC = new org.apache.thrift.protocol.TField("newTablets", org.apache.thrift.protocol.TType.LIST, (short)2);
54  
55    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
56    static {
57      schemes.put(StandardScheme.class, new TabletSplitStandardSchemeFactory());
58      schemes.put(TupleScheme.class, new TabletSplitTupleSchemeFactory());
59    }
60  
61    public org.apache.accumulo.core.data.thrift.TKeyExtent oldTablet; // required
62    public List<org.apache.accumulo.core.data.thrift.TKeyExtent> newTablets; // required
63  
64    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
65    @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
66      OLD_TABLET((short)1, "oldTablet"),
67      NEW_TABLETS((short)2, "newTablets");
68  
69      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
70  
71      static {
72        for (_Fields field : EnumSet.allOf(_Fields.class)) {
73          byName.put(field.getFieldName(), field);
74        }
75      }
76  
77      /**
78       * Find the _Fields constant that matches fieldId, or null if its not found.
79       */
80      public static _Fields findByThriftId(int fieldId) {
81        switch(fieldId) {
82          case 1: // OLD_TABLET
83            return OLD_TABLET;
84          case 2: // NEW_TABLETS
85            return NEW_TABLETS;
86          default:
87            return null;
88        }
89      }
90  
91      /**
92       * Find the _Fields constant that matches fieldId, throwing an exception
93       * if it is not found.
94       */
95      public static _Fields findByThriftIdOrThrow(int fieldId) {
96        _Fields fields = findByThriftId(fieldId);
97        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
98        return fields;
99      }
100 
101     /**
102      * Find the _Fields constant that matches name, or null if its not found.
103      */
104     public static _Fields findByName(String name) {
105       return byName.get(name);
106     }
107 
108     private final short _thriftId;
109     private final String _fieldName;
110 
111     _Fields(short thriftId, String fieldName) {
112       _thriftId = thriftId;
113       _fieldName = fieldName;
114     }
115 
116     public short getThriftFieldId() {
117       return _thriftId;
118     }
119 
120     public String getFieldName() {
121       return _fieldName;
122     }
123   }
124 
125   // isset id assignments
126   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
127   static {
128     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
129     tmpMap.put(_Fields.OLD_TABLET, new org.apache.thrift.meta_data.FieldMetaData("oldTablet", org.apache.thrift.TFieldRequirementType.DEFAULT, 
130         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.data.thrift.TKeyExtent.class)));
131     tmpMap.put(_Fields.NEW_TABLETS, new org.apache.thrift.meta_data.FieldMetaData("newTablets", org.apache.thrift.TFieldRequirementType.DEFAULT, 
132         new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
133             new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.data.thrift.TKeyExtent.class))));
134     metaDataMap = Collections.unmodifiableMap(tmpMap);
135     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TabletSplit.class, metaDataMap);
136   }
137 
138   public TabletSplit() {
139   }
140 
141   public TabletSplit(
142     org.apache.accumulo.core.data.thrift.TKeyExtent oldTablet,
143     List<org.apache.accumulo.core.data.thrift.TKeyExtent> newTablets)
144   {
145     this();
146     this.oldTablet = oldTablet;
147     this.newTablets = newTablets;
148   }
149 
150   /**
151    * Performs a deep copy on <i>other</i>.
152    */
153   public TabletSplit(TabletSplit other) {
154     if (other.isSetOldTablet()) {
155       this.oldTablet = new org.apache.accumulo.core.data.thrift.TKeyExtent(other.oldTablet);
156     }
157     if (other.isSetNewTablets()) {
158       List<org.apache.accumulo.core.data.thrift.TKeyExtent> __this__newTablets = new ArrayList<org.apache.accumulo.core.data.thrift.TKeyExtent>();
159       for (org.apache.accumulo.core.data.thrift.TKeyExtent other_element : other.newTablets) {
160         __this__newTablets.add(new org.apache.accumulo.core.data.thrift.TKeyExtent(other_element));
161       }
162       this.newTablets = __this__newTablets;
163     }
164   }
165 
166   public TabletSplit deepCopy() {
167     return new TabletSplit(this);
168   }
169 
170   @Override
171   public void clear() {
172     this.oldTablet = null;
173     this.newTablets = null;
174   }
175 
176   public org.apache.accumulo.core.data.thrift.TKeyExtent getOldTablet() {
177     return this.oldTablet;
178   }
179 
180   public TabletSplit setOldTablet(org.apache.accumulo.core.data.thrift.TKeyExtent oldTablet) {
181     this.oldTablet = oldTablet;
182     return this;
183   }
184 
185   public void unsetOldTablet() {
186     this.oldTablet = null;
187   }
188 
189   /** Returns true if field oldTablet is set (has been assigned a value) and false otherwise */
190   public boolean isSetOldTablet() {
191     return this.oldTablet != null;
192   }
193 
194   public void setOldTabletIsSet(boolean value) {
195     if (!value) {
196       this.oldTablet = null;
197     }
198   }
199 
200   public int getNewTabletsSize() {
201     return (this.newTablets == null) ? 0 : this.newTablets.size();
202   }
203 
204   public java.util.Iterator<org.apache.accumulo.core.data.thrift.TKeyExtent> getNewTabletsIterator() {
205     return (this.newTablets == null) ? null : this.newTablets.iterator();
206   }
207 
208   public void addToNewTablets(org.apache.accumulo.core.data.thrift.TKeyExtent elem) {
209     if (this.newTablets == null) {
210       this.newTablets = new ArrayList<org.apache.accumulo.core.data.thrift.TKeyExtent>();
211     }
212     this.newTablets.add(elem);
213   }
214 
215   public List<org.apache.accumulo.core.data.thrift.TKeyExtent> getNewTablets() {
216     return this.newTablets;
217   }
218 
219   public TabletSplit setNewTablets(List<org.apache.accumulo.core.data.thrift.TKeyExtent> newTablets) {
220     this.newTablets = newTablets;
221     return this;
222   }
223 
224   public void unsetNewTablets() {
225     this.newTablets = null;
226   }
227 
228   /** Returns true if field newTablets is set (has been assigned a value) and false otherwise */
229   public boolean isSetNewTablets() {
230     return this.newTablets != null;
231   }
232 
233   public void setNewTabletsIsSet(boolean value) {
234     if (!value) {
235       this.newTablets = null;
236     }
237   }
238 
239   public void setFieldValue(_Fields field, Object value) {
240     switch (field) {
241     case OLD_TABLET:
242       if (value == null) {
243         unsetOldTablet();
244       } else {
245         setOldTablet((org.apache.accumulo.core.data.thrift.TKeyExtent)value);
246       }
247       break;
248 
249     case NEW_TABLETS:
250       if (value == null) {
251         unsetNewTablets();
252       } else {
253         setNewTablets((List<org.apache.accumulo.core.data.thrift.TKeyExtent>)value);
254       }
255       break;
256 
257     }
258   }
259 
260   public Object getFieldValue(_Fields field) {
261     switch (field) {
262     case OLD_TABLET:
263       return getOldTablet();
264 
265     case NEW_TABLETS:
266       return getNewTablets();
267 
268     }
269     throw new IllegalStateException();
270   }
271 
272   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
273   public boolean isSet(_Fields field) {
274     if (field == null) {
275       throw new IllegalArgumentException();
276     }
277 
278     switch (field) {
279     case OLD_TABLET:
280       return isSetOldTablet();
281     case NEW_TABLETS:
282       return isSetNewTablets();
283     }
284     throw new IllegalStateException();
285   }
286 
287   @Override
288   public boolean equals(Object that) {
289     if (that == null)
290       return false;
291     if (that instanceof TabletSplit)
292       return this.equals((TabletSplit)that);
293     return false;
294   }
295 
296   public boolean equals(TabletSplit that) {
297     if (that == null)
298       return false;
299 
300     boolean this_present_oldTablet = true && this.isSetOldTablet();
301     boolean that_present_oldTablet = true && that.isSetOldTablet();
302     if (this_present_oldTablet || that_present_oldTablet) {
303       if (!(this_present_oldTablet && that_present_oldTablet))
304         return false;
305       if (!this.oldTablet.equals(that.oldTablet))
306         return false;
307     }
308 
309     boolean this_present_newTablets = true && this.isSetNewTablets();
310     boolean that_present_newTablets = true && that.isSetNewTablets();
311     if (this_present_newTablets || that_present_newTablets) {
312       if (!(this_present_newTablets && that_present_newTablets))
313         return false;
314       if (!this.newTablets.equals(that.newTablets))
315         return false;
316     }
317 
318     return true;
319   }
320 
321   @Override
322   public int hashCode() {
323     return 0;
324   }
325 
326   public int compareTo(TabletSplit other) {
327     if (!getClass().equals(other.getClass())) {
328       return getClass().getName().compareTo(other.getClass().getName());
329     }
330 
331     int lastComparison = 0;
332     TabletSplit typedOther = (TabletSplit)other;
333 
334     lastComparison = Boolean.valueOf(isSetOldTablet()).compareTo(typedOther.isSetOldTablet());
335     if (lastComparison != 0) {
336       return lastComparison;
337     }
338     if (isSetOldTablet()) {
339       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.oldTablet, typedOther.oldTablet);
340       if (lastComparison != 0) {
341         return lastComparison;
342       }
343     }
344     lastComparison = Boolean.valueOf(isSetNewTablets()).compareTo(typedOther.isSetNewTablets());
345     if (lastComparison != 0) {
346       return lastComparison;
347     }
348     if (isSetNewTablets()) {
349       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.newTablets, typedOther.newTablets);
350       if (lastComparison != 0) {
351         return lastComparison;
352       }
353     }
354     return 0;
355   }
356 
357   public _Fields fieldForId(int fieldId) {
358     return _Fields.findByThriftId(fieldId);
359   }
360 
361   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
362     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
363   }
364 
365   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
366     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
367   }
368 
369   @Override
370   public String toString() {
371     StringBuilder sb = new StringBuilder("TabletSplit(");
372     boolean first = true;
373 
374     sb.append("oldTablet:");
375     if (this.oldTablet == null) {
376       sb.append("null");
377     } else {
378       sb.append(this.oldTablet);
379     }
380     first = false;
381     if (!first) sb.append(", ");
382     sb.append("newTablets:");
383     if (this.newTablets == null) {
384       sb.append("null");
385     } else {
386       sb.append(this.newTablets);
387     }
388     first = false;
389     sb.append(")");
390     return sb.toString();
391   }
392 
393   public void validate() throws org.apache.thrift.TException {
394     // check for required fields
395     // check for sub-struct validity
396     if (oldTablet != null) {
397       oldTablet.validate();
398     }
399   }
400 
401   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
402     try {
403       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
404     } catch (org.apache.thrift.TException te) {
405       throw new java.io.IOException(te);
406     }
407   }
408 
409   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
410     try {
411       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
412     } catch (org.apache.thrift.TException te) {
413       throw new java.io.IOException(te);
414     }
415   }
416 
417   private static class TabletSplitStandardSchemeFactory implements SchemeFactory {
418     public TabletSplitStandardScheme getScheme() {
419       return new TabletSplitStandardScheme();
420     }
421   }
422 
423   private static class TabletSplitStandardScheme extends StandardScheme<TabletSplit> {
424 
425     public void read(org.apache.thrift.protocol.TProtocol iprot, TabletSplit struct) throws org.apache.thrift.TException {
426       org.apache.thrift.protocol.TField schemeField;
427       iprot.readStructBegin();
428       while (true)
429       {
430         schemeField = iprot.readFieldBegin();
431         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
432           break;
433         }
434         switch (schemeField.id) {
435           case 1: // OLD_TABLET
436             if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
437               struct.oldTablet = new org.apache.accumulo.core.data.thrift.TKeyExtent();
438               struct.oldTablet.read(iprot);
439               struct.setOldTabletIsSet(true);
440             } else { 
441               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
442             }
443             break;
444           case 2: // NEW_TABLETS
445             if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
446               {
447                 org.apache.thrift.protocol.TList _list62 = iprot.readListBegin();
448                 struct.newTablets = new ArrayList<org.apache.accumulo.core.data.thrift.TKeyExtent>(_list62.size);
449                 for (int _i63 = 0; _i63 < _list62.size; ++_i63)
450                 {
451                   org.apache.accumulo.core.data.thrift.TKeyExtent _elem64; // required
452                   _elem64 = new org.apache.accumulo.core.data.thrift.TKeyExtent();
453                   _elem64.read(iprot);
454                   struct.newTablets.add(_elem64);
455                 }
456                 iprot.readListEnd();
457               }
458               struct.setNewTabletsIsSet(true);
459             } else { 
460               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
461             }
462             break;
463           default:
464             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
465         }
466         iprot.readFieldEnd();
467       }
468       iprot.readStructEnd();
469 
470       // check for required fields of primitive type, which can't be checked in the validate method
471       struct.validate();
472     }
473 
474     public void write(org.apache.thrift.protocol.TProtocol oprot, TabletSplit struct) throws org.apache.thrift.TException {
475       struct.validate();
476 
477       oprot.writeStructBegin(STRUCT_DESC);
478       if (struct.oldTablet != null) {
479         oprot.writeFieldBegin(OLD_TABLET_FIELD_DESC);
480         struct.oldTablet.write(oprot);
481         oprot.writeFieldEnd();
482       }
483       if (struct.newTablets != null) {
484         oprot.writeFieldBegin(NEW_TABLETS_FIELD_DESC);
485         {
486           oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.newTablets.size()));
487           for (org.apache.accumulo.core.data.thrift.TKeyExtent _iter65 : struct.newTablets)
488           {
489             _iter65.write(oprot);
490           }
491           oprot.writeListEnd();
492         }
493         oprot.writeFieldEnd();
494       }
495       oprot.writeFieldStop();
496       oprot.writeStructEnd();
497     }
498 
499   }
500 
501   private static class TabletSplitTupleSchemeFactory implements SchemeFactory {
502     public TabletSplitTupleScheme getScheme() {
503       return new TabletSplitTupleScheme();
504     }
505   }
506 
507   private static class TabletSplitTupleScheme extends TupleScheme<TabletSplit> {
508 
509     @Override
510     public void write(org.apache.thrift.protocol.TProtocol prot, TabletSplit struct) throws org.apache.thrift.TException {
511       TTupleProtocol oprot = (TTupleProtocol) prot;
512       BitSet optionals = new BitSet();
513       if (struct.isSetOldTablet()) {
514         optionals.set(0);
515       }
516       if (struct.isSetNewTablets()) {
517         optionals.set(1);
518       }
519       oprot.writeBitSet(optionals, 2);
520       if (struct.isSetOldTablet()) {
521         struct.oldTablet.write(oprot);
522       }
523       if (struct.isSetNewTablets()) {
524         {
525           oprot.writeI32(struct.newTablets.size());
526           for (org.apache.accumulo.core.data.thrift.TKeyExtent _iter66 : struct.newTablets)
527           {
528             _iter66.write(oprot);
529           }
530         }
531       }
532     }
533 
534     @Override
535     public void read(org.apache.thrift.protocol.TProtocol prot, TabletSplit struct) throws org.apache.thrift.TException {
536       TTupleProtocol iprot = (TTupleProtocol) prot;
537       BitSet incoming = iprot.readBitSet(2);
538       if (incoming.get(0)) {
539         struct.oldTablet = new org.apache.accumulo.core.data.thrift.TKeyExtent();
540         struct.oldTablet.read(iprot);
541         struct.setOldTabletIsSet(true);
542       }
543       if (incoming.get(1)) {
544         {
545           org.apache.thrift.protocol.TList _list67 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
546           struct.newTablets = new ArrayList<org.apache.accumulo.core.data.thrift.TKeyExtent>(_list67.size);
547           for (int _i68 = 0; _i68 < _list67.size; ++_i68)
548           {
549             org.apache.accumulo.core.data.thrift.TKeyExtent _elem69; // required
550             _elem69 = new org.apache.accumulo.core.data.thrift.TKeyExtent();
551             _elem69.read(iprot);
552             struct.newTablets.add(_elem69);
553           }
554         }
555         struct.setNewTabletsIsSet(true);
556       }
557     }
558   }
559 
560 }
561