private void initRunningAttempts() { if (this.runningAttempts != null) { return; } TaskReportProtoOrBuilder p = viaProto ? proto : builder; List<TaskAttemptIdProto> list = p.getRunningAttemptsList(); this.runningAttempts = new ArrayList<TaskAttemptId>(); for (TaskAttemptIdProto c : list) { this.runningAttempts.add(convertFromProtoFormat(c)); } }
private void addRunningAttemptsToProto() { maybeInitBuilder(); builder.clearRunningAttempts(); if (runningAttempts == null) return; Iterable<TaskAttemptIdProto> iterable = new Iterable<TaskAttemptIdProto>() { @Override public Iterator<TaskAttemptIdProto> iterator() { return new Iterator<TaskAttemptIdProto>() { Iterator<TaskAttemptId> iter = runningAttempts.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public TaskAttemptIdProto next() { return convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllRunningAttempts(iterable); }
private TaskAttemptIdPBImpl convertFromProtoFormat(TaskAttemptIdProto p) { return new TaskAttemptIdPBImpl(p); }
private TaskAttemptIdProto convertToProtoFormat(TaskAttemptId t) { return ((TaskAttemptIdPBImpl)t).getProto(); }
public TaskAttemptIdPBImpl() { builder = TaskAttemptIdProto.newBuilder(); }
public TaskAttemptIdPBImpl(TaskAttemptIdProto proto) { this.proto = proto; viaProto = true; }
public synchronized TaskAttemptIdProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; }
private synchronized void maybeInitBuilder() { if (viaProto || builder == null) { builder = TaskAttemptIdProto.newBuilder(proto); } viaProto = false; }