Search in sources :

Example 6 with AbstractFileSystem

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

the class ViewFsBaseTest method testListStatusIterator.

// Confirm that listStatus is delegated properly to the underlying
// AbstractFileSystem's listStatusIterator to allow for optimizations
@Test
public void testListStatusIterator() throws IOException {
    final Path mockTarget = new Path("mockfs://listStatusIterator/foo");
    final Path mountPoint = new Path("/fooMount");
    final Configuration newConf = new Configuration();
    newConf.setClass("fs.AbstractFileSystem.mockfs.impl", MockFs.class, AbstractFileSystem.class);
    ConfigUtil.addLink(newConf, mountPoint.toString(), mockTarget.toUri());
    FileContext.getFileContext(URI.create("viewfs:///"), newConf).listStatus(mountPoint);
    AbstractFileSystem mockFs = MockFs.getMockFs(mockTarget.toUri());
    verify(mockFs).listStatusIterator(new Path(mockTarget.toUri().getPath()));
    verify(mockFs, never()).listStatus(any(Path.class));
}
Also used : Path(org.apache.hadoop.fs.Path) AbstractFileSystem(org.apache.hadoop.fs.AbstractFileSystem) Configuration(org.apache.hadoop.conf.Configuration) Test(org.junit.Test)

Example 7 with AbstractFileSystem

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

the class ViewFsBaseTest method testListLocatedStatus.

// Confirm that listLocatedStatus is delegated properly to the underlying
// AbstractFileSystem to allow for optimizations
@Test
public void testListLocatedStatus() throws IOException {
    final Path mockTarget = new Path("mockfs://listLocatedStatus/foo");
    final Path mountPoint = new Path("/fooMount");
    final Configuration newConf = new Configuration();
    newConf.setClass("fs.AbstractFileSystem.mockfs.impl", MockFs.class, AbstractFileSystem.class);
    ConfigUtil.addLink(newConf, mountPoint.toString(), mockTarget.toUri());
    FileContext.getFileContext(URI.create("viewfs:///"), newConf).listLocatedStatus(mountPoint);
    AbstractFileSystem mockFs = MockFs.getMockFs(mockTarget.toUri());
    verify(mockFs).listLocatedStatus(new Path(mockTarget.toUri().getPath()));
    verify(mockFs, never()).listStatus(any(Path.class));
    verify(mockFs, never()).listStatusIterator(any(Path.class));
}
Also used : Path(org.apache.hadoop.fs.Path) AbstractFileSystem(org.apache.hadoop.fs.AbstractFileSystem) Configuration(org.apache.hadoop.conf.Configuration) Test(org.junit.Test)

Example 8 with AbstractFileSystem

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

the class TestChRootedFs method testIsValidNameInvalidInBaseFs.

@Test
public void testIsValidNameInvalidInBaseFs() throws Exception {
    AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
    ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot"));
    Mockito.doReturn(false).when(baseFs).isValidName(Mockito.anyString());
    Assert.assertFalse(chRootedFs.isValidName("/test"));
    Mockito.verify(baseFs).isValidName("/chroot/test");
}
Also used : AbstractFileSystem(org.apache.hadoop.fs.AbstractFileSystem) Path(org.apache.hadoop.fs.Path) ChRootedFs(org.apache.hadoop.fs.viewfs.ChRootedFs) Test(org.junit.Test)

Example 9 with AbstractFileSystem

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

the class TestChRootedFs method testRenameSnapshot.

@Test(timeout = 30000)
public void testRenameSnapshot() throws Exception {
    Path snapRootPath = new Path("/snapPath");
    Path chRootedSnapRootPath = new Path(Path.getPathWithoutSchemeAndAuthority(chrootedTo), "snapPath");
    AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
    ChRootedFs chRootedFs = new ChRootedFs(baseFs, chrootedTo);
    Mockito.doNothing().when(baseFs).renameSnapshot(chRootedSnapRootPath, "snapOldName", "snapNewName");
    chRootedFs.renameSnapshot(snapRootPath, "snapOldName", "snapNewName");
    Mockito.verify(baseFs).renameSnapshot(chRootedSnapRootPath, "snapOldName", "snapNewName");
}
Also used : Path(org.apache.hadoop.fs.Path) AbstractFileSystem(org.apache.hadoop.fs.AbstractFileSystem) ChRootedFs(org.apache.hadoop.fs.viewfs.ChRootedFs) Test(org.junit.Test)

Example 10 with AbstractFileSystem

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

the class TestDelegationTokensWithHA method testHdfsGetCanonicalServiceName.

@Test(timeout = 300000)
public void testHdfsGetCanonicalServiceName() throws Exception {
    Configuration conf = dfs.getConf();
    URI haUri = HATestUtil.getLogicalUri(cluster);
    AbstractFileSystem afs = AbstractFileSystem.createFileSystem(haUri, conf);
    String haService = HAUtilClient.buildTokenServiceForLogicalUri(haUri, HdfsConstants.HDFS_URI_SCHEME).toString();
    assertEquals(haService, afs.getCanonicalServiceName());
    Token<?> token = afs.getDelegationTokens(UserGroupInformation.getCurrentUser().getShortUserName()).get(0);
    assertEquals(haService, token.getService().toString());
    // make sure the logical uri is handled correctly
    token.renew(conf);
    token.cancel(conf);
}
Also used : AbstractFileSystem(org.apache.hadoop.fs.AbstractFileSystem) Configuration(org.apache.hadoop.conf.Configuration) URI(java.net.URI) Test(org.junit.Test)

Aggregations

AbstractFileSystem (org.apache.hadoop.fs.AbstractFileSystem)20 Test (org.junit.Test)16 Path (org.apache.hadoop.fs.Path)13 Configuration (org.apache.hadoop.conf.Configuration)9 ChRootedFs (org.apache.hadoop.fs.viewfs.ChRootedFs)5 URI (java.net.URI)4 FileContext (org.apache.hadoop.fs.FileContext)4 FileStatus (org.apache.hadoop.fs.FileStatus)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)3 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)3 FileSystem (org.apache.hadoop.fs.FileSystem)2 LocatedFileStatus (org.apache.hadoop.fs.LocatedFileStatus)2 LocalDirsHandlerService (org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService)2 LocalizationProtocol (org.apache.hadoop.yarn.server.nodemanager.api.LocalizationProtocol)2 NMNullStateStoreService (org.apache.hadoop.yarn.server.nodemanager.recovery.NMNullStateStoreService)2 Principal (java.security.Principal)1 Random (java.util.Random)1 Scanner (java.util.Scanner)1