Skip to content

Commit 3f249b6

Browse files
author
Alejandro Abdelnur
committed
MAPREDUCE-4942. mapreduce.Job has a bunch of methods that throw InterruptedException so its incompatible with MR1. (rkanter via tucu)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1480748 13f79535-47bb-0310-9956-ffa450edef68
1 parent 2583f92 commit 3f249b6

File tree

4 files changed

+80
-84
lines changed

4 files changed

+80
-84
lines changed

hadoop-mapreduce-project/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ Release 2.0.5-beta - UNRELEASED
395395
MAPREDUCE-5226. Handling YarnRemoteException separately from IOException in
396396
MR App's use of AMRMProtocol after YARN-630. (Xuan Gong via vinodkv)
397397

398+
MAPREDUCE-4942. mapreduce.Job has a bunch of methods that throw
399+
InterruptedException so its incompatible with MR1. (rkanter via tucu)
400+
398401
Release 2.0.4-alpha - 2013-04-25
399402

400403
INCOMPATIBLE CHANGES

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobClient.java

Lines changed: 15 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -209,23 +209,15 @@ public String getTrackingURL() {
209209
* completed.
210210
*/
211211
public float mapProgress() throws IOException {
212-
try {
213-
return job.mapProgress();
214-
} catch (InterruptedException ie) {
215-
throw new IOException(ie);
216-
}
212+
return job.mapProgress();
217213
}
218214

219215
/**
220216
* A float between 0.0 and 1.0, indicating the % of reduce work
221217
* completed.
222218
*/
223219
public float reduceProgress() throws IOException {
224-
try {
225-
return job.reduceProgress();
226-
} catch (InterruptedException ie) {
227-
throw new IOException(ie);
228-
}
220+
return job.reduceProgress();
229221
}
230222

231223
/**
@@ -245,33 +237,21 @@ public float cleanupProgress() throws IOException {
245237
* completed.
246238
*/
247239
public float setupProgress() throws IOException {
248-
try {
249-
return job.setupProgress();
250-
} catch (InterruptedException ie) {
251-
throw new IOException(ie);
252-
}
240+
return job.setupProgress();
253241
}
254242

255243
/**
256244
* Returns immediately whether the whole job is done yet or not.
257245
*/
258246
public synchronized boolean isComplete() throws IOException {
259-
try {
260-
return job.isComplete();
261-
} catch (InterruptedException ie) {
262-
throw new IOException(ie);
263-
}
247+
return job.isComplete();
264248
}
265249

266250
/**
267251
* True iff job completed successfully.
268252
*/
269253
public synchronized boolean isSuccessful() throws IOException {
270-
try {
271-
return job.isSuccessful();
272-
} catch (InterruptedException ie) {
273-
throw new IOException(ie);
274-
}
254+
return job.isSuccessful();
275255
}
276256

277257
/**
@@ -302,11 +282,7 @@ public synchronized int getJobState() throws IOException {
302282
* Tells the service to terminate the current job.
303283
*/
304284
public synchronized void killJob() throws IOException {
305-
try {
306-
job.killJob();
307-
} catch (InterruptedException ie) {
308-
throw new IOException(ie);
309-
}
285+
job.killJob();
310286
}
311287

312288

@@ -331,14 +307,10 @@ public synchronized void setJobPriority(String priority)
331307
*/
332308
public synchronized void killTask(TaskAttemptID taskId,
333309
boolean shouldFail) throws IOException {
334-
try {
335-
if (shouldFail) {
336-
job.failTask(taskId);
337-
} else {
338-
job.killTask(taskId);
339-
}
340-
} catch (InterruptedException ie) {
341-
throw new IOException(ie);
310+
if (shouldFail) {
311+
job.failTask(taskId);
312+
} else {
313+
job.killTask(taskId);
342314
}
343315
}
344316

@@ -378,16 +350,12 @@ public String toString() {
378350
* Returns the counters for this job
379351
*/
380352
public Counters getCounters() throws IOException {
381-
try {
382-
Counters result = null;
383-
org.apache.hadoop.mapreduce.Counters temp = job.getCounters();
384-
if(temp != null) {
385-
result = Counters.downgrade(temp);
386-
}
387-
return result;
388-
} catch (InterruptedException ie) {
389-
throw new IOException(ie);
353+
Counters result = null;
354+
org.apache.hadoop.mapreduce.Counters temp = job.getCounters();
355+
if(temp != null) {
356+
result = Counters.downgrade(temp);
390357
}
358+
return result;
391359
}
392360

393361
@Override

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Job.java

Lines changed: 61 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private void ensureState(JobState state) throws IllegalStateException {
296296
* it, if necessary
297297
*/
298298
synchronized void ensureFreshStatus()
299-
throws IOException, InterruptedException {
299+
throws IOException {
300300
if (System.currentTimeMillis() - statustime > MAX_JOBSTATUS_AGE) {
301301
updateStatus();
302302
}
@@ -306,13 +306,18 @@ synchronized void ensureFreshStatus()
306306
* immediately
307307
* @throws IOException
308308
*/
309-
synchronized void updateStatus() throws IOException, InterruptedException {
310-
this.status = ugi.doAs(new PrivilegedExceptionAction<JobStatus>() {
311-
@Override
312-
public JobStatus run() throws IOException, InterruptedException {
313-
return cluster.getClient().getJobStatus(status.getJobID());
314-
}
315-
});
309+
synchronized void updateStatus() throws IOException {
310+
try {
311+
this.status = ugi.doAs(new PrivilegedExceptionAction<JobStatus>() {
312+
@Override
313+
public JobStatus run() throws IOException, InterruptedException {
314+
return cluster.getClient().getJobStatus(status.getJobID());
315+
}
316+
});
317+
}
318+
catch (InterruptedException ie) {
319+
throw new IOException(ie);
320+
}
316321
if (this.status == null) {
317322
throw new IOException("Job status not available ");
318323
}
@@ -537,7 +542,7 @@ public TaskReport[] run() throws IOException, InterruptedException {
537542
* @return the progress of the job's map-tasks.
538543
* @throws IOException
539544
*/
540-
public float mapProgress() throws IOException, InterruptedException {
545+
public float mapProgress() throws IOException {
541546
ensureState(JobState.RUNNING);
542547
ensureFreshStatus();
543548
return status.getMapProgress();
@@ -550,7 +555,7 @@ public float mapProgress() throws IOException, InterruptedException {
550555
* @return the progress of the job's reduce-tasks.
551556
* @throws IOException
552557
*/
553-
public float reduceProgress() throws IOException, InterruptedException {
558+
public float reduceProgress() throws IOException {
554559
ensureState(JobState.RUNNING);
555560
ensureFreshStatus();
556561
return status.getReduceProgress();
@@ -576,7 +581,7 @@ public float cleanupProgress() throws IOException, InterruptedException {
576581
* @return the progress of the job's setup-tasks.
577582
* @throws IOException
578583
*/
579-
public float setupProgress() throws IOException, InterruptedException {
584+
public float setupProgress() throws IOException {
580585
ensureState(JobState.RUNNING);
581586
ensureFreshStatus();
582587
return status.getSetupProgress();
@@ -589,7 +594,7 @@ public float setupProgress() throws IOException, InterruptedException {
589594
* @return <code>true</code> if the job is complete, else <code>false</code>.
590595
* @throws IOException
591596
*/
592-
public boolean isComplete() throws IOException, InterruptedException {
597+
public boolean isComplete() throws IOException {
593598
ensureState(JobState.RUNNING);
594599
updateStatus();
595600
return status.isJobComplete();
@@ -601,7 +606,7 @@ public boolean isComplete() throws IOException, InterruptedException {
601606
* @return <code>true</code> if the job succeeded, else <code>false</code>.
602607
* @throws IOException
603608
*/
604-
public boolean isSuccessful() throws IOException, InterruptedException {
609+
public boolean isSuccessful() throws IOException {
605610
ensureState(JobState.RUNNING);
606611
updateStatus();
607612
return status.getState() == JobStatus.State.SUCCEEDED;
@@ -613,9 +618,14 @@ public boolean isSuccessful() throws IOException, InterruptedException {
613618
*
614619
* @throws IOException
615620
*/
616-
public void killJob() throws IOException, InterruptedException {
621+
public void killJob() throws IOException {
617622
ensureState(JobState.RUNNING);
618-
cluster.getClient().killJob(getJobID());
623+
try {
624+
cluster.getClient().killJob(getJobID());
625+
}
626+
catch (InterruptedException ie) {
627+
throw new IOException(ie);
628+
}
619629
}
620630

621631
/**
@@ -673,7 +683,7 @@ public TaskCompletionEvent[] getTaskCompletionEvents(final int startFrom)
673683
try {
674684
return getTaskCompletionEvents(startFrom, 10);
675685
} catch (InterruptedException ie) {
676-
throw new RuntimeException(ie);
686+
throw new IOException(ie);
677687
}
678688
}
679689

@@ -684,13 +694,18 @@ public TaskCompletionEvent[] getTaskCompletionEvents(final int startFrom)
684694
* @throws IOException
685695
*/
686696
public boolean killTask(final TaskAttemptID taskId)
687-
throws IOException, InterruptedException {
697+
throws IOException {
688698
ensureState(JobState.RUNNING);
689-
return ugi.doAs(new PrivilegedExceptionAction<Boolean>() {
690-
public Boolean run() throws IOException, InterruptedException {
691-
return cluster.getClient().killTask(taskId, false);
692-
}
693-
});
699+
try {
700+
return ugi.doAs(new PrivilegedExceptionAction<Boolean>() {
701+
public Boolean run() throws IOException, InterruptedException {
702+
return cluster.getClient().killTask(taskId, false);
703+
}
704+
});
705+
}
706+
catch (InterruptedException ie) {
707+
throw new IOException(ie);
708+
}
694709
}
695710

696711
/**
@@ -700,14 +715,19 @@ public Boolean run() throws IOException, InterruptedException {
700715
* @throws IOException
701716
*/
702717
public boolean failTask(final TaskAttemptID taskId)
703-
throws IOException, InterruptedException {
718+
throws IOException {
704719
ensureState(JobState.RUNNING);
705-
return ugi.doAs(new PrivilegedExceptionAction<Boolean>() {
706-
@Override
707-
public Boolean run() throws IOException, InterruptedException {
708-
return cluster.getClient().killTask(taskId, true);
709-
}
710-
});
720+
try {
721+
return ugi.doAs(new PrivilegedExceptionAction<Boolean>() {
722+
@Override
723+
public Boolean run() throws IOException, InterruptedException {
724+
return cluster.getClient().killTask(taskId, true);
725+
}
726+
});
727+
}
728+
catch (InterruptedException ie) {
729+
throw new IOException(ie);
730+
}
711731
}
712732

713733
/**
@@ -718,14 +738,19 @@ public Boolean run() throws IOException, InterruptedException {
718738
* @throws IOException
719739
*/
720740
public Counters getCounters()
721-
throws IOException, InterruptedException {
741+
throws IOException {
722742
ensureState(JobState.RUNNING);
723-
return ugi.doAs(new PrivilegedExceptionAction<Counters>() {
724-
@Override
725-
public Counters run() throws IOException, InterruptedException {
726-
return cluster.getClient().getJobCounters(getJobID());
727-
}
728-
});
743+
try {
744+
return ugi.doAs(new PrivilegedExceptionAction<Counters>() {
745+
@Override
746+
public Counters run() throws IOException, InterruptedException {
747+
return cluster.getClient().getJobCounters(getJobID());
748+
}
749+
});
750+
}
751+
catch (InterruptedException ie) {
752+
throw new IOException(ie);
753+
}
729754
}
730755

731756
/**

hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestGridmixSummary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public int getNumReduceTasks() {
346346
};
347347

348348
@Override
349-
public boolean isSuccessful() throws IOException, InterruptedException {
349+
public boolean isSuccessful() throws IOException {
350350
if (lost) {
351351
throw new IOException("Test failure!");
352352
}

0 commit comments

Comments
 (0)