MAPREDUCE-6889. Add Job#close API to shutdown MR client services. Contributed by Rohith Sharma K S.
This commit is contained in:
parent
02b141ac60
commit
fb3b5d33ff
@ -75,7 +75,7 @@
|
||||
*/
|
||||
@InterfaceAudience.Public
|
||||
@InterfaceStability.Evolving
|
||||
public class Job extends JobContextImpl implements JobContext {
|
||||
public class Job extends JobContextImpl implements JobContext, AutoCloseable {
|
||||
private static final Log LOG = LogFactory.getLog(Job.class);
|
||||
|
||||
@InterfaceStability.Evolving
|
||||
@ -1553,4 +1553,15 @@ public void setReservationId(ReservationId reservationId) {
|
||||
this.reservationId = reservationId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the <code>Job</code>.
|
||||
* @throws IOException if fail to close.
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (cluster != null) {
|
||||
cluster.close();
|
||||
cluster = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -329,6 +329,10 @@ public void testJobSuccessCleanup() throws Exception {
|
||||
Assert.assertTrue(reduceCleanup);
|
||||
Assert.assertTrue(recordReaderCleanup);
|
||||
Assert.assertTrue(recordWriterCleanup);
|
||||
|
||||
Assert.assertNotNull(job.getCluster());
|
||||
job.close();
|
||||
Assert.assertNull(job.getCluster());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user