use of org.apache.tez.dag.api.records.DAGProtos.TezCounterProto in project tez by apache.
the class DagTypeConverters method convertTezCountersToProto.
public static TezCountersProto convertTezCountersToProto(TezCounters counters) {
TezCountersProto.Builder builder = TezCountersProto.newBuilder();
Iterator<CounterGroup> groupIterator = counters.iterator();
int groupIndex = 0;
while (groupIterator.hasNext()) {
CounterGroup counterGroup = groupIterator.next();
TezCounterGroupProto.Builder groupBuilder = TezCounterGroupProto.newBuilder();
groupBuilder.setName(counterGroup.getName());
groupBuilder.setDisplayName(counterGroup.getDisplayName());
Iterator<TezCounter> counterIterator = counterGroup.iterator();
int counterIndex = 0;
while (counterIterator.hasNext()) {
TezCounter counter = counterIterator.next();
TezCounterProto tezCounterProto = TezCounterProto.newBuilder().setName(counter.getName()).setDisplayName(counter.getDisplayName()).setValue(counter.getValue()).build();
groupBuilder.addCounters(counterIndex, tezCounterProto);
++counterIndex;
}
builder.addCounterGroups(groupIndex, groupBuilder.build());
++groupIndex;
}
return builder.build();
}
use of org.apache.tez.dag.api.records.DAGProtos.TezCounterProto in project tez by apache.
the class DAGClientTimelineImpl method parseCounterGroup.
private TezCounterGroupProto.Builder parseCounterGroup(JSONObject counterGroupNode) throws JSONException {
if (counterGroupNode == null) {
return null;
}
TezCounterGroupProto.Builder counterGroup = TezCounterGroupProto.newBuilder();
final String groupName = counterGroupNode.optString(ATSConstants.COUNTER_GROUP_NAME);
final String groupDisplayName = counterGroupNode.optString(ATSConstants.COUNTER_GROUP_DISPLAY_NAME, groupName);
final JSONArray counterNodes = counterGroupNode.optJSONArray(ATSConstants.COUNTERS);
final int numCounters = counterNodes.length();
List<TezCounterProto> counters = new ArrayList<TezCounterProto>(numCounters);
for (int i = 0; i < numCounters; i++) {
final JSONObject counterNode = counterNodes.getJSONObject(i);
final String counterName = counterNode.getString(ATSConstants.COUNTER_NAME);
final String counterDisplayName = counterNode.optString(ATSConstants.COUNTER_DISPLAY_NAME, counterName);
final long counterValue = counterNode.getLong(ATSConstants.COUNTER_VALUE);
counters.add(TezCounterProto.newBuilder().setName(counterName).setDisplayName(counterDisplayName).setValue(counterValue).build());
}
return counterGroup.setName(groupName).setDisplayName(groupDisplayName).addAllCounters(counters);
}
use of org.apache.tez.dag.api.records.DAGProtos.TezCounterProto in project tez by apache.
the class DagTypeConverters method convertTezCountersFromProto.
public static TezCounters convertTezCountersFromProto(TezCountersProto proto) {
TezCounters counters = new TezCounters();
for (TezCounterGroupProto counterGroupProto : proto.getCounterGroupsList()) {
CounterGroup group = counters.addGroup(counterGroupProto.getName(), counterGroupProto.getDisplayName());
for (TezCounterProto counterProto : counterGroupProto.getCountersList()) {
TezCounter counter = group.findCounter(counterProto.getName(), counterProto.getDisplayName());
counter.setValue(counterProto.getValue());
}
}
return counters;
}
Aggregations