public class Job extends JobContextImpl implements JobContext
| Modifier and Type | Class and Description |
|---|---|
static class |
Job.JobState |
conf, credentials, ugiCACHE_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 and Description |
|---|
Job() |
Job(org.apache.hadoop.conf.Configuration conf) |
Job(org.apache.hadoop.conf.Configuration conf,
java.lang.String jobName) |
| Modifier and Type | Method and Description |
|---|---|
void |
failTask(TaskAttemptID taskId)
Fail indicated task attempt.
|
Counters |
getCounters()
Gets the counters for this job.
|
static Job |
getInstance()
Creates a new
Job
A Job will be created with a generic Configuration. |
static Job |
getInstance(org.apache.hadoop.conf.Configuration conf)
Creates a new
Job with a given Configuration. |
static Job |
getInstance(org.apache.hadoop.conf.Configuration conf,
java.lang.String jobName)
Creates a new
Job with a given Configuration
and a given jobName. |
java.lang.String |
getJar()
Get the pathname of the job's jar.
|
TaskCompletionEvent[] |
getTaskCompletionEvents(int startFrom)
Get events indicating completion (success/failure) of component tasks.
|
java.lang.String |
getTrackingURL()
Get the URL where some job progress information will be displayed.
|
boolean |
isComplete()
Check if the job is finished or not.
|
boolean |
isSuccessful()
Check if the job completed successfully.
|
void |
killJob()
Kill the running job.
|
void |
killTask(TaskAttemptID taskId)
Kill indicated task attempt.
|
float |
mapProgress()
Get the progress of the job's map-tasks, as a float between 0.0
and 1.0.
|
float |
reduceProgress()
Get the progress of the job's reduce-tasks, as a float between 0.0
and 1.0.
|
void |
setCancelDelegationTokenUponJobCompletion(boolean value)
Sets the flag that will allow the JobTracker to cancel the HDFS delegation
tokens upon job completion.
|
void |
setCombinerClass(java.lang.Class<? extends Reducer> cls)
Set the combiner class for the job.
|
void |
setCombinerKeyGroupingComparatorClass(java.lang.Class<? extends org.apache.hadoop.io.RawComparator> cls)
Define the comparator that controls which keys are grouped together
for a single call to combiner,
Reducer.reduce(Object, Iterable,
org.apache.hadoop.mapreduce.Reducer.Context) |
void |
setGroupingComparatorClass(java.lang.Class<? extends org.apache.hadoop.io.RawComparator> cls)
Define the comparator that controls which keys are grouped together
for a single call to
Reducer.reduce(Object, Iterable,
org.apache.hadoop.mapreduce.Reducer.Context) |
void |
setInputFormatClass(java.lang.Class<? extends InputFormat> cls)
Set the
InputFormat for the job. |
void |
setJarByClass(java.lang.Class<?> cls)
Set the Jar by finding where a given class came from.
|
void |
setJobName(java.lang.String name)
Set the user-specified job name.
|
void |
setMapOutputKeyClass(java.lang.Class<?> theClass)
Set the key class for the map output data.
|
void |
setMapOutputValueClass(java.lang.Class<?> theClass)
Set the value class for the map output data.
|
void |
setMapperClass(java.lang.Class<? extends Mapper> cls)
Set the
Mapper for the job. |
void |
setMapSpeculativeExecution(boolean speculativeExecution)
Turn speculative execution on or off for this job for map tasks.
|
void |
setNumReduceTasks(int tasks)
Set the number of reduce tasks for the job.
|
void |
setOutputFormatClass(java.lang.Class<? extends OutputFormat> cls)
Set the
OutputFormat for the job. |
void |
setOutputKeyClass(java.lang.Class<?> theClass)
Set the key class for the job output data.
|
void |
setOutputValueClass(java.lang.Class<?> theClass)
Set the value class for job outputs.
|
void |
setPartitionerClass(java.lang.Class<? extends Partitioner> cls)
Set the
Partitioner for the job. |
void |
setReducerClass(java.lang.Class<? extends Reducer> cls)
Set the
Reducer for the job. |
void |
setReduceSpeculativeExecution(boolean speculativeExecution)
Turn speculative execution on or off for this job for reduce tasks.
|
void |
setSortComparatorClass(java.lang.Class<? extends org.apache.hadoop.io.RawComparator> cls)
Define the comparator that controls how the keys are sorted before they
are passed to the
Reducer. |
void |
setSpeculativeExecution(boolean speculativeExecution)
Turn speculative execution on or off for this job.
|
float |
setupProgress()
Get the progress of the job's setup, as a float between 0.0
and 1.0.
|
void |
setUserClassesTakesPrecedence(boolean value)
Set the boolean property for specifying which classpath takes precedence -
the user's one or the system one, when the tasks are launched
|
void |
setWorkingDirectory(org.apache.hadoop.fs.Path dir)
Set the current working directory for the default file system.
|
void |
submit()
Submit the job to the cluster and return immediately.
|
boolean |
waitForCompletion(boolean verbose)
Submit the job to the cluster and wait for it to finish.
|
getArchiveClassPaths, getArchiveTimestamps, getCacheArchives, getCacheFiles, getCombinerClass, getCombinerKeyGroupingComparator, getConfiguration, getCredentials, getFileClassPaths, getFileTimestamps, getGroupingComparator, getInputFormatClass, getJobID, getJobName, getJobSetupCleanupNeeded, getLocalCacheArchives, getLocalCacheFiles, getMapOutputKeyClass, getMapOutputValueClass, getMapperClass, getMaxMapAttempts, getMaxReduceAttempts, getNumReduceTasks, getOutputFormatClass, getOutputKeyClass, getOutputValueClass, getPartitionerClass, getProfileEnabled, getProfileParams, getProfileTaskRange, getReducerClass, getSortComparator, getSymlink, getUser, getWorkingDirectory, setJobID, userClassesTakesPrecedenceclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetArchiveClassPaths, getArchiveTimestamps, getCacheArchives, getCacheFiles, getCombinerClass, getCombinerKeyGroupingComparator, getConfiguration, getCredentials, getFileClassPaths, getFileTimestamps, getGroupingComparator, getInputFormatClass, getJobID, getJobName, getJobSetupCleanupNeeded, getLocalCacheArchives, getLocalCacheFiles, getMapOutputKeyClass, getMapOutputValueClass, getMapperClass, getMaxMapAttempts, getMaxReduceAttempts, getNumReduceTasks, getOutputFormatClass, getOutputKeyClass, getOutputValueClass, getPartitionerClass, getProfileEnabled, getProfileParams, getReducerClass, getSortComparator, getSymlink, getUser, getWorkingDirectory, userClassesTakesPrecedencepublic Job()
throws java.io.IOException
java.io.IOExceptionpublic Job(org.apache.hadoop.conf.Configuration conf)
throws java.io.IOException
java.io.IOExceptionpublic Job(org.apache.hadoop.conf.Configuration conf,
java.lang.String jobName)
throws java.io.IOException
java.io.IOExceptionpublic static Job getInstance() throws java.io.IOException
Job
A Job will be created with a generic Configuration.Jobjava.io.IOExceptionpublic static Job getInstance(org.apache.hadoop.conf.Configuration conf) throws java.io.IOException
Job with a given Configuration.
The Job makes a copy of the Configuration so
that any necessary internal modifications do not reflect on the incoming
parameter.conf - the ConfigurationJobjava.io.IOExceptionpublic static Job getInstance(org.apache.hadoop.conf.Configuration conf, java.lang.String jobName) throws java.io.IOException
Job with a given Configuration
and a given jobName.
The Job makes a copy of the Configuration so
that any necessary internal modifications do not reflect on the incoming
parameter.conf - the ConfigurationjobName - the job instance's nameJobjava.io.IOExceptionpublic void setNumReduceTasks(int tasks)
throws java.lang.IllegalStateException
tasks - the number of reduce tasksjava.lang.IllegalStateException - if the job is submittedpublic void setWorkingDirectory(org.apache.hadoop.fs.Path dir)
throws java.io.IOException
dir - the new current working directory.java.lang.IllegalStateException - if the job is submittedjava.io.IOExceptionpublic void setInputFormatClass(java.lang.Class<? extends InputFormat> cls) throws java.lang.IllegalStateException
InputFormat for the job.cls - the InputFormat to usejava.lang.IllegalStateException - if the job is submittedpublic void setOutputFormatClass(java.lang.Class<? extends OutputFormat> cls) throws java.lang.IllegalStateException
OutputFormat for the job.cls - the OutputFormat to usejava.lang.IllegalStateException - if the job is submittedpublic void setMapperClass(java.lang.Class<? extends Mapper> cls) throws java.lang.IllegalStateException
Mapper for the job.cls - the Mapper to usejava.lang.IllegalStateException - if the job is submittedpublic void setJarByClass(java.lang.Class<?> cls)
cls - the example classpublic java.lang.String getJar()
getJar in interface JobContextgetJar in class JobContextImplpublic void setCombinerClass(java.lang.Class<? extends Reducer> cls) throws java.lang.IllegalStateException
cls - the combiner to usejava.lang.IllegalStateException - if the job is submittedpublic void setReducerClass(java.lang.Class<? extends Reducer> cls) throws java.lang.IllegalStateException
Reducer for the job.cls - the Reducer to usejava.lang.IllegalStateException - if the job is submittedpublic void setPartitionerClass(java.lang.Class<? extends Partitioner> cls) throws java.lang.IllegalStateException
Partitioner for the job.cls - the Partitioner to usejava.lang.IllegalStateException - if the job is submittedpublic void setMapOutputKeyClass(java.lang.Class<?> theClass)
throws java.lang.IllegalStateException
theClass - the map output key class.java.lang.IllegalStateException - if the job is submittedpublic void setMapOutputValueClass(java.lang.Class<?> theClass)
throws java.lang.IllegalStateException
theClass - the map output value class.java.lang.IllegalStateException - if the job is submittedpublic void setOutputKeyClass(java.lang.Class<?> theClass)
throws java.lang.IllegalStateException
theClass - the key class for the job output data.java.lang.IllegalStateException - if the job is submittedpublic void setSpeculativeExecution(boolean speculativeExecution)
speculativeExecution - true if speculative execution
should be turned on, else false.public void setMapSpeculativeExecution(boolean speculativeExecution)
speculativeExecution - true if speculative execution
should be turned on for map tasks,
else false.public void setReduceSpeculativeExecution(boolean speculativeExecution)
speculativeExecution - true if speculative execution
should be turned on for reduce tasks,
else false.public void setOutputValueClass(java.lang.Class<?> theClass)
throws java.lang.IllegalStateException
theClass - the value class for job outputs.java.lang.IllegalStateException - if the job is submittedpublic void setSortComparatorClass(java.lang.Class<? extends org.apache.hadoop.io.RawComparator> cls)
throws java.lang.IllegalStateException
Reducer.cls - the raw comparatorjava.lang.IllegalStateException - if the job is submittedsetCombinerKeyGroupingComparatorClass(Class)public void setCombinerKeyGroupingComparatorClass(java.lang.Class<? extends org.apache.hadoop.io.RawComparator> cls)
throws java.lang.IllegalStateException
Reducer.reduce(Object, Iterable,
org.apache.hadoop.mapreduce.Reducer.Context)cls - the raw comparator to usejava.lang.IllegalStateException - if the job is submittedpublic void setGroupingComparatorClass(java.lang.Class<? extends org.apache.hadoop.io.RawComparator> cls)
throws java.lang.IllegalStateException
Reducer.reduce(Object, Iterable,
org.apache.hadoop.mapreduce.Reducer.Context)cls - the raw comparator to usejava.lang.IllegalStateException - if the job is submittedsetCombinerKeyGroupingComparatorClass(Class)public void setJobName(java.lang.String name)
throws java.lang.IllegalStateException
name - the job's new name.java.lang.IllegalStateException - if the job is submittedpublic void setUserClassesTakesPrecedence(boolean value)
value - pass true if user's classes should take precedencepublic java.lang.String getTrackingURL()
public float setupProgress()
throws java.io.IOException
java.io.IOExceptionpublic float mapProgress()
throws java.io.IOException
java.io.IOExceptionpublic float reduceProgress()
throws java.io.IOException
java.io.IOExceptionpublic boolean isComplete()
throws java.io.IOException
true if the job is complete, else false.java.io.IOExceptionpublic boolean isSuccessful()
throws java.io.IOException
true if the job succeeded, else false.java.io.IOExceptionpublic void killJob()
throws java.io.IOException
java.io.IOExceptionpublic TaskCompletionEvent[] getTaskCompletionEvents(int startFrom) throws java.io.IOException
startFrom - index to start fetching events fromTaskCompletionEventsjava.io.IOExceptionpublic void killTask(TaskAttemptID taskId) throws java.io.IOException
taskId - the id of the task to be terminated.java.io.IOExceptionpublic void failTask(TaskAttemptID taskId) throws java.io.IOException
taskId - the id of the task to be terminated.java.io.IOExceptionpublic Counters getCounters() throws java.io.IOException
java.io.IOExceptionpublic void setCancelDelegationTokenUponJobCompletion(boolean value)
public void submit()
throws java.io.IOException,
java.lang.InterruptedException,
java.lang.ClassNotFoundException
java.io.IOExceptionjava.lang.InterruptedExceptionjava.lang.ClassNotFoundExceptionpublic boolean waitForCompletion(boolean verbose)
throws java.io.IOException,
java.lang.InterruptedException,
java.lang.ClassNotFoundException
verbose - print the progress to the userjava.io.IOException - thrown if the communication with the
JobTracker is lostjava.lang.InterruptedExceptionjava.lang.ClassNotFoundExceptionCopyright © 2009 The Apache Software Foundation