コード例 #1
0
        private void AddCounters(CounterGroup group)
        {
            group.ListViewGroup = this.listView1.Groups.Add(group.Name, group.Name);

            List <CounterItem> items = new List <CounterItem>(group.Counters.Length);

            foreach (Counter counter in group.Counters)
            {
                CounterItem item = new CounterItem();
                item.Text                    = counter.Name;
                item.ToolTipText             = counter.Description;
                item.Group                   = group.ListViewGroup;
                item.Font                    = _nameFont;
                item.Counter                 = counter;
                item.UseItemStyleForSubItems = false;

                ListViewItem.ListViewSubItem valueItem = new ListViewItem.ListViewSubItem(item, "-");
                valueItem.Font = _valueFont;
                item.SubItems.Add(valueItem);
                ListViewItem.ListViewSubItem deltaItem = new ListViewItem.ListViewSubItem(item, "-");
                deltaItem.Font = _valueFont;
                item.SubItems.Add(deltaItem);

                this.listView1.Items.Add(item);
                items.Add(item);
            }
            group.Items = items.ToArray();

            this.timer1.Enabled = true;
        }
コード例 #2
0
ファイル: TypeConverter.cs プロジェクト: orf53975/hadoop.net
        public static Counters ToYarn(Counters counters)
        {
            if (counters == null)
            {
                return(null);
            }
            Counters yCntrs = recordFactory.NewRecordInstance <Counters>();

            yCntrs.AddAllCounterGroups(new Dictionary <string, CounterGroup>());
            foreach (CounterGroup grp in counters)
            {
                CounterGroup yGrp = recordFactory.NewRecordInstance <CounterGroup>();
                yGrp.SetName(grp.GetName());
                yGrp.SetDisplayName(grp.GetDisplayName());
                yGrp.AddAllCounters(new Dictionary <string, Counter>());
                foreach (Counter cntr in grp)
                {
                    Counter yCntr = recordFactory.NewRecordInstance <Counter>();
                    yCntr.SetName(cntr.GetName());
                    yCntr.SetDisplayName(cntr.GetDisplayName());
                    yCntr.SetValue(cntr.GetValue());
                    yGrp.SetCounter(yCntr.GetName(), yCntr);
                }
                yCntrs.SetCounterGroup(yGrp.GetName(), yGrp);
            }
            return(yCntrs);
        }
コード例 #3
0
        public virtual void TestCountersIncrement()
        {
            Counters fCounters = new Counters();
            Counter  fCounter  = fCounters.FindCounter(FrameworkCounter);

            fCounter.SetValue(100);
            Counter gCounter = fCounters.FindCounter("test", "foo");

            gCounter.SetValue(200);
            Counters counters = new Counters();

            counters.IncrAllCounters(fCounters);
            Counter counter;

            foreach (CounterGroup cg in fCounters)
            {
                CounterGroup group = counters.GetGroup(cg.GetName());
                if (group.GetName().Equals("test"))
                {
                    counter = counters.FindCounter("test", "foo");
                    NUnit.Framework.Assert.AreEqual(200, counter.GetValue());
                }
                else
                {
                    counter = counters.FindCounter(FrameworkCounter);
                    NUnit.Framework.Assert.AreEqual(100, counter.GetValue());
                }
            }
        }
コード例 #4
0
        private void AddCounters( CounterGroup group )
        {
            group.ListViewGroup = this.listView1.Groups.Add( group.Name, group.Name );

            List<CounterItem> items = new List<CounterItem>( group.Counters.Length );
            foreach( Counter counter in group.Counters )
            {
                CounterItem item = new CounterItem();
                item.Text = counter.Name;
                item.ToolTipText = counter.Description;
                item.Group = group.ListViewGroup;
                item.Font = _nameFont;
                item.Counter = counter;
                item.UseItemStyleForSubItems = false;

                ListViewItem.ListViewSubItem valueItem = new ListViewItem.ListViewSubItem( item, "-" );
                valueItem.Font = _valueFont;
                item.SubItems.Add( valueItem );
                ListViewItem.ListViewSubItem deltaItem = new ListViewItem.ListViewSubItem( item, "-" );
                deltaItem.Font = _valueFont;
                item.SubItems.Add( deltaItem );

                this.listView1.Items.Add( item );
                items.Add( item );
            }
            group.Items = items.ToArray();

            this.timer1.Enabled = true;
        }
