org.apache.hadoop.mapreduce.lib.output.FileOutputFormatCounter Java Examples

The following examples show how to use org.apache.hadoop.mapreduce.lib.output.FileOutputFormatCounter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestJobCounters.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private void validateFileCounters(Counters counter, long fileBytesRead,
    long fileBytesWritten, long mapOutputBytes,
    long mapOutputMaterializedBytes) {
  assertTrue(counter.findCounter(FileInputFormatCounter.BYTES_READ)
      .getValue() != 0);
  assertEquals(fileBytesRead,
      counter.findCounter(FileInputFormatCounter.BYTES_READ).getValue());

  assertTrue(counter.findCounter(FileOutputFormatCounter.BYTES_WRITTEN)
      .getValue() != 0);

  if (mapOutputBytes >= 0) {
    assertTrue(counter.findCounter(TaskCounter.MAP_OUTPUT_BYTES).getValue() != 0);
  }
  if (mapOutputMaterializedBytes >= 0) {
    assertTrue(counter.findCounter(TaskCounter.MAP_OUTPUT_MATERIALIZED_BYTES)
        .getValue() != 0);
  }
}
 
Example #2
Source File: MapTask.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
NewDirectOutputCollector(MRJobConfig jobContext,
    JobConf job, TaskUmbilicalProtocol umbilical, TaskReporter reporter) 
throws IOException, ClassNotFoundException, InterruptedException {
  this.reporter = reporter;
  mapOutputRecordCounter = reporter
      .getCounter(TaskCounter.MAP_OUTPUT_RECORDS);
  fileOutputByteCounter = reporter
      .getCounter(FileOutputFormatCounter.BYTES_WRITTEN);

  List<Statistics> matchedStats = null;
  if (outputFormat instanceof org.apache.hadoop.mapreduce.lib.output.FileOutputFormat) {
    matchedStats = getFsStatistics(org.apache.hadoop.mapreduce.lib.output.FileOutputFormat
        .getOutputPath(taskContext), taskContext.getConfiguration());
  }
  fsStats = matchedStats;

  long bytesOutPrev = getOutputBytes(fsStats);
  out = outputFormat.getRecordWriter(taskContext);
  long bytesOutCurr = getOutputBytes(fsStats);
  fileOutputByteCounter.increment(bytesOutCurr - bytesOutPrev);
}
 
Example #3
Source File: MapTask.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void init(MapOutputCollector.Context context
                ) throws IOException, ClassNotFoundException {
  this.reporter = context.getReporter();
  JobConf job = context.getJobConf();
  String finalName = getOutputName(getPartition());
  FileSystem fs = FileSystem.get(job);

  OutputFormat<K, V> outputFormat = job.getOutputFormat();   
  mapOutputRecordCounter = reporter.getCounter(TaskCounter.MAP_OUTPUT_RECORDS);
  
  fileOutputByteCounter = reporter
      .getCounter(FileOutputFormatCounter.BYTES_WRITTEN);

  List<Statistics> matchedStats = null;
  if (outputFormat instanceof FileOutputFormat) {
    matchedStats = getFsStatistics(FileOutputFormat.getOutputPath(job), job);
  }
  fsStats = matchedStats;

  long bytesOutPrev = getOutputBytes(fsStats);
  out = job.getOutputFormat().getRecordWriter(fs, job, finalName, reporter);
  long bytesOutCurr = getOutputBytes(fsStats);
  fileOutputByteCounter.increment(bytesOutCurr - bytesOutPrev);
}
 
Example #4
Source File: TestJobCounters.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void validateFileCounters(Counters counter, long fileBytesRead,
    long fileBytesWritten, long mapOutputBytes,
    long mapOutputMaterializedBytes) {
  assertTrue(counter.findCounter(FileInputFormatCounter.BYTES_READ)
      .getValue() != 0);
  assertEquals(fileBytesRead,
      counter.findCounter(FileInputFormatCounter.BYTES_READ).getValue());

  assertTrue(counter.findCounter(FileOutputFormatCounter.BYTES_WRITTEN)
      .getValue() != 0);

  if (mapOutputBytes >= 0) {
    assertTrue(counter.findCounter(TaskCounter.MAP_OUTPUT_BYTES).getValue() != 0);
  }
  if (mapOutputMaterializedBytes >= 0) {
    assertTrue(counter.findCounter(TaskCounter.MAP_OUTPUT_MATERIALIZED_BYTES)
        .getValue() != 0);
  }
}
 
