コード例 #1
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));
         }
     }
 }
コード例 #2
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());
        }