static Counters fromAvro(JhCounters counters) { Counters result = new Counters(); for (JhCounterGroup g : counters.groups) { CounterGroup group = new CounterGroup(g.name.toString(), g.displayName.toString()); for (JhCounter c : g.counts) { group.addCounter(new Counter(c.name.toString(), c.displayName.toString(), c.value)); } result.addGroup(group); } return result; }
Counters(org.apache.hadoop.mapred.Counters counters) { for(org.apache.hadoop.mapred.Counters.Group group: counters) { String name = group.getName(); CounterGroup newGroup = new CounterGroup(name, group.getDisplayName()); groups.put(name, newGroup); for(Counter counter: group) { newGroup.addCounter(counter); } } }
/** * Utility method to create a Counters object from the * org.apache.hadoop.mapred counters * @param counters */ public Counters(org.apache.hadoop.mapred.Counters counters) { for(org.apache.hadoop.mapred.Counters.Group group: counters) { String name = group.getName(); CounterGroup newGroup = new CounterGroup(name, group.getDisplayName()); groups.put(name, newGroup); for(Counter counter: group) { newGroup.addCounter(counter); } } }
static Counters fromAvro(JhCounters counters) { Counters result = new Counters(); if(counters != null) { for (JhCounterGroup g : counters.groups) { CounterGroup group = result.addGroup(StringInterner.weakIntern(g.name.toString()), StringInterner.weakIntern(g.displayName.toString())); for (JhCounter c : g.counts) { group.addCounter(StringInterner.weakIntern(c.name.toString()), StringInterner.weakIntern(c.displayName.toString()), c.value); } } } return result; }
static Counters fromAvro(JhCounters counters) { Counters result = new Counters(); if(counters != null) { for (JhCounterGroup g : counters.groups) { CounterGroup group = result.addGroup(StringInterner.weakIntern(g.name.toString()), StringInterner.weakIntern(g.displayName.toString())); for (JhCounter c : g.counts) { group.addCounter(StringInterner.weakIntern(c.name.toString()), StringInterner.weakIntern(c.displayName.toString()), c.value); } } } return result; }
static Counters fromAvro(JhCounters counters) { Counters result = new Counters(); if(counters != null) { for (JhCounterGroup g : counters.groups) { CounterGroup group = result.addGroup(StringInterner.weakIntern(g.name.toString()), StringInterner.weakIntern(g.displayName.toString())); for (JhCounter c : g.counts) { group.addCounter(StringInterner.weakIntern(c.name.toString()), StringInterner.weakIntern(c.displayName.toString()), c.value); } } } return result; }
CounterGroup group1 = counters.addGroup("DOCTORS", "Incarnations of the Doctor"); group1.addCounter("PETER_CAPALDI", "Peter Capaldi", 12); group1.addCounter("MATT_SMITH", "Matt Smith", 11); group1.addCounter("DAVID_TENNANT", "David Tennant", 10); CounterGroup group2 = counters.addGroup("COMPANIONS", "Companions of the Doctor"); group2.addCounter("CLARA_OSWALD", "Clara Oswald", 6); group2.addCounter("RORY_WILLIAMS", "Rory Williams", 5); group2.addCounter("AMY_POND", "Amy Pond", 4); group2.addCounter("MARTHA_JONES", "Martha Jones", 3); group2.addCounter("DONNA_NOBLE", "Donna Noble", 2); group2.addCounter("ROSE_TYLER", "Rose Tyler", 1); JsonNode jsonNode = JobHistoryEventUtils.countersToJSON(counters); String jsonStr = new ObjectMapper().writeValueAsString(jsonNode);
static Counters fromAvro(JhCounters counters) { Counters result = new Counters(); if(counters != null) { for (JhCounterGroup g : counters.getGroups()) { CounterGroup group = result.addGroup(StringInterner.weakIntern(g.getName().toString()), StringInterner.weakIntern(g.getDisplayName().toString())); for (JhCounter c : g.getCounts()) { group.addCounter(StringInterner.weakIntern(c.getName().toString()), StringInterner.weakIntern(c.getDisplayName().toString()), c.getValue()); } } } return result; }
counterDisplayName = Text.readString(in); long value = WritableUtils.readVLong(in); group.addCounter(counterName, counterDisplayName, value);