コード例 #5
0
 private void PrintCounters(StringBuilder buff, Counters totalCounters, Counters mapCounters
                            , Counters reduceCounters)
 {
     // Killed jobs might not have counters
     if (totalCounters == null)
     {
         return;
     }
     buff.Append("\nCounters: \n\n");
     buff.Append(string.Format("|%1$-30s|%2$-30s|%3$-10s|%4$-10s|%5$-10s|", "Group Name"
                               , "Counter name", "Map Value", "Reduce Value", "Total Value"));
     buff.Append("\n------------------------------------------" + "---------------------------------------------"
                 );
     foreach (string groupName in totalCounters.GetGroupNames())
     {
         CounterGroup          totalGroup  = totalCounters.GetGroup(groupName);
         CounterGroup          mapGroup    = mapCounters.GetGroup(groupName);
         CounterGroup          reduceGroup = reduceCounters.GetGroup(groupName);
         Format                @decimal    = new DecimalFormat();
         IEnumerator <Counter> ctrItr      = totalGroup.GetEnumerator();
         while (ctrItr.HasNext())
         {
             Counter counter     = ctrItr.Next();
             string  name        = counter.GetName();
             string  mapValue    = @decimal.Format(mapGroup.FindCounter(name).GetValue());
             string  reduceValue = @decimal.Format(reduceGroup.FindCounter(name).GetValue());
             string  totalValue  = @decimal.Format(counter.GetValue());
             buff.Append(string.Format("%n|%1$-30s|%2$-30s|%3$-10s|%4$-10s|%5$-10s", totalGroup
                                       .GetDisplayName(), counter.GetDisplayName(), mapValue, reduceValue, totalValue));
         }
     }
 }
コード例 #6
0
        public virtual void TestPbRecordFactory()
        {
            RecordFactory pbRecordFactory = RecordFactoryPBImpl.Get();

            try
            {
                CounterGroup response = pbRecordFactory.NewRecordInstance <CounterGroup>();
                NUnit.Framework.Assert.AreEqual(typeof(CounterGroupPBImpl), response.GetType());
            }
            catch (YarnRuntimeException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
                NUnit.Framework.Assert.Fail("Failed to crete record");
            }
            try
            {
                GetCountersRequest response = pbRecordFactory.NewRecordInstance <GetCountersRequest
                                                                                 >();
                NUnit.Framework.Assert.AreEqual(typeof(GetCountersRequestPBImpl), response.GetType
                                                    ());
            }
            catch (YarnRuntimeException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
                NUnit.Framework.Assert.Fail("Failed to crete record");
            }
        }
コード例 #7
0
        public virtual Counter GetCounter <_T0>(Enum <_T0> key)
            where _T0 : Enum <E>
        {
            CounterGroup group = GetCounterGroup(key.GetDeclaringClass().FullName);

            return(group == null ? null : group.GetCounter(key.Name()));
        }
コード例 #8
0
        public Tuple <string, Tuple <string, OutputLevel> > CreateCounter(string groupName, int secondsInterval, int refreshInstanceInterval, List <ICounter> counters, CollectorEngineType collectorEngineType)
        {
            var response = new CounterGroup(groupName, secondsInterval, refreshInstanceInterval, counters, new ITag[] { }, collectorEngineType, null, null, false);
            var message  = CreateFile(groupName, response);

            return(new Tuple <string, Tuple <string, OutputLevel> >(groupName, message));
        }
コード例 #9
0
        /// <summary>Adds the counter to the set that the EventSource will report on.</summary>
        /// <remarks>
        /// Must only be invoked once, and only after the instance has been fully initialized.
        /// This should be invoked by a derived type's ctor as the last thing it does.
        /// </remarks>
        private protected void Publish()
        {
            Debug.Assert(_group is null);
            Debug.Assert(Name != null);
            Debug.Assert(EventSource != null);

            _group = CounterGroup.GetCounterGroup(EventSource);
            _group.Add(this);
        }
