org.apache.hadoop.mapreduce.task
Class JobContextImpl

java.lang.Object
  extended by org.apache.hadoop.mapreduce.task.JobContextImpl
All Implemented Interfaces:
JobContext
Direct Known Subclasses:
Job, JobContextImpl, TaskAttemptContextImpl

public class JobContextImpl
extends java.lang.Object
implements JobContext

A read-only view of the job that is provided to the tasks while they are running.


Field Summary
protected  JobConf conf
           
protected  org.apache.hadoop.security.Credentials credentials
           
protected  org.apache.hadoop.security.UserGroupInformation ugi
          The UserGroupInformation object that has a reference to the current user
 
Fields inherited from interface org.apache.hadoop.mapreduce.JobContext
CACHE_ARCHIVES_VISIBILITIES, CACHE_FILE_VISIBILITIES, COMBINE_CLASS_ATTR, INPUT_FORMAT_CLASS_ATTR, JAR_UNPACK_PATTERN, JOB_ACL_MODIFY_JOB, JOB_ACL_VIEW_JOB, JOB_CANCEL_DELEGATION_TOKEN, JOB_NAMENODES, MAP_CLASS_ATTR, MAP_MEMORY_PHYSICAL_MB, MAP_OUTPUT_COLLECTOR_CLASS_ATTR, MAPREDUCE_TASK_CLASSPATH_PRECEDENCE, OUTPUT_FORMAT_CLASS_ATTR, PARTITIONER_CLASS_ATTR, REDUCE_CLASS_ATTR, REDUCE_MEMORY_PHYSICAL_MB, SHUFFLE_CONSUMER_PLUGIN_ATTR, USER_LOG_RETAIN_HOURS
 
Constructor Summary
JobContextImpl(org.apache.hadoop.conf.Configuration conf, JobID jobId)
           
 
Method Summary
 org.apache.hadoop.fs.Path[] getArchiveClassPaths()
          Get the archive entries in classpath as an array of Path
 java.lang.String[] getArchiveTimestamps()
          Get the timestamps of the archives.
 java.net.URI[] getCacheArchives()
          Get cache archives set in the Configuration
 java.net.URI[] getCacheFiles()
          Get cache files set in the Configuration
 java.lang.Class<? extends Reducer<?,?,?,?>> getCombinerClass()
          Get the combiner class for the job.
 org.apache.hadoop.io.RawComparator<?> getCombinerKeyGroupingComparator()
          Get the user defined RawComparator comparator for grouping keys of inputs to the combiner.
 org.apache.hadoop.conf.Configuration getConfiguration()
          Return the configuration for the job.
 org.apache.hadoop.security.Credentials getCredentials()
          Get credentials for the job.
 org.apache.hadoop.fs.Path[] getFileClassPaths()
          Get the file entries in classpath as an array of Path
 java.lang.String[] getFileTimestamps()
          Get the timestamps of the files.
 org.apache.hadoop.io.RawComparator<?> getGroupingComparator()
          Get the user defined RawComparator comparator for grouping keys of inputs to the reduce.
 java.lang.Class<? extends InputFormat<?,?>> getInputFormatClass()
          Get the InputFormat class for the job.
 java.lang.String getJar()
          Get the pathname of the job's jar.
 JobID getJobID()
          Get the unique ID for the job.
 java.lang.String getJobName()
          Get the user-specified job name.
 boolean getJobSetupCleanupNeeded()
          Get whether job-setup and job-cleanup is needed for the job
 org.apache.hadoop.fs.Path[] getLocalCacheArchives()
          Return the path array of the localized caches
 org.apache.hadoop.fs.Path[] getLocalCacheFiles()
          Return the path array of the localized files
 java.lang.Class<?> getMapOutputKeyClass()
          Get the key class for the map output data.
 java.lang.Class<?> getMapOutputValueClass()
          Get the value class for the map output data.
 java.lang.Class<? extends Mapper<?,?,?,?>> getMapperClass()
          Get the Mapper class for the job.
 int getMaxMapAttempts()
          Get the configured number of maximum attempts that will be made to run a map task, as specified by the mapred.map.max.attempts property.
 int getMaxReduceAttempts()
          Get the configured number of maximum attempts that will be made to run a reduce task, as specified by the mapred.reduce.max.attempts property.
 int getNumReduceTasks()
          Get configured the number of reduce tasks for this job.
 java.lang.Class<? extends OutputFormat<?,?>> getOutputFormatClass()
          Get the OutputFormat class for the job.
 java.lang.Class<?> getOutputKeyClass()
          Get the key class for the job output data.
 java.lang.Class<?> getOutputValueClass()
          Get the value class for job outputs.
 java.lang.Class<? extends Partitioner<?,?>> getPartitionerClass()
          Get the Partitioner class for the job.
 boolean getProfileEnabled()
          Get whether the task profiling is enabled.
 java.lang.String getProfileParams()
          Get the profiler configuration arguments.
 org.apache.hadoop.conf.Configuration.IntegerRanges getProfileTaskRange(boolean isMap)
          Get the range of maps or reduces to profile.
 java.lang.Class<? extends Reducer<?,?,?,?>> getReducerClass()
          Get the Reducer class for the job.
 org.apache.hadoop.io.RawComparator<?> getSortComparator()
          Get the RawComparator comparator used to compare keys.
 boolean getSymlink()
          This method checks to see if symlinks are to be create for the localized cache files in the current working directory
 java.lang.String getUser()
          Get the reported username for this job.
 org.apache.hadoop.fs.Path getWorkingDirectory()
          Get the current working directory for the default file system.
 void setJobID(JobID jobId)
          Set the JobID.
 boolean userClassesTakesPrecedence()
          Get the boolean value for the property that specifies which classpath takes precedence when tasks are launched.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conf

