public AbstractCounters(Org.Apache.Hadoop.Mapreduce.Counters.AbstractCounters <C1, G1> counters, CounterGroupFactory <C, G> groupFactory) { this.groupFactory = groupFactory; foreach (G1 group in counters) { string name = group.GetName(); G newGroup = groupFactory.NewGroup(name, group.GetDisplayName(), limits); (CounterGroupFactory.IsFrameworkGroup(name) ? fgroups : groups)[name] = newGroup; foreach (Counter counter in group) { newGroup.AddCounter(counter.GetName(), counter.GetDisplayName(), counter.GetValue ()); } } }
/// <summary>Returns the names of all counter classes.</summary> /// <returns>Set of counter names.</returns> public virtual IEnumerable <string> GetGroupNames() { lock (this) { HashSet <string> deprecated = new HashSet <string>(); foreach (KeyValuePair <string, string> entry in legacyMap) { string newGroup = entry.Value; bool isFGroup = CounterGroupFactory.IsFrameworkGroup(newGroup); if (isFGroup ? fgroups.Contains(newGroup) : groups.Contains(newGroup)) { deprecated.AddItem(entry.Key); } } return(Iterables.Concat(fgroups.Keys, groups.Keys, deprecated)); } }
public virtual G AddGroup(G group) { lock (this) { string name = group.GetName(); if (CounterGroupFactory.IsFrameworkGroup(name)) { fgroups[name] = group; } else { limits.CheckGroups(groups.Count + 1); groups[name] = group; } return(group); } }
/// <summary> /// Increments multiple counters by their amounts in another Counters /// instance. /// </summary> /// <param name="other">the other Counters instance</param> public virtual void IncrAllCounters(Org.Apache.Hadoop.Mapreduce.Counters.AbstractCounters <C, G> other) { lock (this) { foreach (G right in other) { string groupName = right.GetName(); G left = (CounterGroupFactory.IsFrameworkGroup(groupName) ? fgroups : groups)[groupName ]; if (left == null) { left = AddGroup(groupName, right.GetDisplayName()); } left.IncrAllCounters(right); } } }
/// <summary> /// Returns the named counter group, or an empty group if there is none /// with the specified name. /// </summary> /// <param name="groupName">name of the group</param> /// <returns>the group</returns> public virtual G GetGroup(string groupName) { lock (this) { // filterGroupName bool groupNameInLegacyMap = true; string newGroupName = legacyMap[groupName]; if (newGroupName == null) { groupNameInLegacyMap = false; newGroupName = Org.Apache.Hadoop.Mapreduce.Counters.Limits.FilterGroupName(groupName ); } bool isFGroup = CounterGroupFactory.IsFrameworkGroup(newGroupName); G group = isFGroup ? fgroups[newGroupName] : groups[newGroupName]; if (group == null) { group = groupFactory.NewGroup(newGroupName, limits); if (isFGroup) { fgroups[newGroupName] = group; } else { limits.CheckGroups(groups.Count + 1); groups[newGroupName] = group; } if (groupNameInLegacyMap) { Log.Warn("Group " + groupName + " is deprecated. Use " + newGroupName + " instead" ); } } return(group); } }