コード例 #10
0
 public TaskCounterGroupInfo(string name, CounterGroup group)
 {
     this.counterGroupName = name;
     this.counter          = new AList <TaskCounterInfo>();
     foreach (Counter c in group)
     {
         TaskCounterInfo cinfo = new TaskCounterInfo(c.GetName(), c.GetValue());
         this.counter.AddItem(cinfo);
     }
 }
コード例 #11
0
        private Tuple <string, OutputLevel> CreateMemoryCounter()
        {
            var name = "memory";

            var counters = new List <ICounter> {
                new Counter("Memory", "*")
            };
            var response = new CounterGroup(name, 10, 0, counters, new ITag[] { }, CollectorEngineType.Safe);

            return(ConvertErrorsToWarnings(CreateFile(name, response)));
        }
コード例 #12
0
        private Tuple <string, OutputLevel> CreateProcessorCounter()
        {
            var name = "processor";

            var counters = new List <ICounter> {
                new Counter("Processor", "% Processor Time", "*", null, null)
            };
            var response = new CounterGroup(name, 10, 0, counters, new ITag[] { }, CollectorEngineType.Safe);

            return(ConvertErrorsToWarnings(CreateFile(name, response)));
        }
コード例 #13
0
 public CounterGroupInfo(string name, CounterGroup group, CounterGroup mg, CounterGroup
                         rg)
 {
     this.counterGroupName = name;
     this.counter          = new AList <CounterInfo>();
     foreach (Counter c in group)
     {
         Counter     mc    = mg == null ? null : mg.FindCounter(c.GetName());
         Counter     rc    = rg == null ? null : rg.FindCounter(c.GetName());
         CounterInfo cinfo = new CounterInfo(c, mc, rc);
         this.counter.AddItem(cinfo);
     }
 }
コード例 #14
0
ファイル: MiniR21.cs プロジェクト: CK-Yong/QboxNext
        protected override void AddCounterPayload(Mini07ParseModel model, CounterGroup group)
        {
            var number = Parser.ParseByte();

            model.Payloads.Add(new R21CounterPayload
            {
                InternalNr = number & 0x7F,
                // Bit 7 (0x80) indicates if the counter value is valid (0) / invalid (1)
                IsValid      = (number & 0x80) == 0x00,
                Value        = Parser.ParseUInt32(),
                PrimaryMeter = group.PrimaryMeterCounters,
                Source       = group.CounterSource
            });
        }
コード例 #15
0
        private Tuple <string, OutputLevel> CreateDiskCounter()
        {
            var name = "disk";

            var counters = new List <ICounter>
            {
                new Counter("LogicalDisk", new Naming("Free Megabytes"), new Naming("*"), null, null, null, null, null, null),
                new Counter("LogicalDisk", new Naming("% Free Space"), new Naming("*"), null, null, 100, 0, null, null),
                new Counter("LogicalDisk", new Naming("% Free Space", "% Used Space"), new Naming("*"), null, null, 100, 0, null, 100),
            };
            var response = new CounterGroup(name, 600, 0, counters, new ITag[] { }, CollectorEngineType.Safe, null, null, false);

            return(ConvertErrorsToWarnings(CreateFile(name, response)));
        }
コード例 #16
0
        private Tuple <string, OutputLevel> CreateMemoryCounter()
        {
            var name = "memory";

            var counters = new List <ICounter>
            {
                //new Counter("Memory", new Naming("*"), new Naming(string.Empty), null, null, null, null, null, null),
                new Counter("Memory", new Naming("% Committed Bytes In Use"), new Naming(string.Empty), null, null, null, null, null, null),
                new Counter("Memory", new Naming("% Committed Bytes In Use", "% Committed Bytes Free"), new Naming(string.Empty), null, null, null, null, null, 100),
            };
            var response = new CounterGroup(name, 10, 0, counters, new ITag[] { }, CollectorEngineType.Safe, null, null, false);

            return(ConvertErrorsToWarnings(CreateFile(name, response)));
        }
