public class Job extends JobContext
Modifier and Type | Class and Description |
---|---|
static class |
Job.JobState |
COMBINE_CLASS_ATTR, conf, INPUT_FORMAT_CLASS_ATTR, MAP_CLASS_ATTR, OUTPUT_FORMAT_CLASS_ATTR, PARTITIONER_CLASS_ATTR, REDUCE_CLASS_ATTR
Constructor and Description |
---|
Job() |
Job(Configuration conf) |
Job(Configuration conf,
String jobName) |
Modifier and Type | Method and Description |
---|---|
void |
failTask(TaskAttemptID taskId)
Fail indicated task attempt.
|
Counters |
getCounters()
Gets the counters for this job.
|
String |
getJar()
Get the pathname of the job's jar.
|
TaskCompletionEvent[] |
getTaskCompletionEvents(int startFrom)
Get events indicating completion (success/failure) of component tasks.
|
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 |
setCombinerClass(Class<? extends Reducer> cls)
Set the combiner class for the job.
|
void |
setGroupingComparatorClass(Class<? extends 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(Class<? extends InputFormat> cls)
Set the
InputFormat for the job. |
void |
setJarByClass(Class<?> cls)
Set the Jar by finding where a given class came from.
|
void |
setJobName(String name)
Set the user-specified job name.
|
void |
setMapOutputKeyClass(Class<?> theClass)
Set the key class for the map output data.
|
void |
setMapOutputValueClass(Class<?> theClass)
Set the value class for the map output data.
|
void |
setMapperClass(Class<? extends Mapper> cls)
Set the
Mapper for the job. |
void |
setNumReduceTasks(int tasks)
Set the number of reduce tasks for the job.
|
void |
setOutputFormatClass(Class<? extends OutputFormat> cls)
Set the
OutputFormat for the job. |
void |
setOutputKeyClass(Class<?> theClass)
Set the key class for the job output data.
|
void |
setOutputValueClass(Class<?> theClass)
Set the value class for job outputs.
|
void |
setPartitionerClass(Class<? extends Partitioner> cls)
Set the
Partitioner for the job. |
void |
setReducerClass(Class<? extends Reducer> cls)
Set the
Reducer for the job. |
void |
setSortComparatorClass(Class<? extends RawComparator> cls)
Define the comparator that controls how the keys are sorted before they
are passed to the
Reducer . |
void |
setWorkingDirectory(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.
|
getCombinerClass, getConfiguration, getGroupingComparator, getInputFormatClass, getJobID, getJobName, getMapOutputKeyClass, getMapOutputValueClass, getMapperClass, getNumReduceTasks, getOutputFormatClass, getOutputKeyClass, getOutputValueClass, getPartitionerClass, getReducerClass, getSortComparator, getWorkingDirectory
public Job() throws IOException
IOException
public Job(Configuration conf) throws IOException
IOException
public Job(Configuration conf, String jobName) throws IOException
IOException
public void setNumReduceTasks(int tasks) throws IllegalStateException
tasks
- the number of reduce tasksIllegalStateException
- if the job is submittedpublic void setWorkingDirectory(Path dir) throws IOException
dir
- the new current working directory.IllegalStateException
- if the job is submittedIOException
public void setInputFormatClass(Class<? extends InputFormat> cls) throws IllegalStateException
InputFormat
for the job.cls
- the InputFormat
to useIllegalStateException
- if the job is submittedpublic void setOutputFormatClass(Class<? extends OutputFormat> cls) throws IllegalStateException
OutputFormat
for the job.cls
- the OutputFormat
to useIllegalStateException
- if the job is submittedpublic void setMapperClass(Class<? extends Mapper> cls) throws IllegalStateException
Mapper
for the job.cls
- the Mapper
to useIllegalStateException
- if the job is submittedpublic void setJarByClass(Class<?> cls)
cls
- the example classpublic String getJar()
getJar
in class JobContext
public void setCombinerClass(Class<? extends Reducer> cls) throws IllegalStateException
cls
- the combiner to useIllegalStateException
- if the job is submittedpublic void setReducerClass(Class<? extends Reducer> cls) throws IllegalStateException
Reducer
for the job.cls
- the Reducer
to useIllegalStateException
- if the job is submittedpublic void setPartitionerClass(Class<? extends Partitioner> cls) throws IllegalStateException
Partitioner
for the job.cls
- the Partitioner
to useIllegalStateException
- if the job is submittedpublic void setMapOutputKeyClass(Class<?> theClass) throws IllegalStateException
theClass
- the map output key class.IllegalStateException
- if the job is submittedpublic void setMapOutputValueClass(Class<?> theClass) throws IllegalStateException
theClass
- the map output value class.IllegalStateException
- if the job is submittedpublic void setOutputKeyClass(Class<?> theClass) throws IllegalStateException
theClass
- the key class for the job output data.IllegalStateException
- if the job is submittedpublic void setOutputValueClass(Class<?> theClass) throws IllegalStateException
theClass
- the value class for job outputs.IllegalStateException
- if the job is submittedpublic void setSortComparatorClass(Class<? extends RawComparator> cls) throws IllegalStateException
Reducer
.cls
- the raw comparatorIllegalStateException
- if the job is submittedpublic void setGroupingComparatorClass(Class<? extends RawComparator> cls) throws IllegalStateException
Reducer.reduce(Object, Iterable,
org.apache.hadoop.mapreduce.Reducer.Context)
cls
- the raw comparator to useIllegalStateException
- if the job is submittedpublic void setJobName(String name) throws IllegalStateException
name
- the job's new name.IllegalStateException
- if the job is submittedpublic String getTrackingURL()
public float mapProgress() throws IOException
IOException
public float reduceProgress() throws IOException
IOException
public boolean isComplete() throws IOException
true
if the job is complete, else false
.IOException
public boolean isSuccessful() throws IOException
true
if the job succeeded, else false
.IOException
public void killJob() throws IOException
IOException
public TaskCompletionEvent[] getTaskCompletionEvents(int startFrom) throws IOException
startFrom
- index to start fetching events fromTaskCompletionEvent
sIOException
public void killTask(TaskAttemptID taskId) throws IOException
taskId
- the id of the task to be terminated.IOException
public void failTask(TaskAttemptID taskId) throws IOException
taskId
- the id of the task to be terminated.IOException
public Counters getCounters() throws IOException
IOException
public void submit() throws IOException, InterruptedException, ClassNotFoundException
public boolean waitForCompletion(boolean verbose) throws IOException, InterruptedException, ClassNotFoundException
verbose
- print the progress to the userIOException
- thrown if the communication with the
JobTracker
is lostInterruptedException
ClassNotFoundException
Copyright © 2010 The Apache Software Foundation