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 Compacting implements org.apache.thrift.TBase<Compacting, Compacting._Fields>, java.io.Serializable, Cloneable {
50    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Compacting");
51  
52    private static final org.apache.thrift.protocol.TField RUNNING_FIELD_DESC = new org.apache.thrift.protocol.TField("running", org.apache.thrift.protocol.TType.I32, (short)1);
53    private static final org.apache.thrift.protocol.TField QUEUED_FIELD_DESC = new org.apache.thrift.protocol.TField("queued", org.apache.thrift.protocol.TType.I32, (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 CompactingStandardSchemeFactory());
58      schemes.put(TupleScheme.class, new CompactingTupleSchemeFactory());
59    }
60  
61    public int running; // required
62    public int queued; // 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      RUNNING((short)1, "running"),
67      QUEUED((short)2, "queued");
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: // RUNNING
83            return RUNNING;
84          case 2: // QUEUED
85            return QUEUED;
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   private static final int __RUNNING_ISSET_ID = 0;
127   private static final int __QUEUED_ISSET_ID = 1;
128   private byte __isset_bitfield = 0;
129   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
130   static {
131     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
132     tmpMap.put(_Fields.RUNNING, new org.apache.thrift.meta_data.FieldMetaData("running", org.apache.thrift.TFieldRequirementType.DEFAULT, 
133         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
134     tmpMap.put(_Fields.QUEUED, new org.apache.thrift.meta_data.FieldMetaData("queued", org.apache.thrift.TFieldRequirementType.DEFAULT, 
135         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
136     metaDataMap = Collections.unmodifiableMap(tmpMap);
137     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Compacting.class, metaDataMap);
138   }
139 
140   public Compacting() {
141   }
142 
143   public Compacting(
144     int running,
145     int queued)
146   {
147     this();
148     this.running = running;
149     setRunningIsSet(true);
150     this.queued = queued;
151     setQueuedIsSet(true);
152   }
153 
154   /**
155    * Performs a deep copy on <i>other</i>.
156    */
157   public Compacting(Compacting other) {
158     __isset_bitfield = other.__isset_bitfield;
159     this.running = other.running;
160     this.queued = other.queued;
161   }
162 
163   public Compacting deepCopy() {
164     return new Compacting(this);
165   }
166 
167   @Override
168   public void clear() {
169     setRunningIsSet(false);
170     this.running = 0;
171     setQueuedIsSet(false);
172     this.queued = 0;
173   }
174 
175   public int getRunning() {
176     return this.running;
177   }
178 
179   public Compacting setRunning(int running) {
180     this.running = running;
181     setRunningIsSet(true);
182     return this;
183   }
184 
185   public void unsetRunning() {
186     __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __RUNNING_ISSET_ID);
187   }
188 
189   /** Returns true if field running is set (has been assigned a value) and false otherwise */
190   public boolean isSetRunning() {
191     return EncodingUtils.testBit(__isset_bitfield, __RUNNING_ISSET_ID);
192   }
193 
194   public void setRunningIsSet(boolean value) {
195     __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __RUNNING_ISSET_ID, value);
196   }
197 
198   public int getQueued() {
199     return this.queued;
200   }
201 
202   public Compacting setQueued(int queued) {
203     this.queued = queued;
204     setQueuedIsSet(true);
205     return this;
206   }
207 
208   public void unsetQueued() {
209     __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __QUEUED_ISSET_ID);
210   }
211 
212   /** Returns true if field queued is set (has been assigned a value) and false otherwise */
213   public boolean isSetQueued() {
214     return EncodingUtils.testBit(__isset_bitfield, __QUEUED_ISSET_ID);
215   }
216 
217   public void setQueuedIsSet(boolean value) {
218     __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __QUEUED_ISSET_ID, value);
219   }
220 
221   public void setFieldValue(_Fields field, Object value) {
222     switch (field) {
223     case RUNNING:
224       if (value == null) {
225         unsetRunning();
226       } else {
227         setRunning((Integer)value);
228       }
229       break;
230 
231     case QUEUED:
232       if (value == null) {
233         unsetQueued();
234       } else {
235         setQueued((Integer)value);
236       }
237       break;
238 
239     }
240   }
241 
242   public Object getFieldValue(_Fields field) {
243     switch (field) {
244     case RUNNING:
245       return Integer.valueOf(getRunning());
246 
247     case QUEUED:
248       return Integer.valueOf(getQueued());
249 
250     }
251     throw new IllegalStateException();
252   }
253 
254   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
255   public boolean isSet(_Fields field) {
256     if (field == null) {
257       throw new IllegalArgumentException();
258     }
259 
260     switch (field) {
261     case RUNNING:
262       return isSetRunning();
263     case QUEUED:
264       return isSetQueued();
265     }
266     throw new IllegalStateException();
267   }
268 
269   @Override
270   public boolean equals(Object that) {
271     if (that == null)
272       return false;
273     if (that instanceof Compacting)
274       return this.equals((Compacting)that);
275     return false;
276   }
277 
278   public boolean equals(Compacting that) {
279     if (that == null)
280       return false;
281 
282     boolean this_present_running = true;
283     boolean that_present_running = true;
284     if (this_present_running || that_present_running) {
285       if (!(this_present_running && that_present_running))
286         return false;
287       if (this.running != that.running)
288         return false;
289     }
290 
291     boolean this_present_queued = true;
292     boolean that_present_queued = true;
293     if (this_present_queued || that_present_queued) {
294       if (!(this_present_queued && that_present_queued))
295         return false;
296       if (this.queued != that.queued)
297         return false;
298     }
299 
300     return true;
301   }
302 
303   @Override
304   public int hashCode() {
305     return 0;
306   }
307 
308   public int compareTo(Compacting other) {
309     if (!getClass().equals(other.getClass())) {
310       return getClass().getName().compareTo(other.getClass().getName());
311     }
312 
313     int lastComparison = 0;
314     Compacting typedOther = (Compacting)other;
315 
316     lastComparison = Boolean.valueOf(isSetRunning()).compareTo(typedOther.isSetRunning());
317     if (lastComparison != 0) {
318       return lastComparison;
319     }
320     if (isSetRunning()) {
321       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.running, typedOther.running);
322       if (lastComparison != 0) {
323         return lastComparison;
324       }
325     }
326     lastComparison = Boolean.valueOf(isSetQueued()).compareTo(typedOther.isSetQueued());
327     if (lastComparison != 0) {
328       return lastComparison;
329     }
330     if (isSetQueued()) {
331       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queued, typedOther.queued);
332       if (lastComparison != 0) {
333         return lastComparison;
334       }
335     }
336     return 0;
337   }
338 
339   public _Fields fieldForId(int fieldId) {
340     return _Fields.findByThriftId(fieldId);
341   }
342 
343   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
344     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
345   }
346 
347   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
348     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
349   }
350 
351   @Override
352   public String toString() {
353     StringBuilder sb = new StringBuilder("Compacting(");
354     boolean first = true;
355 
356     sb.append("running:");
357     sb.append(this.running);
358     first = false;
359     if (!first) sb.append(", ");
360     sb.append("queued:");
361     sb.append(this.queued);
362     first = false;
363     sb.append(")");
364     return sb.toString();
365   }
366 
367   public void validate() throws org.apache.thrift.TException {
368     // check for required fields
369     // check for sub-struct validity
370   }
371 
372   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
373     try {
374       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
375     } catch (org.apache.thrift.TException te) {
376       throw new java.io.IOException(te);
377     }
378   }
379 
380   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
381     try {
382       // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
383       __isset_bitfield = 0;
384       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
385     } catch (org.apache.thrift.TException te) {
386       throw new java.io.IOException(te);
387     }
388   }
389 
390   private static class CompactingStandardSchemeFactory implements SchemeFactory {
391     public CompactingStandardScheme getScheme() {
392       return new CompactingStandardScheme();
393     }
394   }
395 
396   private static class CompactingStandardScheme extends StandardScheme<Compacting> {
397 
398     public void read(org.apache.thrift.protocol.TProtocol iprot, Compacting struct) throws org.apache.thrift.TException {
399       org.apache.thrift.protocol.TField schemeField;
400       iprot.readStructBegin();
401       while (true)
402       {
403         schemeField = iprot.readFieldBegin();
404         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
405           break;
406         }
407         switch (schemeField.id) {
408           case 1: // RUNNING
409             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
410               struct.running = iprot.readI32();
411               struct.setRunningIsSet(true);
412             } else { 
413               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
414             }
415             break;
416           case 2: // QUEUED
417             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
418               struct.queued = iprot.readI32();
419               struct.setQueuedIsSet(true);
420             } else { 
421               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
422             }
423             break;
424           default:
425             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
426         }
427         iprot.readFieldEnd();
428       }
429       iprot.readStructEnd();
430 
431       // check for required fields of primitive type, which can't be checked in the validate method
432       struct.validate();
433     }
434 
435     public void write(org.apache.thrift.protocol.TProtocol oprot, Compacting struct) throws org.apache.thrift.TException {
436       struct.validate();
437 
438       oprot.writeStructBegin(STRUCT_DESC);
439       oprot.writeFieldBegin(RUNNING_FIELD_DESC);
440       oprot.writeI32(struct.running);
441       oprot.writeFieldEnd();
442       oprot.writeFieldBegin(QUEUED_FIELD_DESC);
443       oprot.writeI32(struct.queued);
444       oprot.writeFieldEnd();
445       oprot.writeFieldStop();
446       oprot.writeStructEnd();
447     }
448 
449   }
450 
451   private static class CompactingTupleSchemeFactory implements SchemeFactory {
452     public CompactingTupleScheme getScheme() {
453       return new CompactingTupleScheme();
454     }
455   }
456 
457   private static class CompactingTupleScheme extends TupleScheme<Compacting> {
458 
459     @Override
460     public void write(org.apache.thrift.protocol.TProtocol prot, Compacting struct) throws org.apache.thrift.TException {
461       TTupleProtocol oprot = (TTupleProtocol) prot;
462       BitSet optionals = new BitSet();
463       if (struct.isSetRunning()) {
464         optionals.set(0);
465       }
466       if (struct.isSetQueued()) {
467         optionals.set(1);
468       }
469       oprot.writeBitSet(optionals, 2);
470       if (struct.isSetRunning()) {
471         oprot.writeI32(struct.running);
472       }
473       if (struct.isSetQueued()) {
474         oprot.writeI32(struct.queued);
475       }
476     }
477 
478     @Override
479     public void read(org.apache.thrift.protocol.TProtocol prot, Compacting struct) throws org.apache.thrift.TException {
480       TTupleProtocol iprot = (TTupleProtocol) prot;
481       BitSet incoming = iprot.readBitSet(2);
482       if (incoming.get(0)) {
483         struct.running = iprot.readI32();
484         struct.setRunningIsSet(true);
485       }
486       if (incoming.get(1)) {
487         struct.queued = iprot.readI32();
488         struct.setQueuedIsSet(true);
489       }
490     }
491   }
492 
493 }
494