コード例 #17
0
        private void ValidateCounters(Counters counters)
        {
            IEnumerator <CounterGroup> it = counters.GetEnumerator();

            while (it.HasNext())
            {
                CounterGroup group = it.Next();
                Log.Info("Group " + group.GetDisplayName());
                IEnumerator <Counter> itc = group.GetEnumerator();
                while (itc.HasNext())
                {
                    Log.Info("Counter is " + itc.Next().GetDisplayName());
                }
            }
            NUnit.Framework.Assert.AreEqual(1, counters.CountCounters());
        }
コード例 #18
0
 internal static CounterGroup GetCounterGroup(EventSource eventSource)
 {
     lock (s_counterGroupsLock)
     {
         int eventSourceIndex = EventListener.EventSourceIndex(eventSource);
         EnsureEventSourceIndexAvailable(eventSourceIndex);
         WeakReference <CounterGroup> weakRef = CounterGroup.s_counterGroups[eventSourceIndex];
         CounterGroup ret = null;
         if (weakRef == null || !weakRef.TryGetTarget(out ret))
         {
             ret = new CounterGroup(eventSource);
             CounterGroup.s_counterGroups[eventSourceIndex] = new WeakReference <CounterGroup>(ret);
         }
         return(ret);
     }
 }
コード例 #19
0
        internal static Counters GetMyCounters()
        {
            Counter counter = recordFactory.NewRecordInstance <Counter>();

            counter.SetName("Mycounter");
            counter.SetDisplayName("My counter display name");
            counter.SetValue(12345);
            CounterGroup group = recordFactory.NewRecordInstance <CounterGroup>();

            group.SetName("MyGroup");
            group.SetDisplayName("My groupd display name");
            group.SetCounter("myCounter", counter);
            Counters counters = recordFactory.NewRecordInstance <Counters>();

            counters.SetCounterGroup("myGroupd", group);
            return(counters);
        }
コード例 #20
0
        /// <summary>
        /// All Counters live as long as the EventSource that they are attached to unless they are
        /// explicitly Disposed.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="eventSource">The event source.</param>
        internal DiagnosticCounter(string name, EventSource eventSource)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(Name));
            }

            if (eventSource == null)
            {
                throw new ArgumentNullException(nameof(EventSource));
            }

            _group = CounterGroup.GetCounterGroup(eventSource);
            _group.Add(this);
            Name        = name;
            EventSource = eventSource;
        }
コード例 #21
0
        /// <summary>
        /// All Counters live as long as the EventSource that they are attached to unless they are
        /// explicitly Disposed.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="eventSource">The event source.</param>
        public BaseCounter(string name, EventSource eventSource)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(_name));
            }

            if (eventSource == null)
            {
                throw new ArgumentNullException(nameof(eventSource));
            }

            _group = CounterGroup.GetCounterGroup(eventSource);
            _group.Add(this);
            _eventSource = eventSource;
            _name        = name;
            _metaData    = new Dictionary <string, string>();
        }
コード例 #22
0
        private Tuple <string, OutputLevel> CreateFile(string name, CounterGroup counterGroup)
        {
            var config        = _configBusiness.LoadFiles(new string[] { });
            var counterGroups = _counterBusiness.GetPerformanceCounterGroups(config).ToArray();

            if (counterGroups.Any(x => x.Name == counterGroup.Name))
            {
                return(new Tuple <string, OutputLevel>(string.Format("There is already a counter group named {0}.", counterGroup.Name), OutputLevel.Error));
            }

            if (!_configBusiness.CreateConfig(name + ".xml", new List <ICounterGroup> {
                counterGroup
            }))
            {
                return(new Tuple <string, OutputLevel>(string.Format("Did not create {0}, the file {0}.xml" + " already exists.", name), OutputLevel.Error));
            }

            return(new Tuple <string, OutputLevel>(string.Format("Created counter config {0}.", name), OutputLevel.Information));
        }
コード例 #23
0
        private GetCountersResponse GetCountersResponseFromHistoryServer()
        {
            GetCountersResponse countersResponse = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord
                                                   <GetCountersResponse>();
            Counter      counter      = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <Counter>();
            CounterGroup counterGroup = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <CounterGroup
                                                                                       >();
            Counters counters = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <Counters>();

            counter.SetDisplayName("dummyCounter");
            counter.SetName("dummyCounter");
            counter.SetValue(1001);
            counterGroup.SetName("dummyCounters");
            counterGroup.SetDisplayName("dummyCounters");
            counterGroup.SetCounter("dummyCounter", counter);
            counters.SetCounterGroup("dummyCounters", counterGroup);
            countersResponse.SetCounters(counters);
            return(countersResponse);
        }
