Package org.apache.hadoop.mapred.Counters

Examples of org.apache.hadoop.mapred.Counters.Counter


     throws ParseException {
    for (String groupName : counters.getGroupNames()) {
       Group totalGroup = counters.getGroup(groupName);
       Iterator<Counter> itrCounter = totalGroup.iterator();
       while (itrCounter.hasNext()) {
         Counter counter = itrCounter.next();
         if (counter.getName().equals(key)) {
           return counter.getValue();
         }
       }
    }
    return 0;
  }
View Full Code Here


    FileSystem fs = FileSystem.getLocal(conf);
    Path tmpDir = new Path("localpath");
    Class<Text> keyClass = (Class<Text>) jobConf.getMapOutputKeyClass();
    Class<Text> valueClass = (Class<Text>) jobConf.getMapOutputValueClass();
    RawComparator<Text> comparator = jobConf.getOutputKeyComparator();
    Counter readsCounter = new Counter();
    Counter writesCounter = new Counter();
    RawKeyValueIterator mergeQueue = Merger.merge(conf, fs, keyClass,
        valueClass, segments, 2, tmpDir, comparator, getReporter(),
        readsCounter, writesCounter);
    Assert.assertEquals(1.0f, mergeQueue.getProgress().get());
  }
View Full Code Here

     
      Counters counters = job.running_.getCounters();
      assertNotNull("Counters", counters);
      Group group = counters.getGroup("UserCounters");
      assertNotNull("Group", group);
      Counter counter = group.getCounterForName("InputLines");
      assertNotNull("Counter", counter);
      assertEquals(3, counter.getCounter());
    } finally {
      try {
        INPUT_FILE.delete();
        FileUtil.fullyDelete(OUTPUT_DIR.getAbsoluteFile());
      } catch (IOException e) {
View Full Code Here

    final int NUMBER_INC = 10;
    final Random rand = new Random();
    for (int i = 0; i < NUMBER_TESTS; i++) {
      long initValue = rand.nextInt();
      long expectedValue = initValue;
      Counter counter = counters.findCounter("foo", "bar");
      counter.setValue(initValue);
      assertEquals("Counter value is not initialized correctly",
                   expectedValue, counter.getValue());
      for (int j = 0; j < NUMBER_INC; j++) {
        int incValue = rand.nextInt();
        counter.increment(incValue);
        expectedValue += incValue;
        assertEquals("Counter value is not incremented correctly",
                     expectedValue, counter.getValue());
      }
      expectedValue = rand.nextInt();
      counter.setValue(expectedValue);
      assertEquals("Counter value is not set correctly",
                   expectedValue, counter.getValue());
    }
  }
View Full Code Here

        try {
            Counters counterGroups = Counters.fromEscapedCompactString(counters);
            for (Group otherGroup : counterGroups) {
                Group group = counterGroups.getGroup(otherGroup.getName());
                for (Counter otherCounter : otherGroup) {
                    Counter counter = group.getCounterForName(otherCounter.getName());
                    job.put(otherCounter.getName(), String.valueOf(counter.getValue()));
                }
            }
        } catch (ParseException e) {
           LOG.warn("Failed to parse job counters", e);
        }
View Full Code Here

            activeSpillCountRecs = counters.findCounter(
                    PigCounters.PROACTIVE_SPILL_COUNT_RECS).getCounter();

            Iterator<Counter> iter = multistoregroup.iterator();
            while (iter.hasNext()) {
                Counter cter = iter.next();
                multiStoreCounters.put(cter.getName(), cter.getValue());
            }    
           
            Iterator<Counter> iter2 = multiloadgroup.iterator();
            while (iter2.hasNext()) {
                Counter cter = iter2.next();
                multiInputCounters.put(cter.getName(), cter.getValue());
            }
           
        }             
    }
