Skip to content

Commit 4781761

Browse files
authored
HADOOP-17594. DistCp: Expose the JobId for applications executing through run method (#2786). Contributed by Ayush Saxena.
Signed-off-by: Mingliang Liu <[email protected]> Signed-off-by: Steve Loughran <[email protected]>
1 parent f5f3fc6 commit 4781761

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ public Job createAndSubmitJob() throws Exception {
225225
String jobID = job.getJobID().toString();
226226
job.getConfiguration().set(DistCpConstants.CONF_LABEL_DISTCP_JOB_ID,
227227
jobID);
228+
// Set the jobId for the applications running through run method.
229+
getConf().set(DistCpConstants.CONF_LABEL_DISTCP_JOB_ID, jobID);
228230
LOG.info("DistCp job-id: " + jobID);
229231

230232
return job;

hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/contract/AbstractContractDistCpTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.hadoop.tools.contract;
2020

2121
import static org.apache.hadoop.fs.contract.ContractTestUtils.*;
22+
import static org.apache.hadoop.tools.DistCpConstants.CONF_LABEL_DISTCP_JOB_ID;
2223

2324
import java.io.IOException;
2425
import java.util.Collections;
@@ -42,6 +43,7 @@
4243
import org.apache.hadoop.tools.DistCpConstants;
4344
import org.apache.hadoop.tools.DistCpOptions;
4445
import org.apache.hadoop.tools.mapred.CopyMapper;
46+
import org.apache.hadoop.tools.util.DistCpTestUtils;
4547

4648
import org.junit.Before;
4749
import org.junit.Rule;
@@ -464,6 +466,17 @@ public void testLargeFilesFromRemote() throws Exception {
464466
largeFiles(remoteFS, remoteDir, localFS, localDir);
465467
}
466468

469+
@Test
470+
public void testSetJobId() throws Exception {
471+
describe("check jobId is set in the conf");
472+
remoteFS.create(new Path(remoteDir, "file1")).close();
473+
DistCpTestUtils
474+
.assertRunDistCp(DistCpConstants.SUCCESS, remoteDir.toString(),
475+
localDir.toString(), null, conf);
476+
assertNotNull("DistCp job id isn't set",
477+
conf.get(CONF_LABEL_DISTCP_JOB_ID));
478+
}
479+
467480
/**
468481
* Executes a DistCp using a file system sub-tree with multiple nesting
469482
* levels.

0 commit comments

Comments
 (0)