コード例 #24
0
        internal static Counters FromAvro(JhCounters counters)
        {
            Counters result = new Counters();

            if (counters != null)
            {
                foreach (JhCounterGroup g in counters.groups)
                {
                    CounterGroup group = result.AddGroup(StringInterner.WeakIntern(g.name.ToString())
                                                         , StringInterner.WeakIntern(g.displayName.ToString()));
                    foreach (JhCounter c in g.counts)
                    {
                        group.AddCounter(StringInterner.WeakIntern(c.name.ToString()), StringInterner.WeakIntern
                                             (c.displayName.ToString()), c.value);
                    }
                }
            }
            return(result);
        }
コード例 #25
0
 public JobCounterInfo(AppContext ctx, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job
                       job)
 {
     GetCounters(ctx, job);
     counterGroup = new AList <CounterGroupInfo>();
     this.id      = MRApps.ToString(job.GetID());
     if (total != null)
     {
         foreach (CounterGroup g in total)
         {
             if (g != null)
             {
                 CounterGroup     mg     = map == null ? null : map.GetGroup(g.GetName());
                 CounterGroup     rg     = reduce == null ? null : reduce.GetGroup(g.GetName());
                 CounterGroupInfo cginfo = new CounterGroupInfo(g.GetName(), g, mg, rg);
                 counterGroup.AddItem(cginfo);
             }
         }
     }
 }
コード例 #26
0
ファイル: CompilerModel.cs プロジェクト: EvgenTat/brocompiler
        public ProcessCountersGroup(DateTime start, DateTime finish, CounterGroup counters, int index)
        {
            Start  = start;
            Finish = finish;

            Children = new List <Timeline.IItem>();

            CounterDescription   desc = counters.Descriptions[index];
            ProcessChartLineItem item = new ProcessChartLineItem()
            {
                Name = desc.Name, Start = start, Finish = finish
            };

            for (int x = 0; x < counters.Samples.Count; ++x)
            {
                item.Points.Add(new KeyValuePair <DateTime, double>(counters.Samples[x].Timestamp, counters.Samples[x].Values[index]));
            }

            Children.Add(item);

            Height = Children.Max(c => c.Height);
        }
コード例 #27
0
 private CounterGroup CreateCounterGroup(CounterGroup.GroupBy groupBy, LogEvent eventArgs)
 {
     return new CounterGroup(
         eventArgs.Counter,
         groupBy.HasFlag(CounterGroup.GroupBy.Source)? "ALL_SOURCES" : eventArgs.Source,
         groupBy.HasFlag(CounterGroup.GroupBy.Instance) ? "ALL_INSTANCES" : eventArgs.Instance,
         groupBy.HasFlag(CounterGroup.GroupBy.ExtendedData) ? "ALL_EXTDATA" : eventArgs.ExtendedData
         );
 }
コード例 #28
0
 private MRProtos.CounterGroupProto ConvertToProtoFormat(CounterGroup t)
 {
     return(((CounterGroupPBImpl)t).GetProto());
 }
