-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HADOOP-17139 Re-enable optimized copyFromLocal implementation in S3AF…
…ileSystem (#3101) This work * Defines the behavior of FileSystem.copyFromLocal in filesystem.md * Implements a high performance implementation of copyFromLocalOperation for S3 * Adds a contract test for the operation: AbstractContractCopyFromLocalTest * Implements the contract tests for Local and S3A FileSystems Contributed by: Bogdan Stolojan
- Loading branch information
Showing
7 changed files
with
1,171 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...on-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSCopyFromLocal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.hadoop.fs; | ||
|
||
import java.io.File; | ||
|
||
import org.junit.Test; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.contract.AbstractContractCopyFromLocalTest; | ||
import org.apache.hadoop.fs.contract.AbstractFSContract; | ||
import org.apache.hadoop.fs.contract.localfs.LocalFSContract; | ||
|
||
import static org.apache.hadoop.test.LambdaTestUtils.intercept; | ||
|
||
public class TestLocalFSCopyFromLocal extends AbstractContractCopyFromLocalTest { | ||
@Override | ||
protected AbstractFSContract createContract(Configuration conf) { | ||
return new LocalFSContract(conf); | ||
} | ||
|
||
@Test | ||
public void testDestinationFileIsToParentDirectory() throws Throwable { | ||
describe("Source is a file and destination is its own parent directory"); | ||
|
||
File file = createTempFile("local"); | ||
Path dest = new Path(file.getParentFile().toURI()); | ||
Path src = new Path(file.toURI()); | ||
|
||
intercept(PathOperationException.class, | ||
() -> getFileSystem().copyFromLocalFile( true, true, src, dest)); | ||
} | ||
|
||
@Test | ||
public void testDestinationDirectoryToSelf() throws Throwable { | ||
describe("Source is a directory and it is copied into itself with " + | ||
"delSrc flag set, destination must not exist"); | ||
|
||
File source = createTempDirectory("srcDir"); | ||
Path dest = new Path(source.toURI()); | ||
getFileSystem().copyFromLocalFile( true, true, dest, dest); | ||
|
||
assertPathDoesNotExist("Source found", dest); | ||
} | ||
|
||
@Test | ||
public void testSourceIntoDestinationSubDirectoryWithDelSrc() throws Throwable { | ||
describe("Copying a parent folder inside a child folder with" + | ||
" delSrc=TRUE"); | ||
File parent = createTempDirectory("parent"); | ||
File child = createTempDirectory(parent, "child"); | ||
|
||
Path src = new Path(parent.toURI()); | ||
Path dest = new Path(child.toURI()); | ||
getFileSystem().copyFromLocalFile(true, true, src, dest); | ||
|
||
assertPathDoesNotExist("Source found", src); | ||
assertPathDoesNotExist("Destination found", dest); | ||
} | ||
|
||
@Test | ||
public void testSourceIntoDestinationSubDirectory() throws Throwable { | ||
describe("Copying a parent folder inside a child folder with" + | ||
" delSrc=FALSE"); | ||
File parent = createTempDirectory("parent"); | ||
File child = createTempDirectory(parent, "child"); | ||
|
||
Path src = new Path(parent.toURI()); | ||
Path dest = new Path(child.toURI()); | ||
getFileSystem().copyFromLocalFile(false, true, src, dest); | ||
|
||
Path recursiveParent = new Path(dest, parent.getName()); | ||
Path recursiveChild = new Path(recursiveParent, child.getName()); | ||
|
||
// This definitely counts as interesting behaviour which needs documented | ||
// Depending on the underlying system this can recurse 15+ times | ||
recursiveParent = new Path(recursiveChild, parent.getName()); | ||
recursiveChild = new Path(recursiveParent, child.getName()); | ||
assertPathExists("Recursive parent not found", recursiveParent); | ||
assertPathExists("Recursive child not found", recursiveChild); | ||
} | ||
} |
Oops, something went wrong.