Class ContextUtil


  • public class ContextUtil
    extends Object
    Utility methods to allow applications to deal with inconsistencies between MapReduce Context Objects API between hadoop-0.20 and later versions.
    • Constructor Summary

      Constructors 
      Constructor Description
      ContextUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.apache.hadoop.conf.Configuration getConfiguration​(org.apache.hadoop.mapreduce.JobContext context)
      Invoke getConfiguration() method on JobContext.
      static org.apache.hadoop.mapreduce.Counter getCounter​(org.apache.hadoop.mapreduce.TaskInputOutputContext context, String groupName, String counterName)  
      static void incrementCounter​(org.apache.hadoop.mapreduce.Counter counter, long increment)  
      static org.apache.hadoop.mapreduce.Counter newGenericCounter​(String name, String displayName, long value)  
      static org.apache.hadoop.mapreduce.JobContext newJobContext​(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.mapreduce.JobID jobId)
      Creates JobContext from a JobConf and jobId using the correct constructor for based on Hadoop version.
      static org.apache.hadoop.mapreduce.TaskAttemptContext newTaskAttemptContext​(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.mapreduce.TaskAttemptID taskAttemptId)
      Creates TaskAttempContext from a JobConf and jobId using the correct constructor for based on Hadoop version.
    • Constructor Detail

      • ContextUtil

        public ContextUtil()
    • Method Detail

      • newJobContext

        public static org.apache.hadoop.mapreduce.JobContext newJobContext​(org.apache.hadoop.conf.Configuration conf,
                                                                           org.apache.hadoop.mapreduce.JobID jobId)
        Creates JobContext from a JobConf and jobId using the correct constructor for based on Hadoop version. jobId could be null.
      • newTaskAttemptContext

        public static org.apache.hadoop.mapreduce.TaskAttemptContext newTaskAttemptContext​(org.apache.hadoop.conf.Configuration conf,
                                                                                           org.apache.hadoop.mapreduce.TaskAttemptID taskAttemptId)
        Creates TaskAttempContext from a JobConf and jobId using the correct constructor for based on Hadoop version.
      • newGenericCounter

        public static org.apache.hadoop.mapreduce.Counter newGenericCounter​(String name,
                                                                            String displayName,
                                                                            long value)
        Returns:
        with Hadoop 2 : new GenericCounter(args),
        with Hadoop 1 : new Counter(args)
      • getConfiguration

        public static org.apache.hadoop.conf.Configuration getConfiguration​(org.apache.hadoop.mapreduce.JobContext context)
        Invoke getConfiguration() method on JobContext. Works with both Hadoop 1 and 2.
      • getCounter

        public static org.apache.hadoop.mapreduce.Counter getCounter​(org.apache.hadoop.mapreduce.TaskInputOutputContext context,
                                                                     String groupName,
                                                                     String counterName)
      • incrementCounter

        public static void incrementCounter​(org.apache.hadoop.mapreduce.Counter counter,
                                            long increment)