use of org.apache.hadoop.mapreduce.Counters in project hbase by apache.
the class TestSyncTable method testSyncTableIgnoreTimestampsTrue.
@Test
public void testSyncTableIgnoreTimestampsTrue() throws Exception {
final TableName sourceTableName = TableName.valueOf(name.getMethodName() + "_source");
final TableName targetTableName = TableName.valueOf(name.getMethodName() + "_target");
Path testDir = TEST_UTIL.getDataTestDirOnTestFS("testSyncTableIgnoreTimestampsTrue");
long current = EnvironmentEdgeManager.currentTime();
writeTestData(sourceTableName, targetTableName, current - 1000, current);
hashSourceTable(sourceTableName, testDir, "--ignoreTimestamps=true");
Counters syncCounters = syncTables(sourceTableName, targetTableName, testDir, "--ignoreTimestamps=true");
assertEqualTables(90, sourceTableName, targetTableName, true);
assertEquals(50, syncCounters.findCounter(Counter.ROWSWITHDIFFS).getValue());
assertEquals(10, syncCounters.findCounter(Counter.SOURCEMISSINGROWS).getValue());
assertEquals(10, syncCounters.findCounter(Counter.TARGETMISSINGROWS).getValue());
assertEquals(30, syncCounters.findCounter(Counter.SOURCEMISSINGCELLS).getValue());
assertEquals(30, syncCounters.findCounter(Counter.TARGETMISSINGCELLS).getValue());
assertEquals(20, syncCounters.findCounter(Counter.DIFFERENTCELLVALUES).getValue());
TEST_UTIL.deleteTable(sourceTableName);
TEST_UTIL.deleteTable(targetTableName);
}
use of org.apache.hadoop.mapreduce.Counters in project druid by druid-io.
the class DetermineHashedPartitionsJob method getStats.
@Override
public Map<String, Object> getStats() {
if (groupByJob == null) {
return null;
}
try {
Counters jobCounters = groupByJob.getCounters();
Map<String, Object> metrics = TaskMetricsUtils.makeIngestionRowMetrics(jobCounters.findCounter(HadoopDruidIndexerConfig.IndexJobCounters.ROWS_PROCESSED_COUNTER).getValue(), jobCounters.findCounter(HadoopDruidIndexerConfig.IndexJobCounters.ROWS_PROCESSED_WITH_ERRORS_COUNTER).getValue(), jobCounters.findCounter(HadoopDruidIndexerConfig.IndexJobCounters.ROWS_UNPARSEABLE_COUNTER).getValue(), jobCounters.findCounter(HadoopDruidIndexerConfig.IndexJobCounters.ROWS_THROWN_AWAY_COUNTER).getValue());
return metrics;
} catch (IllegalStateException ise) {
log.debug("Couldn't get counters due to job state");
return null;
} catch (Exception e) {
log.debug(e, "Encountered exception in getStats().");
return null;
}
}
use of org.apache.hadoop.mapreduce.Counters in project Cloud9 by lintool.
the class CountTrecDocuments method run.
/**
* Runs this tool.
*/
@SuppressWarnings("static-access")
public int run(String[] args) throws Exception {
Options options = new Options();
options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("(required) collection path").create(COLLECTION_OPTION));
options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("(required) output path").create(OUTPUT_OPTION));
options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("(required) DocnoMapping data").create(MAPPING_OPTION));
options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("(optional) output file to write the number of records").create(COUNT_OPTION));
CommandLine cmdline;
CommandLineParser parser = new GnuParser();
try {
cmdline = parser.parse(options, args);
} catch (ParseException exp) {
System.err.println("Error parsing command line: " + exp.getMessage());
return -1;
}
if (!cmdline.hasOption(COLLECTION_OPTION) || !cmdline.hasOption(OUTPUT_OPTION) || !cmdline.hasOption(MAPPING_OPTION)) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(this.getClass().getName(), options);
ToolRunner.printGenericCommandUsage(System.out);
return -1;
}
String inputPath = cmdline.getOptionValue(COLLECTION_OPTION);
String outputPath = cmdline.getOptionValue(OUTPUT_OPTION);
String mappingFile = cmdline.getOptionValue(MAPPING_OPTION);
LOG.info("Tool: " + CountTrecDocuments.class.getSimpleName());
LOG.info(" - input: " + inputPath);
LOG.info(" - output dir: " + outputPath);
LOG.info(" - docno mapping file: " + mappingFile);
Job job = new Job(getConf(), CountTrecDocuments.class.getSimpleName());
job.setJarByClass(CountTrecDocuments.class);
job.setNumReduceTasks(0);
// Pass in the class name as a String; this is makes the mapper general in being able to load
// any collection of Indexable objects that has docid/docno mapping specified by a DocnoMapping
// object.
job.getConfiguration().set("DocnoMappingClass", TrecDocnoMapping.class.getCanonicalName());
// Put the mapping file in the distributed cache so each map worker will have it.
DistributedCache.addCacheFile(new URI(mappingFile), job.getConfiguration());
FileInputFormat.setInputPaths(job, new Path(inputPath));
FileOutputFormat.setOutputPath(job, new Path(outputPath));
FileOutputFormat.setCompressOutput(job, false);
job.setInputFormatClass(TrecDocumentInputFormat.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
job.setMapperClass(MyMapper.class);
// Delete the output directory if it exists already.
FileSystem.get(job.getConfiguration()).delete(new Path(outputPath), true);
job.waitForCompletion(true);
Counters counters = job.getCounters();
int numDocs = (int) counters.findCounter(Count.DOCS).getValue();
LOG.info("Read " + numDocs + " docs.");
if (cmdline.hasOption(COUNT_OPTION)) {
String f = cmdline.getOptionValue(COUNT_OPTION);
FileSystem fs = FileSystem.get(getConf());
FSDataOutputStream out = fs.create(new Path(f));
out.write(new Integer(numDocs).toString().getBytes());
out.close();
}
return numDocs;
}
use of org.apache.hadoop.mapreduce.Counters in project cdap by caskdata.
the class MapReduceMetricsWriter method reportStats.
public void reportStats() throws IOException, InterruptedException {
Counters jobCounters = jobConf.getCounters();
reportMapredStats(jobCounters);
}
use of org.apache.hadoop.mapreduce.Counters in project phoenix by apache.
the class IndexScrutinyToolForTenantIT method testTenantViewAndIndexEqual.
/**
* Tests that the config for max number of output rows is observed
*/
@Test
public void testTenantViewAndIndexEqual() throws Exception {
connTenant.createStatement().execute(String.format(upsertQueryStr, tenantViewName, tenantId, 1, "x"));
connTenant.commit();
String[] argValues = getArgValues("", tenantViewName, indexNameTenant, 10L, SourceTable.INDEX_TABLE_SOURCE, false, null, null, tenantId, EnvironmentEdgeManager.currentTimeMillis());
List<Job> completedJobs = runScrutiny(IndexScrutinyMapperForTest.class, argValues);
// Sunny case, both index and view are equal. 1 row
assertEquals(1, completedJobs.size());
for (Job job : completedJobs) {
assertTrue(job.isSuccessful());
Counters counters = job.getCounters();
assertEquals(1, getCounterValue(counters, VALID_ROW_COUNT));
assertEquals(0, getCounterValue(counters, INVALID_ROW_COUNT));
}
}
Aggregations