Author: tucu Date: Mon Jun 25 22:01:01 2012 New Revision: 1353760 URL: http://svn.apache.org/viewvc?rev=1353760&view=rev Log: Merge -r 1353756:1353757 from trunk to branch. FIXES: MAPREDUCE-4355
Added: hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapred/TestJobClient.java - copied unchanged from r1353757, hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapred/TestJobClient.java Removed: hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapred/TestJobClientGetJob.java Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobClient.java hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Cluster.java Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt?rev=1353760&r1=1353759&r2=1353760&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt (original) +++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt Mon Jun 25 22:01:01 2012 @@ -6,6 +6,8 @@ Release 2.0.1-alpha - UNRELEASED NEW FEATURES + MAPREDUCE-4355. Add JobStatus getJobStatus(JobID) to JobClient. (kkambatl via tucu) + IMPROVEMENTS MAPREDUCE-4146. Support limits on task status string length and number of Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobClient.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobClient.java?rev=1353760&r1=1353759&r2=1353760&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobClient.java (original) +++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobClient.java Mon Jun 25 22:01:01 2012 @@ -620,6 +620,15 @@ public class JobClient extends CLI { } } + private JobStatus getJobStatusUsingCluster(final JobID jobId) + throws IOException, InterruptedException { + return clientUgi.doAs(new PrivilegedExceptionAction<JobStatus>() { + public JobStatus run() throws IOException, InterruptedException { + return JobStatus.downgrade(cluster.getJobStatus(jobId)); + } + }); + } + private Job getJobUsingCluster(final JobID jobid) throws IOException, InterruptedException { return clientUgi.doAs(new PrivilegedExceptionAction<Job>() { @@ -628,28 +637,40 @@ public class JobClient extends CLI { } }); } + /** - * Get an {@link RunningJob} object to track an ongoing job. Returns - * null if the id does not correspond to any known job. + * Get {@link JobStatus} of a job. Returns null if the id does not correspond + * to any known job. * - * @param jobid the jobid of the job. - * @return the {@link RunningJob} handle to track the job, null if the + * @param jobid + * the jobid of the job. + * @return the {@link JobStatus} object to retrieve the job stats, null if the * <code>jobid</code> doesn't correspond to any known job. * @throws IOException */ - public RunningJob getJob(final JobID jobid) throws IOException { + public JobStatus getJobStatus(JobID jobId) throws IOException { try { - - Job job = getJobUsingCluster(jobid); - if (job != null) { - JobStatus status = JobStatus.downgrade(job.getStatus()); - if (status != null) { - return new NetworkedJob(status, cluster); - } - } + return getJobStatusUsingCluster(jobId); } catch (InterruptedException ie) { throw new IOException(ie); } + } + + /** + * Get an {@link RunningJob} object to track an ongoing job. Returns null if + * the id does not correspond to any known job. + * + * @param jobid + * the jobid of the job. + * @return the {@link RunningJob} handle to track the job, null if the + * <code>jobid</code> doesn't correspond to any known job. + * @throws IOException + */ + public RunningJob getJob(JobID jobId) throws IOException { + JobStatus status = getJobStatus(jobId); + if (status != null) { + return new NetworkedJob(status, cluster); + } return null; } Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Cluster.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Cluster.java?rev=1353760&r1=1353759&r2=1353760&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Cluster.java (original) +++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Cluster.java Mon Jun 25 22:01:01 2012 @@ -173,6 +173,19 @@ public class Cluster { } /** + * Get JobStatus corresponding to jobId. + * + * @param jobId + * @return object of {@link JobStatus} + * @throws IOException + * @throws InterruptedException + */ + public JobStatus getJobStatus(JobID jobId) throws IOException, + InterruptedException { + return client.getJobStatus(jobId); + } + + /** * Get job corresponding to jobid. * * @param jobId @@ -181,7 +194,7 @@ public class Cluster { * @throws InterruptedException */ public Job getJob(JobID jobId) throws IOException, InterruptedException { - JobStatus status = client.getJobStatus(jobId); + JobStatus status = getJobStatus(jobId); if (status != null) { return Job.getInstance(this, status, new JobConf(status.getJobFile())); }