public virtual void TestFrameworkCounter() { Counters.GroupFactory groupFactory = new GroupFactoryForTest(); CounterGroupFactory.FrameworkGroupFactory frameworkGroupFactory = groupFactory.NewFrameworkGroupFactory <JobCounter>(); Counters.Group group = (Counters.Group)frameworkGroupFactory.NewGroup("JobCounter" ); FrameworkCounterGroup counterGroup = (FrameworkCounterGroup)group.GetUnderlyingGroup (); Counter count1 = counterGroup.FindCounter(JobCounter.NumFailedMaps.ToString()); NUnit.Framework.Assert.IsNotNull(count1); // Verify no exception get thrown when finding an unknown counter Counter count2 = counterGroup.FindCounter("Unknown"); NUnit.Framework.Assert.IsNull(count2); }
/// <summary>Create a new framework group</summary> /// <param name="id">of the group</param> /// <returns>a new framework group</returns> public virtual G NewFrameworkGroup(int id) { string name; lock (typeof(CounterGroupFactory)) { if (id < 0 || id >= i2s.Count) { ThrowBadFrameGroupIdException(id); } name = i2s[id]; } // should not throw here. CounterGroupFactory.FrameworkGroupFactory <G> gf = fmap[name]; if (gf == null) { ThrowBadFrameGroupIdException(id); } return(gf.NewGroup(name)); }
/// <summary>Create a new counter group</summary> /// <param name="name">of the group</param> /// <param name="displayName">of the group</param> /// <param name="limits">the counters limits policy object</param> /// <returns>a new counter group</returns> public virtual G NewGroup(string name, string displayName, Limits limits) { CounterGroupFactory.FrameworkGroupFactory <G> gf = fmap[name]; if (gf != null) { return(gf.NewGroup(name)); } if (name.Equals(FsGroupName)) { return(NewFileSystemGroup()); } else { if (s2i[name] != null) { return(NewFrameworkGroup(s2i[name])); } } return(NewGenericGroup(name, displayName, limits)); }