public void main(String[] args) throws Exception { conf = new JobConf(System.getProperty("oozie.action.conf.xml")); MorphlinesJob job = new MorphlinesMRDriver().run(conf); if (job.isSuccessful()) { String countersFile = System.getProperty("oozie.action.output.properties"); File file = new File(countersFile); if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); BufferedWriter bw = new BufferedWriter(fw); bw.write("#" + DateTime.now().toString() + "\n"); CounterGroup counterGroup = job.getCounters().getGroup(MorphlinesMRCounters.COUNTERGROUP); String groupname = counterGroup.getDisplayName(); for (Counter c : counterGroup) { bw.write(groupname + "." + c.getDisplayName() + "=" + c.getValue() + "\n"); } bw.close(); } else { throw new RuntimeException("Job is failed. See the log of " + job.getJobID()); } }
private void validateCounters(org.apache.hadoop.mapreduce.Counters counters) { Iterator<org.apache.hadoop.mapreduce.CounterGroup> it = counters.iterator(); while (it.hasNext()) { org.apache.hadoop.mapreduce.CounterGroup group = it.next(); LOG.info("Group " + group.getDisplayName()); Iterator<org.apache.hadoop.mapreduce.Counter> itc = group.iterator(); while (itc.hasNext()) { LOG.info("Counter is " + itc.next().getDisplayName()); } } Assert.assertEquals(1, counters.countCounters()); }
/** {@inheritDoc} */ @Override public synchronized CounterGroup addGroup(CounterGroup grp) { return addGroup(grp.getName(), grp.getDisplayName()); }