-
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.
HDFS-17089. Close child files systems in ViewFileSystem when cache is…
… disabled.
- Loading branch information
1 parent
c44823d
commit 60ca8c3
Showing
3 changed files
with
81 additions
and
0 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
47 changes: 47 additions & 0 deletions
47
...roject/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemClose.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,47 @@ | ||
package org.apache.hadoop.fs.viewfs; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.FsConstants; | ||
import org.apache.hadoop.fs.Path; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
public class TestViewFileSystemClose { | ||
|
||
/** | ||
* Verify that all child file systems of a ViewFileSystem will be shut down | ||
* when the cache is disabled. | ||
* @throws IOException | ||
*/ | ||
@Test | ||
public void testFileSystemLeak() throws IOException { | ||
|
||
Configuration conf = new Configuration(); | ||
conf.set("fs.viewfs.impl", ViewFileSystem.class.getName()); | ||
conf.setBoolean("fs.viewfs.enable.inner.cache", false); | ||
conf.setBoolean("fs.viewfs.impl.disable.cache", true); | ||
conf.setBoolean("fs.hdfs.impl.disable.cache", true); | ||
|
||
String rootPath = "hdfs://localhost/tmp"; | ||
ConfigUtil.addLink(conf, "/data", new Path(rootPath, "data").toUri()); | ||
ViewFileSystem viewFs = | ||
(ViewFileSystem) FileSystem.get(FsConstants.VIEWFS_URI, conf); | ||
|
||
FileSystem[] children = viewFs.getChildFileSystems(); | ||
viewFs.close(); | ||
FileSystem.closeAll(); | ||
for (FileSystem fs : children) { | ||
try { | ||
fs.create(new Path(rootPath, "neverSuccess")); | ||
fail(); | ||
} catch (IOException ioe) { | ||
assertTrue(ioe.getMessage().contains("Filesystem closed")); | ||
} | ||
} | ||
} | ||
} |