コード例 #29
0
        /// <exception cref="System.Exception"/>
        protected internal virtual void _testMOWithJavaSerialization(bool withCounters)
        {
            string        input = "a\nb\nc\nd\ne\nc\nd\ne";
            Configuration conf  = CreateJobConf();

            conf.Set("io.serializations", "org.apache.hadoop.io.serializer.JavaSerialization,"
                     + "org.apache.hadoop.io.serializer.WritableSerialization");
            Job job = MapReduceTestUtil.CreateJob(conf, InDir, OutDir, 2, 1, input);

            job.SetJobName("mo");
            MultipleOutputs.AddNamedOutput(job, Text, typeof(TextOutputFormat), typeof(long),
                                           typeof(string));
            MultipleOutputs.SetCountersEnabled(job, withCounters);
            job.SetSortComparatorClass(typeof(JavaSerializationComparator));
            job.SetMapOutputKeyClass(typeof(long));
            job.SetMapOutputValueClass(typeof(string));
            job.SetOutputKeyClass(typeof(long));
            job.SetOutputValueClass(typeof(string));
            job.SetMapperClass(typeof(TestMRMultipleOutputs.MOJavaSerDeMap));
            job.SetReducerClass(typeof(TestMRMultipleOutputs.MOJavaSerDeReduce));
            job.WaitForCompletion(true);
            // assert number of named output part files
            int        namedOutputCount      = 0;
            int        valueBasedOutputCount = 0;
            FileSystem fs = OutDir.GetFileSystem(conf);

            FileStatus[] statuses = fs.ListStatus(OutDir);
            foreach (FileStatus status in statuses)
            {
                string fileName = status.GetPath().GetName();
                if (fileName.Equals("text-m-00000") || fileName.Equals("text-m-00001") || fileName
                    .Equals("text-r-00000"))
                {
                    namedOutputCount++;
                }
                else
                {
                    if (fileName.Equals("a-r-00000") || fileName.Equals("b-r-00000") || fileName.Equals
                            ("c-r-00000") || fileName.Equals("d-r-00000") || fileName.Equals("e-r-00000"))
                    {
                        valueBasedOutputCount++;
                    }
                }
            }
            NUnit.Framework.Assert.AreEqual(3, namedOutputCount);
            NUnit.Framework.Assert.AreEqual(5, valueBasedOutputCount);
            // assert TextOutputFormat files correctness
            BufferedReader reader = new BufferedReader(new InputStreamReader(fs.Open(new Path
                                                                                         (FileOutputFormat.GetOutputPath(job), "text-r-00000"))));
            int    count = 0;
            string line  = reader.ReadLine();

            while (line != null)
            {
                NUnit.Framework.Assert.IsTrue(line.EndsWith(Text));
                line = reader.ReadLine();
                count++;
            }
            reader.Close();
            NUnit.Framework.Assert.IsFalse(count == 0);
            if (withCounters)
            {
                CounterGroup counters = job.GetCounters().GetGroup(typeof(MultipleOutputs).FullName
                                                                   );
                NUnit.Framework.Assert.AreEqual(6, counters.Size());
                NUnit.Framework.Assert.AreEqual(4, counters.FindCounter(Text).GetValue());
                NUnit.Framework.Assert.AreEqual(2, counters.FindCounter("a").GetValue());
                NUnit.Framework.Assert.AreEqual(2, counters.FindCounter("b").GetValue());
                NUnit.Framework.Assert.AreEqual(4, counters.FindCounter("c").GetValue());
                NUnit.Framework.Assert.AreEqual(4, counters.FindCounter("d").GetValue());
                NUnit.Framework.Assert.AreEqual(4, counters.FindCounter("e").GetValue());
            }
        }
