java.lang.Object org.apache.hadoop.conf.Configured org.apache.hadoop.mapred.JobClient
public class JobClient
JobClient
is the primary interface for the user-job to interact with the JobTracker
. JobClient
provides facilities to submit jobs, track their progress, access component-tasks' reports/logs, get the Map-Reduce cluster status information etc.
The job submission process involves:
InputSplit
s for the job.DistributedCache
of the job, if necessary.JobTracker
and optionally monitoring it's status.JobConf
and then uses the JobClient
to submit the job and monitor its progress.
Here is an example on how to use JobClient
:
Job Control// Create a new JobConf JobConf job = new JobConf(new Configuration(), MyJob.class); // Specify various job-specific parameters job.setJobName("myjob"); job.setInputPath(new Path("in")); job.setOutputPath(new Path("out")); job.setMapperClass(MyJob.MyMapper.class); job.setReducerClass(MyJob.MyReducer.class); // Submit the job, then poll for progress until the job is complete JobClient.runJob(job);
At times clients would chain map-reduce jobs to accomplish complex tasks which cannot be done via a single map-reduce job. This is fairly easy since the output of the job, typically, goes to distributed file-system and that can be used as the input for the next job.
However, this also means that the onus on ensuring jobs are complete (success/failure) lies squarely on the clients. In such situations the various job-control options are:
runJob(JobConf)
: submits the job and returns only after the job has completed.submitJob(JobConf)
: only submits the job, then poll the returned handle to the RunningJob
to query status and make scheduling decisions.JobConf.setJobEndNotificationURI(String)
: setup a notification on job-completion, thus avoiding polling.JobConf
, ClusterStatus
, Tool
, DistributedCache
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
MAPREDUCE_CLIENT_RETRY_POLICY_ENABLED_KEY
public static final String MAPREDUCE_CLIENT_RETRY_POLICY_ENABLED_KEY
public static final boolean MAPREDUCE_CLIENT_RETRY_POLICY_ENABLED_DEFAULT
public static final String MAPREDUCE_CLIENT_RETRY_POLICY_SPEC_KEY
public static final String MAPREDUCE_CLIENT_RETRY_POLICY_SPEC_DEFAULT
public static final int HEARTBEAT_INTERVAL_MIN
public static final long COUNTER_UPDATE_INTERVAL
public static final long DEFAULT_DISK_HEALTH_CHECK_INTERVAL
public static final int SUCCESS
public static final int FILE_NOT_FOUND
public static final String MAP_OUTPUT_LENGTH
public static final String RAW_MAP_OUTPUT_LENGTH
public static final String FROM_MAP_TASK
public static final String FOR_REDUCE_TASK
public static final String WORKDIR
public JobClient()
public JobClient(JobConf conf) throws IOException
JobConf
, and connect to the default JobTracker
.
conf
- the job configuration.
IOException
public JobClient(InetSocketAddress jobTrackAddr, Configuration conf) throws IOException
jobTrackAddr
- the job tracker to connect to.
conf
- configuration.
IOException
public void init(JobConf conf) throws IOException
JobTracker
.
conf
- the job configuration.
IOException
public void close() throws IOException
JobClient
.
IOException
public FileSystem getFs() throws IOException
IOException
public RunningJob submitJob(String jobFile) throws FileNotFoundException, InvalidJobConfException, IOException
RunningJob
which can be used to track the running-job.
jobFile
- the job configuration.
RunningJob
which can be used to track the running-job.
FileNotFoundException
InvalidJobConfException
IOException
public RunningJob submitJob(JobConf job) throws FileNotFoundException, IOException
RunningJob
which can be used to track the running-job.
job
- the job configuration.
RunningJob
which can be used to track the running-job.
FileNotFoundException
IOException
public RunningJob submitJobInternal(JobConf job) throws FileNotFoundException, ClassNotFoundException, InterruptedException, IOException
job
- the configuration to submit
FileNotFoundException
ClassNotFoundException
InterruptedException
IOException
public static boolean isJobDirValid(Path jobDirPath, FileSystem fs) throws IOException
IOException
public RunningJob getJob(JobID jobid) throws IOException
RunningJob
object to track an ongoing job. Returns null if the id does not correspond to any known job.
jobid
- the jobid of the job.
RunningJob
handle to track the job, null if the jobid
doesn't correspond to any known job.
IOException
@Deprecated public RunningJob getJob(String jobid) throws IOException
getJob(JobID)
.
IOException
public TaskReport[] getMapTaskReports(JobID jobId) throws IOException
jobId
- the job to query.
IOException
@Deprecated public TaskReport[] getMapTaskReports(String jobId) throws IOException
getMapTaskReports(JobID)
IOException
public TaskReport[] getReduceTaskReports(JobID jobId) throws IOException
jobId
- the job to query.
IOException
public TaskReport[] getCleanupTaskReports(JobID jobId) throws IOException
jobId
- the job to query.
IOException
public TaskReport[] getSetupTaskReports(JobID jobId) throws IOException
jobId
- the job to query.
IOException
@Deprecated public TaskReport[] getReduceTaskReports(String jobId) throws IOException
getReduceTaskReports(JobID)
IOException
public void displayTasks(JobID jobId, String type, String state) throws IOException
jobId
- the ID of the job
type
- the type of the task (map/reduce/setup/cleanup)
state
- the state of the task (pending/running/completed/failed/killed)
IOException
public ClusterStatus getClusterStatus() throws IOException
ClusterStatus
.
IOException
public ClusterStatus getClusterStatus(boolean detailed) throws IOException
detailed
- if true then get a detailed status including the tracker names and memory usage of the JobTracker
ClusterStatus
.
IOException
public Path getStagingAreaDir() throws IOException
IOException
public JobStatus[] jobsToComplete() throws IOException
JobStatus
for the running/to-be-run jobs.
IOException
public JobStatus[] getAllJobs() throws IOException
JobStatus
for the submitted jobs.
IOException
public static RunningJob runJob(JobConf job) throws IOException
job
- the job configuration.
IOException
- if the job fails
public boolean monitorAndPrintJob(JobConf conf, RunningJob job) throws IOException, InterruptedException
conf
- the job's configuration
job
- the job to track
IOException
- if communication to the JobTracker fails
InterruptedException
@Deprecated public void setTaskOutputFilter(JobClient.TaskStatusFilter newValue)
newValue
- task filter.
public static JobClient.TaskStatusFilter getTaskOutputFilter(JobConf job)
job
- the JobConf to examine.
public static void setTaskOutputFilter(JobConf job, JobClient.TaskStatusFilter newValue)
job
- the JobConf to modify.
newValue
- the value to set.
@Deprecated public JobClient.TaskStatusFilter getTaskOutputFilter()
public int run(String[] argv) throws Exception
Tool
run
in interface Tool
argv
- command specific arguments.
Exception
public int getDefaultMaps() throws IOException
IOException
public int getDefaultReduces() throws IOException
IOException
public Path getSystemDir()
public JobQueueInfo[] getQueues() throws IOException
IOException
public JobStatus[] getJobsFromQueue(String queueName) throws IOException
queueName
- name of the Job Queue
IOException
public JobQueueInfo getQueueInfo(String queueName) throws IOException
queueName
- name of the job queue.
IOException
public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException
IOException
public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer) throws IOException, InterruptedException
IOException
InterruptedException
public long renewDelegationToken(Token<DelegationTokenIdentifier> token) throws SecretManager.InvalidToken, IOException, InterruptedException
token
- the token to renew
SecretManager.InvalidToken
IOException
InterruptedException
public void cancelDelegationToken(Token<DelegationTokenIdentifier> token) throws IOException, InterruptedException
token
- the token to cancel
IOException
InterruptedException
public static void main(String[] argv) throws Exception
Exception
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4