View Full Code Here

            while (iter.hasNext()) {
                Group group = iter.next();

                Iterator<Counter> cIter = group.iterator();
                while (cIter.hasNext()) {
                    Counter c = cIter.next();
                    taskCounters.append("    <counter name='").append(c.getDisplayName()).append("' value='").append(c.getValue()).append("'>\n");
                }
            }

            taskCounters.append("   </counters>\n");
            taskCounters.append("  </task>\n");
        }

        taskCounters.append(" </mapTasks>\n");

        taskCounters.append(" <reduceTasks>\n");

        for (TaskReport reduceTaskReport : reduceTaskReports) {
            taskCounters.append("  <task id='").append(reduceTaskReport.getTaskID().toString()).append("'\n");
            taskCounters.append("   <counters>\n");

            Counters counter = reduceTaskReport.getCounters();

            Iterator<Group> iter = counter.iterator();

            while (iter.hasNext()) {
                Group group = iter.next();

                Iterator<Counter> cIter = group.iterator();
                while (cIter.hasNext()) {
                    Counter c = cIter.next();
                    taskCounters.append("    <counter name='").append(c.getDisplayName()).append("' value='").append(c.getValue()).append("'>\n");
                }
            }

            taskCounters.append("   </counters>\n");
            taskCounters.append("  </task>\n");
View Full Code Here

                Group group = iter.next();

                if (group.getDisplayName().equalsIgnoreCase(getGroupName())) {
                    Iterator<Counter> cIter = group.iterator();
                    while (cIter.hasNext()) {
                        Counter c = cIter.next();
                        counters.put(c.getDisplayName(), String.valueOf(c.getValue()));
                    }
                }
            }
        } else {
            while (iter.hasNext()) {
                Group group = iter.next();
                Iterator<Counter> cIter = group.iterator();
                while (cIter.hasNext()) {
                    Counter c = cIter.next();
                    counters.put(c.getDisplayName(), String.valueOf(c.getValue()));
                }
            }
        }
        return counters;
    }
View Full Code Here

      while (iter.hasNext()) {
        Group group = iter.next();
         
          Iterator<Counter> cIter = group.iterator();
          while (cIter.hasNext()) {
            Counter c = cIter.next();
            taskCounters.append("    <counter name='" + c.getDisplayName() + "' value='" + c.getValue() + "'>\n");
          }
        }
     
      taskCounters.append("   </counters>\n");
      taskCounters.append("  </task>\n");     
    }
   
    taskCounters.append(" </mapTasks>\n");
   
    taskCounters.append(" <reduceTasks>\n");
   
    for (TaskReport reduceTaskReport : reduceTaskReports)
    {
      taskCounters.append("  <task id='"+reduceTaskReport.getTaskID().toString()+"'\n");
      taskCounters.append("   <counters>\n");
     
      Counters counter = reduceTaskReport.getCounters();
     
      Iterator<Group> iter = counter.iterator();   
     
      while (iter.hasNext()) {
        Group group = iter.next();
         
          Iterator<Counter> cIter = group.iterator();
          while (cIter.hasNext()) {
            Counter c = cIter.next();
            taskCounters.append("    <counter name='" + c.getDisplayName() + "' value='" + c.getValue() + "'>\n");
          }
        }
     
      taskCounters.append("   </counters>\n");
      taskCounters.append("  </task>\n");     
View Full Code Here

     
        if (group.getDisplayName().equalsIgnoreCase(getGroupName()))
        {     
          Iterator<Counter> cIter = group.iterator();
          while (cIter.hasNext()) {
            Counter c = cIter.next();
            counters.put(c.getDisplayName(), String.valueOf(c.getValue()));
          }
        }
      }
    }
    else
    {
      while (iter.hasNext()) {
        Group group = iter.next();       
        Iterator<Counter> cIter = group.iterator();
          while (cIter.hasNext()) {
            Counter c = cIter.next();
            counters.put(c.getDisplayName(), String.valueOf(c.getValue()));
          }
      }
    }
    return counters;
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.mapred.Counters.Counter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.