コード例 #30
0
        /// <exception cref="System.Exception"/>
        protected internal virtual void _testMultipleOutputs(bool withCounters)
        {
            string        input = "a\nb\nc\nd\ne\nc\nd\ne";
            Configuration conf  = CreateJobConf();
            Job           job   = MapReduceTestUtil.CreateJob(conf, InDir, OutDir, 2, 1, input);

            job.SetJobName("mo");
            MultipleOutputs.AddNamedOutput(job, Text, typeof(TextOutputFormat), typeof(LongWritable
                                                                                       ), typeof(Text));
            MultipleOutputs.AddNamedOutput(job, Sequence, typeof(SequenceFileOutputFormat), typeof(
                                               IntWritable), typeof(Text));
            MultipleOutputs.SetCountersEnabled(job, withCounters);
            job.SetMapperClass(typeof(TestMRMultipleOutputs.MOMap));
            job.SetReducerClass(typeof(TestMRMultipleOutputs.MOReduce));
            job.WaitForCompletion(true);
            // assert number of named output part files
            int        namedOutputCount      = 0;
            int        valueBasedOutputCount = 0;
            FileSystem fs = OutDir.GetFileSystem(conf);

            FileStatus[] statuses = fs.ListStatus(OutDir);
            foreach (FileStatus status in statuses)
            {
                string fileName = status.GetPath().GetName();
                if (fileName.Equals("text-m-00000") || fileName.Equals("text-m-00001") || fileName
                    .Equals("text-r-00000") || fileName.Equals("sequence_A-m-00000") || fileName.Equals
                        ("sequence_A-m-00001") || fileName.Equals("sequence_B-m-00000") || fileName.Equals
                        ("sequence_B-m-00001") || fileName.Equals("sequence_B-r-00000") || fileName.Equals
                        ("sequence_C-r-00000"))
                {
                    namedOutputCount++;
                }
                else
                {
                    if (fileName.Equals("a-r-00000") || fileName.Equals("b-r-00000") || fileName.Equals
                            ("c-r-00000") || fileName.Equals("d-r-00000") || fileName.Equals("e-r-00000"))
                    {
                        valueBasedOutputCount++;
                    }
                }
            }
            NUnit.Framework.Assert.AreEqual(9, namedOutputCount);
            NUnit.Framework.Assert.AreEqual(5, valueBasedOutputCount);
            // assert TextOutputFormat files correctness
            BufferedReader reader = new BufferedReader(new InputStreamReader(fs.Open(new Path
                                                                                         (FileOutputFormat.GetOutputPath(job), "text-r-00000"))));
            int    count = 0;
            string line  = reader.ReadLine();

            while (line != null)
            {
                NUnit.Framework.Assert.IsTrue(line.EndsWith(Text));
                line = reader.ReadLine();
                count++;
            }
            reader.Close();
            NUnit.Framework.Assert.IsFalse(count == 0);
            // assert SequenceOutputFormat files correctness
            SequenceFile.Reader seqReader = new SequenceFile.Reader(fs, new Path(FileOutputFormat
                                                                                 .GetOutputPath(job), "sequence_B-r-00000"), conf);
            NUnit.Framework.Assert.AreEqual(typeof(IntWritable), seqReader.GetKeyClass());
            NUnit.Framework.Assert.AreEqual(typeof(Text), seqReader.GetValueClass());
            count = 0;
            IntWritable key   = new IntWritable();
            Text        value = new Text();

            while (seqReader.Next(key, value))
            {
                NUnit.Framework.Assert.AreEqual(Sequence, value.ToString());
                count++;
            }
            seqReader.Close();
            NUnit.Framework.Assert.IsFalse(count == 0);
            if (withCounters)
            {
                CounterGroup counters = job.GetCounters().GetGroup(typeof(MultipleOutputs).FullName
                                                                   );
                NUnit.Framework.Assert.AreEqual(9, counters.Size());
                NUnit.Framework.Assert.AreEqual(4, counters.FindCounter(Text).GetValue());
                NUnit.Framework.Assert.AreEqual(2, counters.FindCounter(Sequence + "_A").GetValue
                                                    ());
                NUnit.Framework.Assert.AreEqual(4, counters.FindCounter(Sequence + "_B").GetValue
                                                    ());
                NUnit.Framework.Assert.AreEqual(2, counters.FindCounter(Sequence + "_C").GetValue
                                                    ());
                NUnit.Framework.Assert.AreEqual(2, counters.FindCounter("a").GetValue());
                NUnit.Framework.Assert.AreEqual(2, counters.FindCounter("b").GetValue());
                NUnit.Framework.Assert.AreEqual(4, counters.FindCounter("c").GetValue());
                NUnit.Framework.Assert.AreEqual(4, counters.FindCounter("d").GetValue());
                NUnit.Framework.Assert.AreEqual(4, counters.FindCounter("e").GetValue());
            }
        }
コード例 #31
0
 public AggregatedValue(CounterGroup counterGroup, AggregationOperationResult value)
 {
     CounterGroup = counterGroup;
     Value = value;
 }