Example #5
Source File: MapTask.java    From big-c with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
NewDirectOutputCollector(MRJobConfig jobContext,
    JobConf job, TaskUmbilicalProtocol umbilical, TaskReporter reporter) 
throws IOException, ClassNotFoundException, InterruptedException {
  this.reporter = reporter;
  mapOutputRecordCounter = reporter
      .getCounter(TaskCounter.MAP_OUTPUT_RECORDS);
  fileOutputByteCounter = reporter
      .getCounter(FileOutputFormatCounter.BYTES_WRITTEN);

  List<Statistics> matchedStats = null;
  if (outputFormat instanceof org.apache.hadoop.mapreduce.lib.output.FileOutputFormat) {
    matchedStats = getFsStatistics(org.apache.hadoop.mapreduce.lib.output.FileOutputFormat
        .getOutputPath(taskContext), taskContext.getConfiguration());
  }
  fsStats = matchedStats;

  long bytesOutPrev = getOutputBytes(fsStats);
  out = outputFormat.getRecordWriter(taskContext);
  long bytesOutCurr = getOutputBytes(fsStats);
  fileOutputByteCounter.increment(bytesOutCurr - bytesOutPrev);
}
 
Example #6
Source File: MapTask.java    From big-c with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void init(MapOutputCollector.Context context
                ) throws IOException, ClassNotFoundException {
  this.reporter = context.getReporter();
  JobConf job = context.getJobConf();
  String finalName = getOutputName(getPartition());
  FileSystem fs = FileSystem.get(job);

  OutputFormat<K, V> outputFormat = job.getOutputFormat();   
  mapOutputRecordCounter = reporter.getCounter(TaskCounter.MAP_OUTPUT_RECORDS);
  
  fileOutputByteCounter = reporter
      .getCounter(FileOutputFormatCounter.BYTES_WRITTEN);

  List<Statistics> matchedStats = null;
  if (outputFormat instanceof FileOutputFormat) {
    matchedStats = getFsStatistics(FileOutputFormat.getOutputPath(job), job);
  }
  fsStats = matchedStats;

  long bytesOutPrev = getOutputBytes(fsStats);
  out = job.getOutputFormat().getRecordWriter(fs, job, finalName, reporter);
  long bytesOutCurr = getOutputBytes(fsStats);
  fileOutputByteCounter.increment(bytesOutCurr - bytesOutPrev);
}
 
Example #7
Source File: MRCompactionTask.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
private void setCounterInfo(TaskState taskState)
    throws IOException {

  if (mrJob == null) {
    return;
  }

  long recordCount = getCounterValue(mrJob, RecordKeyDedupReducerBase.EVENT_COUNTER.RECORD_COUNT);
  if (recordCount == 0) {
    // map only job
    recordCount = getCounterValue(mrJob, RecordKeyMapperBase.EVENT_COUNTER.RECORD_COUNT);
  }
  taskState.setProp(RECORD_COUNT, recordCount);
  taskState.setProp(FILE_COUNT, getCounterValue(mrJob, CompactorOutputCommitter.EVENT_COUNTER.OUTPUT_FILE_COUNT));
  taskState.setProp(BYTE_COUNT, getCounterValue(mrJob, FileOutputFormatCounter.BYTES_WRITTEN));
}
 
Example #8
Source File: Counters.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "deprecation" })
private static void initDepricatedMap() {
  depricatedCounterMap.put(FileInputFormat.Counter.class.getName(),
    FileInputFormatCounter.class.getName());
  depricatedCounterMap.put(FileOutputFormat.Counter.class.getName(),
    FileOutputFormatCounter.class.getName());
  depricatedCounterMap.put(
    org.apache.hadoop.mapreduce.lib.input.FileInputFormat.Counter.class
      .getName(), FileInputFormatCounter.class.getName());
  depricatedCounterMap.put(
    org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.Counter.class
      .getName(), FileOutputFormatCounter.class.getName());
}
 
Example #9
Source File: Counters.java    From big-c with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "deprecation" })
private static void initDepricatedMap() {
  depricatedCounterMap.put(FileInputFormat.Counter.class.getName(),
    FileInputFormatCounter.class.getName());
  depricatedCounterMap.put(FileOutputFormat.Counter.class.getName(),
    FileOutputFormatCounter.class.getName());
  depricatedCounterMap.put(
    org.apache.hadoop.mapreduce.lib.input.FileInputFormat.Counter.class
      .getName(), FileInputFormatCounter.class.getName());
  depricatedCounterMap.put(
    org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.Counter.class
      .getName(), FileOutputFormatCounter.class.getName());
}