protected final JobConf conf

ugi

protected org.apache.hadoop.security.UserGroupInformation ugi
The UserGroupInformation object that has a reference to the current user


credentials

protected final org.apache.hadoop.security.Credentials credentials
Constructor Detail

JobContextImpl

public JobContextImpl(org.apache.hadoop.conf.Configuration conf,
                      JobID jobId)
Method Detail

getConfiguration

public org.apache.hadoop.conf.Configuration getConfiguration()
Return the configuration for the job.

Specified by:
getConfiguration in interface JobContext
Returns:
the shared configuration object

getJobID

public JobID getJobID()
Get the unique ID for the job.

Specified by:
getJobID in interface JobContext
Returns:
the object with the job id

setJobID

public void setJobID(JobID jobId)
Set the JobID.


getNumReduceTasks

public int getNumReduceTasks()
Get configured the number of reduce tasks for this job. Defaults to 1.

Specified by:
getNumReduceTasks in interface JobContext
Returns:
the number of reduce tasks for this job.

getWorkingDirectory

public org.apache.hadoop.fs.Path getWorkingDirectory()
                                              throws java.io.IOException
Get the current working directory for the default file system.

Specified by:
getWorkingDirectory in interface JobContext
Returns:
the directory name.
Throws:
java.io.IOException

getOutputKeyClass

public java.lang.Class<?> getOutputKeyClass()
Get the key class for the job output data.

Specified by:
getOutputKeyClass in interface JobContext
Returns:
the key class for the job output data.

getOutputValueClass

public java.lang.Class<?> getOutputValueClass()
Get the value class for job outputs.

Specified by:
getOutputValueClass in interface JobContext
Returns:
the value class for job outputs.

getMapOutputKeyClass

public java.lang.Class<?> getMapOutputKeyClass()
Get the key class for the map output data. If it is not set, use the (final) output key class. This allows the map output key class to be different than the final output key class.

Specified by:
getMapOutputKeyClass in interface JobContext
Returns:
the map output key class.

getMapOutputValueClass

public java.lang.Class<?> getMapOutputValueClass()
Get the value class for the map output data. If it is not set, use the (final) output value class This allows the map output value class to be different than the final output value class.