コード例 #32
0
ファイル: CountersBlock.cs プロジェクト: orf53975/hadoop.net
        protected override void Render(HtmlBlock.Block html)
        {
            if (job == null)
            {
                html.P().("Sorry, no counters for nonexistent", $(AMParams.JobId, "job")).();
                return;
            }
            if (!$(AMParams.TaskId).IsEmpty() && task == null)
            {
                html.P().("Sorry, no counters for nonexistent", $(AMParams.TaskId, "task")).();
                return;
            }
            if (total == null || total.GetGroupNames() == null || total.CountCounters() == 0)
            {
                string type = $(AMParams.TaskId);
                if (type == null || type.IsEmpty())
                {
                    type = $(AMParams.JobId, "the job");
                }
                html.P().("Sorry it looks like ", type, " has no counters.").();
                return;
            }
            string urlBase;
            string urlId;

            if (task != null)
            {
                urlBase = "singletaskcounter";
                urlId   = MRApps.ToString(task.GetID());
            }
            else
            {
                urlBase = "singlejobcounter";
                urlId   = MRApps.ToString(job.GetID());
            }
            int numGroups = 0;

            Hamlet.TBODY <Hamlet.TABLE <Hamlet.DIV <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet>
                                        > > tbody = html.Div(JQueryUI.InfoWrap).Table("#counters").Thead().Tr().Th(".group.ui-state-default"
                                                                                                                   , "Counter Group").Th(".ui-state-default", "Counters").().().Tbody();
            foreach (CounterGroup g in total)
            {
                CounterGroup mg = map == null ? null : map.GetGroup(g.GetName());
                CounterGroup rg = reduce == null ? null : reduce.GetGroup(g.GetName());
                ++numGroups;
                // This is mostly for demonstration :) Typically we'd introduced
                // a CounterGroup block to reduce the verbosity. OTOH, this
                // serves as an indicator of where we're in the tag hierarchy.
                Hamlet.TR <Hamlet.THEAD <Hamlet.TABLE <Hamlet.TD <Hamlet.TR <Hamlet.TBODY <Hamlet.TABLE
                                                                                           <Hamlet.DIV <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > > > > > > > groupHeadRow = tbody
                                                                                                                                                                                  .Tr().Th().$title(g.GetName()).$class("ui-state-default").(FixGroupDisplayName(g
                                                                                                                                                                                                                                                                 .GetDisplayName())).().Td().$class(JQueryUI.CTable).Table(".dt-counters").$id(job
                                                                                                                                                                                                                                                                                                                                               .GetID() + "." + g.GetName()).Thead().Tr().Th(".name", "Name");
                if (map != null)
                {
                    groupHeadRow.Th("Map").Th("Reduce");
                }
                // Ditto
                Hamlet.TBODY <Hamlet.TABLE <Hamlet.TD <Hamlet.TR <Hamlet.TBODY <Hamlet.TABLE <Hamlet.DIV
                                                                                              <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > > > > > > group = groupHeadRow.Th(map
                                                                                                                                                                                == null ? "Value" : "Total").().().Tbody();
                foreach (Counter counter in g)
                {
                    // Ditto
                    Hamlet.TR <Hamlet.TBODY <Hamlet.TABLE <Hamlet.TD <Hamlet.TR <Hamlet.TBODY <Hamlet.TABLE
                                                                                               <Hamlet.DIV <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > > > > > > > groupRow = group
                                                                                                                                                                                  .Tr();
                    if (task == null && mg == null && rg == null)
                    {
                        groupRow.Td().$title(counter.GetName()).(counter.GetDisplayName()).();
                    }
                    else
                    {
                        groupRow.Td().$title(counter.GetName()).A(Url(urlBase, urlId, g.GetName(), counter
                                                                      .GetName()), counter.GetDisplayName()).();
                    }
                    if (map != null)
                    {
                        Counter mc = mg == null ? null : mg.FindCounter(counter.GetName());
                        Counter rc = rg == null ? null : rg.FindCounter(counter.GetName());
                        groupRow.Td(mc == null ? "0" : string.Format("%,d", mc.GetValue())).Td(rc == null
                                                         ? "0" : string.Format("%,d", rc.GetValue()));
                    }
                    groupRow.Td(string.Format("%,d", counter.GetValue())).();
                }
                group.().().().();
            }
            tbody.().().();
        }
コード例 #33
0
 public AggregatedValue(CounterGroup counterGroup, AggregationOperationResult value)
 {
     CounterGroup = counterGroup;
     Value        = value;
 }