Search in sources :

Example 1 with TezCounterProto

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();
}
Also used : TezCounterGroupProto(org.apache.tez.dag.api.records.DAGProtos.TezCounterGroupProto) TezCounterProto(org.apache.tez.dag.api.records.DAGProtos.TezCounterProto) TezCountersProto(org.apache.tez.dag.api.records.DAGProtos.TezCountersProto) CounterGroup(org.apache.tez.common.counters.CounterGroup) TezCounter(org.apache.tez.common.counters.TezCounter) PlanTaskLocationHint(org.apache.tez.dag.api.records.DAGProtos.PlanTaskLocationHint)

Example 2 with TezCounterProto

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);
}
Also used : TezCounterGroupProto(org.apache.tez.dag.api.records.DAGProtos.TezCounterGroupProto) JSONObject(org.codehaus.jettison.json.JSONObject) TezCounterProto(org.apache.tez.dag.api.records.DAGProtos.TezCounterProto) JSONArray(org.codehaus.jettison.json.JSONArray) ArrayList(java.util.ArrayList)

Example 3 with TezCounterProto

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;
}
Also used : TezCounterGroupProto(org.apache.tez.dag.api.records.DAGProtos.TezCounterGroupProto) TezCounterProto(org.apache.tez.dag.api.records.DAGProtos.TezCounterProto) CounterGroup(org.apache.tez.common.counters.CounterGroup) TezCounter(org.apache.tez.common.counters.TezCounter) TezCounters(org.apache.tez.common.counters.TezCounters)

Aggregations

TezCounterGroupProto (org.apache.tez.dag.api.records.DAGProtos.TezCounterGroupProto)3 TezCounterProto (org.apache.tez.dag.api.records.DAGProtos.TezCounterProto)3 CounterGroup (org.apache.tez.common.counters.CounterGroup)2 TezCounter (org.apache.tez.common.counters.TezCounter)2 ArrayList (java.util.ArrayList)1 TezCounters (org.apache.tez.common.counters.TezCounters)1 PlanTaskLocationHint (org.apache.tez.dag.api.records.DAGProtos.PlanTaskLocationHint)1 TezCountersProto (org.apache.tez.dag.api.records.DAGProtos.TezCountersProto)1 JSONArray (org.codehaus.jettison.json.JSONArray)1 JSONObject (org.codehaus.jettison.json.JSONObject)1