Specified by:
getMapOutputValueClass in interface JobContext
Returns:
the map output value class.

getJobName

public java.lang.String getJobName()
Get the user-specified job name. This is only used to identify the job to the user.

Specified by:
getJobName in interface JobContext
Returns:
the job's name, defaulting to "".

userClassesTakesPrecedence

public boolean userClassesTakesPrecedence()
Get the boolean value for the property that specifies which classpath takes precedence when tasks are launched. True - user's classes takes precedence. False - system's classes takes precedence.

Specified by:
userClassesTakesPrecedence in interface JobContext
Returns:
true if user's classes should take precedence

getInputFormatClass

public java.lang.Class<? extends InputFormat<?,?>> getInputFormatClass()
                                                                throws java.lang.ClassNotFoundException
Get the InputFormat class for the job.

Specified by:
getInputFormatClass in interface JobContext
Returns:
the InputFormat class for the job.
Throws:
java.lang.ClassNotFoundException

getMapperClass

public java.lang.Class<? extends Mapper<?,?,?,?>> getMapperClass()
                                                          throws java.lang.ClassNotFoundException
Get the Mapper class for the job.

Specified by:
getMapperClass in interface JobContext
Returns:
the Mapper class for the job.
Throws:
java.lang.ClassNotFoundException

getCombinerClass

public java.lang.Class<? extends Reducer<?,?,?,?>> getCombinerClass()
                                                             throws java.lang.ClassNotFoundException
Get the combiner class for the job.

Specified by:
getCombinerClass in interface JobContext
Returns:
the combiner class for the job.
Throws:
java.lang.ClassNotFoundException

getReducerClass

public java.lang.Class<? extends Reducer<?,?,?,?>> getReducerClass()
                                                            throws java.lang.ClassNotFoundException
Get the Reducer class for the job.

Specified by:
getReducerClass in interface JobContext
Returns:
the Reducer class for the job.
Throws:
java.lang.ClassNotFoundException

getOutputFormatClass

public java.lang.Class<? extends OutputFormat<?,?>> getOutputFormatClass()
                                                                  throws java.lang.ClassNotFoundException
Get the OutputFormat class for the job.

Specified by:
getOutputFormatClass in interface JobContext
Returns:
the OutputFormat class for the job.
Throws:
java.lang.ClassNotFoundException

getPartitionerClass

public java.lang.Class<? extends Partitioner<?,?>> getPartitionerClass()
                                                                throws java.lang.ClassNotFoundException
Get the Partitioner class for the job.

Specified by:
getPartitionerClass in interface JobContext
Returns:
the Partitioner class for the job.
Throws:
java.lang.ClassNotFoundException

getSortComparator

public org.apache.hadoop.io.RawComparator<?> getSortComparator()
Get the RawComparator comparator used to compare keys.

Specified by:
getSortComparator in interface JobContext
Returns:
the RawComparator comparator used to compare keys.

getJar

public java.lang.String getJar()
Get the pathname of the job's jar.

Specified by:
getJar in interface JobContext
Returns:
the pathname

getCombinerKeyGroupingComparator

public org.apache.hadoop.io.RawComparator<?> getCombinerKeyGroupingComparator()
Get the user defined RawComparator comparator for grouping keys of inputs to the combiner.

Specified by:
getCombinerKeyGroupingComparator in interface JobContext
Returns:
comparator set by the user for grouping values.
See Also:
for details.

getGroupingComparator

public org.apache.hadoop.io.RawComparator<?> getGroupingComparator()
Get the user defined RawComparator comparator for grouping keys of inputs to the reduce.

Specified by:
getGroupingComparator in interface JobContext
Returns:
comparator set by the user for grouping values.
See Also:
for details.

getJobSetupCleanupNeeded

public boolean getJobSetupCleanupNeeded()
Get whether job-setup and job-cleanup is needed for the job

Specified by:
getJobSetupCleanupNeeded in interface JobContext
Returns:
boolean

getSymlink

public boolean getSymlink()
This method checks to see if symlinks are to be create for the localized cache files in the current working directory

