001/**
002 * Autogenerated by Avro
003 *
004 * DO NOT EDIT DIRECTLY
005 */
006package org.apache.reef.io.watcher.driver.context;
007
008import org.apache.avro.specific.SpecificData;
009
010@SuppressWarnings("all")
011@org.apache.avro.specific.AvroGenerated
012public class AvroFailedContext extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
013  private static final long serialVersionUID = 1293806727361449095L;
014  public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"AvroFailedContext\",\"namespace\":\"org.apache.reef.io.watcher.driver.context\",\"fields\":[{\"name\":\"base\",\"type\":{\"type\":\"record\",\"name\":\"AvroContextBase\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"evaluatorId\",\"type\":\"string\"},{\"name\":\"parentId\",\"type\":[\"string\",\"null\"]},{\"name\":\"evaluatorDescriptor\",\"type\":[{\"type\":\"record\",\"name\":\"AvroEvaluatorDescriptor\",\"namespace\":\"org.apache.reef.io.watcher.driver.evaluator\",\"fields\":[{\"name\":\"nodeDescriptor\",\"type\":{\"type\":\"record\",\"name\":\"AvroNodeDescriptor\",\"namespace\":\"org.apache.reef.io.watcher.driver.catalog\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"inetSocketAddress\",\"type\":\"string\"},{\"name\":\"rackDescriptor\",\"type\":{\"type\":\"record\",\"name\":\"AvroRackDescriptor\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"nodes\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"record\",\"name\":\"AvroNodeDescriptorInRackDescriptor\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"inetSocketAddress\",\"type\":\"string\"}]}}}]}}]}},{\"name\":\"process\",\"type\":{\"type\":\"record\",\"name\":\"AvroEvaluatorProcess\",\"fields\":[{\"name\":\"commandLines\",\"type\":{\"type\":\"array\",\"items\":[\"string\",\"null\"]}},{\"name\":\"evaluatorType\",\"type\":{\"type\":\"enum\",\"name\":\"AvroEvaluatorType\",\"symbols\":[\"JVM\",\"CLR\",\"UNDECIDED\"]}},{\"name\":\"isOptionSet\",\"type\":\"boolean\"}]}},{\"name\":\"memory\",\"type\":\"int\"},{\"name\":\"numberOfCores\",\"type\":\"int\"}]},\"null\"]}]}},{\"name\":\"parentContext\",\"type\":[{\"type\":\"record\",\"name\":\"AvroActiveContext\",\"fields\":[{\"name\":\"base\",\"type\":\"AvroContextBase\"}]},\"null\"]},{\"name\":\"failure\",\"type\":{\"type\":\"record\",\"name\":\"AvroFailure\",\"namespace\":\"org.apache.reef.io.watcher.common\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"message\",\"type\":\"string\"},{\"name\":\"description\",\"type\":[\"string\",\"null\"]},{\"name\":\"reason\",\"type\":[\"string\",\"null\"]},{\"name\":\"data\",\"type\":[\"bytes\",\"null\"]},{\"name\":\"asError\",\"type\":\"string\"}]}}]}");
015  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
016  @Deprecated public org.apache.reef.io.watcher.driver.context.AvroContextBase base;
017  @Deprecated public org.apache.reef.io.watcher.driver.context.AvroActiveContext parentContext;
018  @Deprecated public org.apache.reef.io.watcher.common.AvroFailure failure;
019
020  /**
021   * Default constructor.  Note that this does not initialize fields
022   * to their default values from the schema.  If that is desired then
023   * one should use <code>newBuilder()</code>.
024   */
025  public AvroFailedContext() {}
026
027  /**
028   * All-args constructor.
029   * @param base The new value for base
030   * @param parentContext The new value for parentContext
031   * @param failure The new value for failure
032   */
033  public AvroFailedContext(org.apache.reef.io.watcher.driver.context.AvroContextBase base, org.apache.reef.io.watcher.driver.context.AvroActiveContext parentContext, org.apache.reef.io.watcher.common.AvroFailure failure) {
034    this.base = base;
035    this.parentContext = parentContext;
036    this.failure = failure;
037  }
038
039  public org.apache.avro.Schema getSchema() { return SCHEMA$; }
040  // Used by DatumWriter.  Applications should not call.
041  public java.lang.Object get(int field$) {
042    switch (field$) {
043    case 0: return base;
044    case 1: return parentContext;
045    case 2: return failure;
046    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
047    }
048  }
049
050  // Used by DatumReader.  Applications should not call.
051  @SuppressWarnings(value="unchecked")
052  public void put(int field$, java.lang.Object value$) {
053    switch (field$) {
054    case 0: base = (org.apache.reef.io.watcher.driver.context.AvroContextBase)value$; break;
055    case 1: parentContext = (org.apache.reef.io.watcher.driver.context.AvroActiveContext)value$; break;
056    case 2: failure = (org.apache.reef.io.watcher.common.AvroFailure)value$; break;
057    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
058    }
059  }
060
061  /**
062   * Gets the value of the 'base' field.
063   * @return The value of the 'base' field.
064   */
065  public org.apache.reef.io.watcher.driver.context.AvroContextBase getBase() {
066    return base;
067  }
068
069  /**
070   * Sets the value of the 'base' field.
071   * @param value the value to set.
072   */
073  public void setBase(org.apache.reef.io.watcher.driver.context.AvroContextBase value) {
074    this.base = value;
075  }
076
077  /**
078   * Gets the value of the 'parentContext' field.
079   * @return The value of the 'parentContext' field.
080   */
081  public org.apache.reef.io.watcher.driver.context.AvroActiveContext getParentContext() {
082    return parentContext;
083  }
084
085  /**
086   * Sets the value of the 'parentContext' field.
087   * @param value the value to set.
088   */
089  public void setParentContext(org.apache.reef.io.watcher.driver.context.AvroActiveContext value) {
090    this.parentContext = value;
091  }
092
093  /**
094   * Gets the value of the 'failure' field.
095   * @return The value of the 'failure' field.
096   */
097  public org.apache.reef.io.watcher.common.AvroFailure getFailure() {
098    return failure;
099  }
100
101  /**
102   * Sets the value of the 'failure' field.
103   * @param value the value to set.
104   */
105  public void setFailure(org.apache.reef.io.watcher.common.AvroFailure value) {
106    this.failure = value;
107  }
108
109  /**
110   * Creates a new AvroFailedContext RecordBuilder.
111   * @return A new AvroFailedContext RecordBuilder
112   */
113  public static org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder newBuilder() {
114    return new org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder();
115  }
116
117  /**
118   * Creates a new AvroFailedContext RecordBuilder by copying an existing Builder.
119   * @param other The existing builder to copy.
120   * @return A new AvroFailedContext RecordBuilder
121   */
122  public static org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder newBuilder(org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder other) {
123    return new org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder(other);
124  }
125
126  /**
127   * Creates a new AvroFailedContext RecordBuilder by copying an existing AvroFailedContext instance.
128   * @param other The existing instance to copy.
129   * @return A new AvroFailedContext RecordBuilder
130   */
131  public static org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder newBuilder(org.apache.reef.io.watcher.driver.context.AvroFailedContext other) {
132    return new org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder(other);
133  }
134
135  /**
136   * RecordBuilder for AvroFailedContext instances.
137   */
138  public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<AvroFailedContext>
139    implements org.apache.avro.data.RecordBuilder<AvroFailedContext> {
140
141    private org.apache.reef.io.watcher.driver.context.AvroContextBase base;
142    private org.apache.reef.io.watcher.driver.context.AvroContextBase.Builder baseBuilder;
143    private org.apache.reef.io.watcher.driver.context.AvroActiveContext parentContext;
144    private org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder parentContextBuilder;
145    private org.apache.reef.io.watcher.common.AvroFailure failure;
146    private org.apache.reef.io.watcher.common.AvroFailure.Builder failureBuilder;
147
148    /** Creates a new Builder */
149    private Builder() {
150      super(SCHEMA$);
151    }
152
153    /**
154     * Creates a Builder by copying an existing Builder.
155     * @param other The existing Builder to copy.
156     */
157    private Builder(org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder other) {
158      super(other);
159      if (isValidValue(fields()[0], other.base)) {
160        this.base = data().deepCopy(fields()[0].schema(), other.base);
161        fieldSetFlags()[0] = true;
162      }
163      if (other.hasBaseBuilder()) {
164        this.baseBuilder = org.apache.reef.io.watcher.driver.context.AvroContextBase.newBuilder(other.getBaseBuilder());
165      }
166      if (isValidValue(fields()[1], other.parentContext)) {
167        this.parentContext = data().deepCopy(fields()[1].schema(), other.parentContext);
168        fieldSetFlags()[1] = true;
169      }
170      if (other.hasParentContextBuilder()) {
171        this.parentContextBuilder = org.apache.reef.io.watcher.driver.context.AvroActiveContext.newBuilder(other.getParentContextBuilder());
172      }
173      if (isValidValue(fields()[2], other.failure)) {
174        this.failure = data().deepCopy(fields()[2].schema(), other.failure);
175        fieldSetFlags()[2] = true;
176      }
177      if (other.hasFailureBuilder()) {
178        this.failureBuilder = org.apache.reef.io.watcher.common.AvroFailure.newBuilder(other.getFailureBuilder());
179      }
180    }
181
182    /**
183     * Creates a Builder by copying an existing AvroFailedContext instance
184     * @param other The existing instance to copy.
185     */
186    private Builder(org.apache.reef.io.watcher.driver.context.AvroFailedContext other) {
187            super(SCHEMA$);
188      if (isValidValue(fields()[0], other.base)) {
189        this.base = data().deepCopy(fields()[0].schema(), other.base);
190        fieldSetFlags()[0] = true;
191      }
192      this.baseBuilder = null;
193      if (isValidValue(fields()[1], other.parentContext)) {
194        this.parentContext = data().deepCopy(fields()[1].schema(), other.parentContext);
195        fieldSetFlags()[1] = true;
196      }
197      this.parentContextBuilder = null;
198      if (isValidValue(fields()[2], other.failure)) {
199        this.failure = data().deepCopy(fields()[2].schema(), other.failure);
200        fieldSetFlags()[2] = true;
201      }
202      this.failureBuilder = null;
203    }
204
205    /**
206      * Gets the value of the 'base' field.
207      * @return The value.
208      */
209    public org.apache.reef.io.watcher.driver.context.AvroContextBase getBase() {
210      return base;
211    }
212
213    /**
214      * Sets the value of the 'base' field.
215      * @param value The value of 'base'.
216      * @return This builder.
217      */
218    public org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder setBase(org.apache.reef.io.watcher.driver.context.AvroContextBase value) {
219      validate(fields()[0], value);
220      this.baseBuilder = null;
221      this.base = value;
222      fieldSetFlags()[0] = true;
223      return this;
224    }
225
226    /**
227      * Checks whether the 'base' field has been set.
228      * @return True if the 'base' field has been set, false otherwise.
229      */
230    public boolean hasBase() {
231      return fieldSetFlags()[0];
232    }
233
234    /**
235     * Gets the Builder instance for the 'base' field and creates one if it doesn't exist yet.
236     * @return This builder.
237     */
238    public org.apache.reef.io.watcher.driver.context.AvroContextBase.Builder getBaseBuilder() {
239      if (baseBuilder == null) {
240        if (hasBase()) {
241          setBaseBuilder(org.apache.reef.io.watcher.driver.context.AvroContextBase.newBuilder(base));
242        } else {
243          setBaseBuilder(org.apache.reef.io.watcher.driver.context.AvroContextBase.newBuilder());
244        }
245      }
246      return baseBuilder;
247    }
248
249    /**
250     * Sets the Builder instance for the 'base' field
251     * @param value The builder instance that must be set.
252     * @return This builder.
253     */
254    public org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder setBaseBuilder(org.apache.reef.io.watcher.driver.context.AvroContextBase.Builder value) {
255      clearBase();
256      baseBuilder = value;
257      return this;
258    }
259
260    /**
261     * Checks whether the 'base' field has an active Builder instance
262     * @return True if the 'base' field has an active Builder instance
263     */
264    public boolean hasBaseBuilder() {
265      return baseBuilder != null;
266    }
267
268    /**
269      * Clears the value of the 'base' field.
270      * @return This builder.
271      */
272    public org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder clearBase() {
273      base = null;
274      baseBuilder = null;
275      fieldSetFlags()[0] = false;
276      return this;
277    }
278
279    /**
280      * Gets the value of the 'parentContext' field.
281      * @return The value.
282      */
283    public org.apache.reef.io.watcher.driver.context.AvroActiveContext getParentContext() {
284      return parentContext;
285    }
286
287    /**
288      * Sets the value of the 'parentContext' field.
289      * @param value The value of 'parentContext'.
290      * @return This builder.
291      */
292    public org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder setParentContext(org.apache.reef.io.watcher.driver.context.AvroActiveContext value) {
293      validate(fields()[1], value);
294      this.parentContextBuilder = null;
295      this.parentContext = value;
296      fieldSetFlags()[1] = true;
297      return this;
298    }
299
300    /**
301      * Checks whether the 'parentContext' field has been set.
302      * @return True if the 'parentContext' field has been set, false otherwise.
303      */
304    public boolean hasParentContext() {
305      return fieldSetFlags()[1];
306    }
307
308    /**
309     * Gets the Builder instance for the 'parentContext' field and creates one if it doesn't exist yet.
310     * @return This builder.
311     */
312    public org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder getParentContextBuilder() {
313      if (parentContextBuilder == null) {
314        if (hasParentContext()) {
315          setParentContextBuilder(org.apache.reef.io.watcher.driver.context.AvroActiveContext.newBuilder(parentContext));
316        } else {
317          setParentContextBuilder(org.apache.reef.io.watcher.driver.context.AvroActiveContext.newBuilder());
318        }
319      }
320      return parentContextBuilder;
321    }
322
323    /**
324     * Sets the Builder instance for the 'parentContext' field
325     * @param value The builder instance that must be set.
326     * @return This builder.
327     */
328    public org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder setParentContextBuilder(org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder value) {
329      clearParentContext();
330      parentContextBuilder = value;
331      return this;
332    }
333
334    /**
335     * Checks whether the 'parentContext' field has an active Builder instance
336     * @return True if the 'parentContext' field has an active Builder instance
337     */
338    public boolean hasParentContextBuilder() {
339      return parentContextBuilder != null;
340    }
341
342    /**
343      * Clears the value of the 'parentContext' field.
344      * @return This builder.
345      */
346    public org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder clearParentContext() {
347      parentContext = null;
348      parentContextBuilder = null;
349      fieldSetFlags()[1] = false;
350      return this;
351    }
352
353    /**
354      * Gets the value of the 'failure' field.
355      * @return The value.
356      */
357    public org.apache.reef.io.watcher.common.AvroFailure getFailure() {
358      return failure;
359    }
360
361    /**
362      * Sets the value of the 'failure' field.
363      * @param value The value of 'failure'.
364      * @return This builder.
365      */
366    public org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder setFailure(org.apache.reef.io.watcher.common.AvroFailure value) {
367      validate(fields()[2], value);
368      this.failureBuilder = null;
369      this.failure = value;
370      fieldSetFlags()[2] = true;
371      return this;
372    }
373
374    /**
375      * Checks whether the 'failure' field has been set.
376      * @return True if the 'failure' field has been set, false otherwise.
377      */
378    public boolean hasFailure() {
379      return fieldSetFlags()[2];
380    }
381
382    /**
383     * Gets the Builder instance for the 'failure' field and creates one if it doesn't exist yet.
384     * @return This builder.
385     */
386    public org.apache.reef.io.watcher.common.AvroFailure.Builder getFailureBuilder() {
387      if (failureBuilder == null) {
388        if (hasFailure()) {
389          setFailureBuilder(org.apache.reef.io.watcher.common.AvroFailure.newBuilder(failure));
390        } else {
391          setFailureBuilder(org.apache.reef.io.watcher.common.AvroFailure.newBuilder());
392        }
393      }
394      return failureBuilder;
395    }
396
397    /**
398     * Sets the Builder instance for the 'failure' field
399     * @param value The builder instance that must be set.
400     * @return This builder.
401     */
402    public org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder setFailureBuilder(org.apache.reef.io.watcher.common.AvroFailure.Builder value) {
403      clearFailure();
404      failureBuilder = value;
405      return this;
406    }
407
408    /**
409     * Checks whether the 'failure' field has an active Builder instance
410     * @return True if the 'failure' field has an active Builder instance
411     */
412    public boolean hasFailureBuilder() {
413      return failureBuilder != null;
414    }
415
416    /**
417      * Clears the value of the 'failure' field.
418      * @return This builder.
419      */
420    public org.apache.reef.io.watcher.driver.context.AvroFailedContext.Builder clearFailure() {
421      failure = null;
422      failureBuilder = null;
423      fieldSetFlags()[2] = false;
424      return this;
425    }
426
427    @Override
428    public AvroFailedContext build() {
429      try {
430        AvroFailedContext record = new AvroFailedContext();
431        if (baseBuilder != null) {
432          record.base = this.baseBuilder.build();
433        } else {
434          record.base = fieldSetFlags()[0] ? this.base : (org.apache.reef.io.watcher.driver.context.AvroContextBase) defaultValue(fields()[0]);
435        }
436        if (parentContextBuilder != null) {
437          record.parentContext = this.parentContextBuilder.build();
438        } else {
439          record.parentContext = fieldSetFlags()[1] ? this.parentContext : (org.apache.reef.io.watcher.driver.context.AvroActiveContext) defaultValue(fields()[1]);
440        }
441        if (failureBuilder != null) {
442          record.failure = this.failureBuilder.build();
443        } else {
444          record.failure = fieldSetFlags()[2] ? this.failure : (org.apache.reef.io.watcher.common.AvroFailure) defaultValue(fields()[2]);
445        }
446        return record;
447      } catch (Exception e) {
448        throw new org.apache.avro.AvroRuntimeException(e);
449      }
450    }
451  }
452
453  private static final org.apache.avro.io.DatumWriter
454    WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
455
456  @Override public void writeExternal(java.io.ObjectOutput out)
457    throws java.io.IOException {
458    WRITER$.write(this, SpecificData.getEncoder(out));
459  }
460
461  private static final org.apache.avro.io.DatumReader
462    READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
463
464  @Override public void readExternal(java.io.ObjectInput in)
465    throws java.io.IOException {
466    READER$.read(this, SpecificData.getDecoder(in));
467  }
468
469}