Search in sources :

Example 1 with FilterFileSystem

use of org.apache.hadoop.fs.FilterFileSystem in project hadoop by apache.

the class TestChRootedFileSystem method testDeleteOnExitPathHandling.

@Test
public void testDeleteOnExitPathHandling() throws IOException {
    Configuration conf = new Configuration();
    conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
    URI chrootUri = URI.create("mockfs://foo/a/b");
    ChRootedFileSystem chrootFs = new ChRootedFileSystem(chrootUri, conf);
    FileSystem mockFs = ((FilterFileSystem) chrootFs.getRawFileSystem()).getRawFileSystem();
    // ensure delete propagates the correct path
    Path chrootPath = new Path("/c");
    Path rawPath = new Path("/a/b/c");
    chrootFs.delete(chrootPath, false);
    verify(mockFs).delete(eq(rawPath), eq(false));
    reset(mockFs);
    // fake that the path exists for deleteOnExit
    FileStatus stat = mock(FileStatus.class);
    when(mockFs.getFileStatus(eq(rawPath))).thenReturn(stat);
    // ensure deleteOnExit propagates the correct path
    chrootFs.deleteOnExit(chrootPath);
    chrootFs.close();
    verify(mockFs).delete(eq(rawPath), eq(true));
}
Also used : Path(org.apache.hadoop.fs.Path) FileStatus(org.apache.hadoop.fs.FileStatus) Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.apache.hadoop.fs.FileSystem) ChRootedFileSystem(org.apache.hadoop.fs.viewfs.ChRootedFileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) URI(java.net.URI) ChRootedFileSystem(org.apache.hadoop.fs.viewfs.ChRootedFileSystem) Test(org.junit.Test)

Example 2 with FilterFileSystem

use of org.apache.hadoop.fs.FilterFileSystem in project hadoop by apache.

the class TestChRootedFileSystem method testGetAllStoragePolicy.

@Test(timeout = 30000)
public void testGetAllStoragePolicy() throws Exception {
    Configuration conf = new Configuration();
    conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
    URI chrootUri = URI.create("mockfs://foo/a/b");
    ChRootedFileSystem chrootFs = new ChRootedFileSystem(chrootUri, conf);
    FileSystem mockFs = ((FilterFileSystem) chrootFs.getRawFileSystem()).getRawFileSystem();
    chrootFs.getAllStoragePolicies();
    verify(mockFs).getAllStoragePolicies();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.apache.hadoop.fs.FileSystem) ChRootedFileSystem(org.apache.hadoop.fs.viewfs.ChRootedFileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) URI(java.net.URI) ChRootedFileSystem(org.apache.hadoop.fs.viewfs.ChRootedFileSystem) Test(org.junit.Test)

Example 3 with FilterFileSystem

use of org.apache.hadoop.fs.FilterFileSystem in project hadoop by apache.

the class TestChRootedFileSystem method testAclMethodsPathTranslation.

/**
   * Tests that ChRootedFileSystem delegates calls for every ACL method to the
   * underlying FileSystem with all Path arguments translated as required to
   * enforce chroot.
   */
