Skip to content

Commit b33b28c

Browse files
committed
HADOOP-13600 moving parallel copy into its own class
Change-Id: Ibfe08fb289deaa3b2fa21a8281f58651edb6d2ab
1 parent 8dc7b5c commit b33b28c

File tree

2 files changed

+53
-11
lines changed

2 files changed

+53
-11
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.hadoop.fs.s3a;
20+
21+
/**
22+
* Execute copy operations in parallel; blocks until all operations
23+
* are completed.
24+
*/
25+
class ParallelCopier {
26+
}

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,6 @@ public boolean rename(Path src, Path dst) throws IOException {
663663
return innerRename(src, dst);
664664
} catch (AmazonClientException e) {
665665
throw translateException("rename(" + src +", " + dst + ")", src, e);
666-
} catch (FileNotFoundException e) {
667-
LOG.error("rename: src not found {}", src);
668-
return false;
669666
} catch (RenameFailedException e) {
670667
LOG.debug(e.getMessage());
671668
return e.getExitCode();
@@ -701,6 +698,8 @@ private boolean innerRename(Path src, Path dst) throws IOException,
701698
throw new RenameFailedException(src, dst, "dest is root directory");
702699
}
703700

701+
// get the source file status; this raises a FNFE if there is no source
702+
// file.
704703
S3AFileStatus srcStatus = getFileStatus(src);
705704

706705
if (srcKey.equals(dstKey)) {
@@ -714,15 +713,31 @@ private boolean innerRename(Path src, Path dst) throws IOException,
714713
S3AFileStatus dstStatus = null;
715714
try {
716715
dstStatus = getFileStatus(dst);
717-
718-
if (srcStatus.isDirectory() && dstStatus.isFile()) {
719-
throw new RenameFailedException(src, dst,
720-
"source is a directory and dest is a file")
721-
.withExitCode(srcStatus.isFile());
722-
}
723-
if (dstStatus.isDirectory() && !dstStatus.isEmptyDirectory()) {
724-
return false;
716+
// if there is no destination entry, an exception is raised.
717+
// hence this code sequence can assume that there is something
718+
// at the end of the path; the only detail being what it is and
719+
// whether or not it can be the destination of the rename.
720+
if (srcStatus.isDirectory()) {
721+
if (dstStatus.isFile()) {
722+
throw new RenameFailedException(src, dst,
723+
"source is a directory and dest is a file")
724+
.withExitCode(srcStatus.isFile());
725+
} else if (!dstStatus.isEmptyDirectory()) {
726+
throw new RenameFailedException(src, dst,
727+
"Destination is a non-empty directory")
728+
.withExitCode(false);
729+
}
730+
// at this point the destination is an empty directory
731+
} else {
732+
// source is a file. Look at the destination
733+
if (dstStatus.isFile()) {
734+
throw new RenameFailedException(src, dst,
735+
"destination file for rename operations already exists")
736+
.withExitCode(false);
737+
}
738+
//
725739
}
740+
726741
} catch (FileNotFoundException e) {
727742
LOG.debug("rename: destination path {} not found", dst);
728743
// Parent must exist
@@ -880,6 +895,7 @@ public CopyResult call() throws Exception {
880895
throw new IOException(ex);
881896
}
882897
} else {
898+
//no cause
883899
throw new IOException(e);
884900
}
885901
}

0 commit comments

Comments
 (0)