Skip to content

Commit 81faae6

Browse files
authored
Revert "HDFS-17611. Move all DistCp execution logic to execute() (#7025)" (#7059)
This reverts commit ff75aa5.
1 parent ff75aa5 commit 81faae6

2 files changed

Lines changed: 8 additions & 25 deletions

File tree

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

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ public int run(String[] argv) {
140140

141141
try {
142142
context = new DistCpContext(OptionsParser.parse(argv));
143-
LOG.info("Input Options: {}", context);
143+
checkSplitLargeFile();
144+
setTargetPathExists();
145+
LOG.info("Input Options: " + context);
144146
} catch (Throwable e) {
145147
LOG.error("Invalid arguments: ", e);
146148
System.err.println("Invalid arguments: " + e.getMessage());
@@ -150,7 +152,7 @@ public int run(String[] argv) {
150152

151153
Job job = null;
152154
try {
153-
job = execute(true);
155+
job = execute();
154156
} catch (InvalidInputException e) {
155157
LOG.error("Invalid input: ", e);
156158
return DistCpConstants.INVALID_ARGUMENT;
@@ -167,7 +169,7 @@ public int run(String[] argv) {
167169
LOG.error("Exception encountered ", e);
168170
return DistCpConstants.UNKNOWN_ERROR;
169171
} finally {
170-
// Blocking distcp so close the job after it's done
172+
//Blocking distcp so close the job after its done
171173
if (job != null && context.shouldBlock()) {
172174
try {
173175
job.close();
@@ -179,31 +181,15 @@ public int run(String[] argv) {
179181
return DistCpConstants.SUCCESS;
180182
}
181183

182-
/**
183-
* Original entrypoint of a distcp job. Calls {@link DistCp#execute(boolean)}
184-
* without doing extra context checks and setting some configs.
185-
* @return Job handle
186-
* @throws Exception when fails to submit distcp job or distcp job fails
187-
*/
188-
public Job execute() throws Exception {
189-
return execute(false);
190-
}
191-
192184
/**
193185
* Implements the core-execution. Creates the file-list for copy,
194186
* and launches the Hadoop-job, to do the copy.
195-
* @param extraContextChecks if true, does extra context checks and sets some configs.
196187
* @return Job handle
197-
* @throws Exception when fails to submit distcp job or distcp job fails, or context checks fail
188+
* @throws Exception
198189
*/
199-
public Job execute(boolean extraContextChecks) throws Exception {
190+
public Job execute() throws Exception {
200191
Preconditions.checkState(context != null,
201192
"The DistCpContext should have been created before running DistCp!");
202-
if (extraContextChecks) {
203-
checkSplitLargeFile();
204-
setTargetPathExists();
205-
}
206-
207193
Job job = createAndSubmitJob();
208194

209195
if (context.shouldBlock()) {

hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestExternalCall.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ public void testCleanupOfJob() throws Exception {
156156
DistCp distcp = mock(DistCp.class);
157157
Job job = spy(Job.class);
158158
Mockito.when(distcp.getConf()).thenReturn(conf);
159-
Mockito.when(distcp.createAndSubmitJob()).thenReturn(job);
160-
Mockito.when(distcp.execute()).thenCallRealMethod();
161-
Mockito.when(distcp.execute(Mockito.anyBoolean())).thenCallRealMethod();
162-
Mockito.doReturn(true).when(job).waitForCompletion(Mockito.anyBoolean());
159+
Mockito.when(distcp.execute()).thenReturn(job);
163160
Mockito.when(distcp.run(Mockito.any())).thenCallRealMethod();
164161
String[] arg = { soure.toString(), target.toString() };
165162

0 commit comments

Comments
 (0)