@Test
public void testAclMethodsPathTranslation() throws IOException {
    Configuration conf = new Configuration();
    conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
    URI chrootUri = URI.create("mockfs://foo/a/b");
    ChRootedFileSystem chrootFs = new ChRootedFileSystem(chrootUri, conf);
    FileSystem mockFs = ((FilterFileSystem) chrootFs.getRawFileSystem()).getRawFileSystem();
    Path chrootPath = new Path("/c");
    Path rawPath = new Path("/a/b/c");
    List<AclEntry> entries = Collections.emptyList();
    chrootFs.modifyAclEntries(chrootPath, entries);
    verify(mockFs).modifyAclEntries(rawPath, entries);
    chrootFs.removeAclEntries(chrootPath, entries);
    verify(mockFs).removeAclEntries(rawPath, entries);
    chrootFs.removeDefaultAcl(chrootPath);
    verify(mockFs).removeDefaultAcl(rawPath);
    chrootFs.removeAcl(chrootPath);
    verify(mockFs).removeAcl(rawPath);
    chrootFs.setAcl(chrootPath, entries);
    verify(mockFs).setAcl(rawPath, entries);
    chrootFs.getAclStatus(chrootPath);
    verify(mockFs).getAclStatus(rawPath);
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.apache.hadoop.fs.FileSystem) ChRootedFileSystem(org.apache.hadoop.fs.viewfs.ChRootedFileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) AclEntry(org.apache.hadoop.fs.permission.AclEntry) URI(java.net.URI) ChRootedFileSystem(org.apache.hadoop.fs.viewfs.ChRootedFileSystem) Test(org.junit.Test)

Example 4 with FilterFileSystem

use of org.apache.hadoop.fs.FilterFileSystem in project hadoop by apache.

the class TestChRootedFileSystem method testSetStoragePolicy.

@Test(timeout = 30000)
public void testSetStoragePolicy() throws Exception {
    Path storagePolicyPath = new Path("/storagePolicy");
    Path chRootedStoragePolicyPath = new Path("/a/b/storagePolicy");
    Configuration conf = new Configuration();
    conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
    URI chrootUri = URI.create("mockfs://foo/a/b");
    ChRootedFileSystem chrootFs = new ChRootedFileSystem(chrootUri, conf);
    FileSystem mockFs = ((FilterFileSystem) chrootFs.getRawFileSystem()).getRawFileSystem();
    chrootFs.setStoragePolicy(storagePolicyPath, "HOT");
    verify(mockFs).setStoragePolicy(chRootedStoragePolicyPath, "HOT");
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.apache.hadoop.fs.FileSystem) ChRootedFileSystem(org.apache.hadoop.fs.viewfs.ChRootedFileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) URI(java.net.URI) ChRootedFileSystem(org.apache.hadoop.fs.viewfs.ChRootedFileSystem) Test(org.junit.Test)

Example 5 with FilterFileSystem

use of org.apache.hadoop.fs.FilterFileSystem in project hadoop by apache.

the class TestChRootedFileSystem method testGetStoragePolicy.

@Test(timeout = 30000)
public void testGetStoragePolicy() throws Exception {
    Path storagePolicyPath = new Path("/storagePolicy");
    Path chRootedStoragePolicyPath = new Path("/a/b/storagePolicy");
    Configuration conf = new Configuration();
    conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
    URI chrootUri = URI.create("mockfs://foo/a/b");
    ChRootedFileSystem chrootFs = new ChRootedFileSystem(chrootUri, conf);
    FileSystem mockFs = ((FilterFileSystem) chrootFs.getRawFileSystem()).getRawFileSystem();
    chrootFs.getStoragePolicy(storagePolicyPath);
    verify(mockFs).getStoragePolicy(chRootedStoragePolicyPath);
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.apache.hadoop.fs.FileSystem) ChRootedFileSystem(org.apache.hadoop.fs.viewfs.ChRootedFileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) URI(java.net.URI) ChRootedFileSystem(org.apache.hadoop.fs.viewfs.ChRootedFileSystem) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)15 FileSystem (org.apache.hadoop.fs.FileSystem)15 FilterFileSystem (org.apache.hadoop.fs.FilterFileSystem)15 Test (org.junit.Test)15 Path (org.apache.hadoop.fs.Path)14 URI (java.net.URI)12 ChRootedFileSystem (org.apache.hadoop.fs.viewfs.ChRootedFileSystem)9 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)6 FileStatus (org.apache.hadoop.fs.FileStatus)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 AccessControlException (org.apache.hadoop.security.AccessControlException)3 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)3 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)3 AclEntry (org.apache.hadoop.fs.permission.AclEntry)1