def _extract_yarn_counters(counters_record):
 if (not isinstance(counters_record, dict)):
  return {}
 group_records = counters_record.get('groups')
 if (not isinstance(group_records, list)):
  return {}
 counters = {}
 for group_record in group_records:
  if (not isinstance(group_record, dict)):
   continue
  group = group_record.get('displayName')
  if (not isinstance(group, string_types)):
   continue
  counter_records = group_record.get('counts')
  if (not isinstance(counter_records, list)):
   continue
  for counter_record in counter_records:
   counter = counter_record.get('displayName')
   if (not isinstance(counter, string_types)):
    continue
   amount = counter_record.get('value')
   if (not isinstance(amount, integer_types)):
    continue
   counters.setdefault(group, {})
   counters[group].setdefault(counter, 0)
   counters[group][counter] += amount
 return counters

def _extract_yarn_counters ( counters_record ) : if ( not isinstance ( counters_record , dict ) ) : return { } group_records = counters_record . get ( 'groups' ) if ( not isinstance ( group_records , list ) ) : return { } counters = { } for group_record in group_records : if ( not isinstance ( group_record , dict ) ) : continue group = group_record . get ( 'displayName' ) if ( not isinstance ( group , string_types ) ) : continue counter_records = group_record . get ( 'counts' ) if ( not isinstance ( counter_records , list ) ) : continue for counter_record in counter_records : counter = counter_record . get ( 'displayName' ) if ( not isinstance ( counter , string_types ) ) : continue amount = counter_record . get ( 'value' ) if ( not isinstance ( amount , integer_types ) ) : continue counters . setdefault ( group , { } ) counters [ group ] . setdefault ( counter , 0 ) counters [ group ] [ counter ] += amount return counters
convert avro-json counter data structure to our group -> counter -> amount format .