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