Specified by:
getSymlink in interface JobContext
Returns:
true if symlinks are to be created- else return false

getArchiveClassPaths

public org.apache.hadoop.fs.Path[] getArchiveClassPaths()
Get the archive entries in classpath as an array of Path

Specified by:
getArchiveClassPaths in interface JobContext

getCacheArchives

public java.net.URI[] getCacheArchives()
                                throws java.io.IOException
Get cache archives set in the Configuration

Specified by:
getCacheArchives in interface JobContext
Returns:
A URI array of the caches set in the Configuration
Throws:
java.io.IOException

getCacheFiles

public java.net.URI[] getCacheFiles()
                             throws java.io.IOException
Get cache files set in the Configuration

Specified by:
getCacheFiles in interface JobContext
Returns:
A URI array of the files set in the Configuration
Throws:
java.io.IOException

getLocalCacheArchives

public org.apache.hadoop.fs.Path[] getLocalCacheArchives()
                                                  throws java.io.IOException
Return the path array of the localized caches

Specified by:
getLocalCacheArchives in interface JobContext
Returns:
A path array of localized caches
Throws:
java.io.IOException

getLocalCacheFiles

public org.apache.hadoop.fs.Path[] getLocalCacheFiles()
                                               throws java.io.IOException
Return the path array of the localized files

Specified by:
getLocalCacheFiles in interface JobContext
Returns:
A path array of localized files
Throws:
java.io.IOException

getFileClassPaths

public org.apache.hadoop.fs.Path[] getFileClassPaths()
Get the file entries in classpath as an array of Path

Specified by:
getFileClassPaths in interface JobContext

getArchiveTimestamps

public java.lang.String[] getArchiveTimestamps()
Get the timestamps of the archives. Used by internal DistributedCache and MapReduce code.

Specified by:
getArchiveTimestamps in interface JobContext
Returns:
a string array of timestamps
Throws:
java.io.IOException

getFileTimestamps

public java.lang.String[] getFileTimestamps()
Get the timestamps of the files. Used by internal DistributedCache and MapReduce code.

Specified by:
getFileTimestamps in interface JobContext
Returns:
a string array of timestamps
Throws:
java.io.IOException

getMaxMapAttempts

public int getMaxMapAttempts()
Get the configured number of maximum attempts that will be made to run a map task, as specified by the mapred.map.max.attempts property. If this property is not already set, the default is 4 attempts.

Specified by:
getMaxMapAttempts in interface JobContext
Returns:
the max number of attempts per map task.

getMaxReduceAttempts

public int getMaxReduceAttempts()
Get the configured number of maximum attempts that will be made to run a reduce task, as specified by the mapred.reduce.max.attempts property. If this property is not already set, the default is 4 attempts.

Specified by:
getMaxReduceAttempts in interface JobContext
Returns:
the max number of attempts per reduce task.

getProfileEnabled

public boolean getProfileEnabled()
Get whether the task profiling is enabled.

Specified by:
getProfileEnabled in interface JobContext
Returns:
true if some tasks will be profiled

getProfileParams

public java.lang.String getProfileParams()
Get the profiler configuration arguments. The default value for this property is "-agentlib:hprof=cpu=samples,heap=sites,force=n,thread=y,verbose=n,file=%s"

Specified by:
getProfileParams in interface JobContext
Returns:
the parameters to pass to the task child to configure profiling

getProfileTaskRange

public org.apache.hadoop.conf.Configuration.IntegerRanges getProfileTaskRange(boolean isMap)
Get the range of maps or reduces to profile.

Parameters:
isMap - is the task a map?
Returns:
the task ranges

getUser

public java.lang.String getUser()
Get the reported username for this job.

Specified by:
getUser in interface JobContext
Returns:
the username

getCredentials

public org.apache.hadoop.security.Credentials getCredentials()
Description copied from interface: JobContext
Get credentials for the job.

Specified by:
getCredentials in interface JobContext
Returns:
credentials for the job


Copyright © 2009 The Apache Software Foundation