Beispiel #1
0
        public virtual void TestGroupIteratorConcurrency()
        {
            Counters counters = new Counters();

            counters.IncrCounter("group1", "counter1", 1);
            Counters.Group group = counters.GetGroup("group1");
            IEnumerator <Counters.Counter> iterator = group.GetEnumerator();

            counters.IncrCounter("group1", "counter2", 1);
            iterator.Next();
        }
Beispiel #2
0
        public virtual void TestFilesystemCounter()
        {
            Counters.GroupFactory groupFactory = new GroupFactoryForTest();
            Counters.Group        fsGroup      = groupFactory.NewFileSystemGroup();
            Counter count1 = fsGroup.FindCounter("ANY_BYTES_READ");

            NUnit.Framework.Assert.IsNotNull(count1);
            // Verify no exception get thrown when finding an unknown counter
            Counter count2 = fsGroup.FindCounter("Unknown");

            NUnit.Framework.Assert.IsNull(count2);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public virtual void TestFileSystemGroupIteratorConcurrency()
        {
            Counters counters = new Counters();

            // create 2 filesystem counter groups
            counters.FindCounter("fs1", FileSystemCounter.BytesRead).Increment(1);
            counters.FindCounter("fs2", FileSystemCounter.BytesRead).Increment(1);
            // Iterate over the counters in this group while updating counters in
            // the group
            Counters.Group group = counters.GetGroup(typeof(FileSystemCounter).FullName);
            IEnumerator <Counters.Counter> iterator = group.GetEnumerator();

            counters.FindCounter("fs3", FileSystemCounter.BytesRead).Increment(1);
            NUnit.Framework.Assert.IsTrue(iterator.HasNext());
            iterator.Next();
            counters.FindCounter("fs3", FileSystemCounter.BytesRead).Increment(1);
            NUnit.Framework.Assert.IsTrue(iterator.HasNext());
            iterator.Next();
        }