Search in sources :

Example 1 with HadoopFileStatus

use of org.apache.hadoop.hive.io.HdfsUtils.HadoopFileStatus in project hive by apache.

the class TestHadoopFileStatus method testHadoopFileStatusAclEntries.

/*
   * HdfsUtils.setFullFileStatus(..) is called from multiple parallel threads. If AclEntries
   * is modifiable the method will not be thread safe and could cause random concurrency issues
   * This test case checks if the aclEntries returned from HadoopFileStatus is thread-safe or not
   */
@Test(expected = UnsupportedOperationException.class)
public void testHadoopFileStatusAclEntries() throws IOException {
    FileSystem mockDfs = Mockito.mock(DistributedFileSystem.class);
    Path mockPath = Mockito.mock(Path.class);
    List<AclEntry> aclEntries = Lists.newArrayList();
    aclEntries.add(newAclEntry(AclEntryScope.ACCESS, AclEntryType.USER, FsAction.ALL));
    aclEntries.add(newAclEntry(AclEntryScope.ACCESS, AclEntryType.GROUP, FsAction.READ_EXECUTE));
    aclEntries.add(newAclEntry(AclEntryScope.ACCESS, AclEntryType.OTHER, FsAction.NONE));
    AclStatus aclStatus = new AclStatus.Builder().owner("dummyOwner").group("dummyGroup").stickyBit(true).addEntries(aclEntries).build();
    FileStatus mockFileStatus = Mockito.mock(FileStatus.class);
    Mockito.when(mockDfs.getAclStatus(mockPath)).thenReturn(aclStatus);
    Mockito.when(mockDfs.getFileStatus(mockPath)).thenReturn(mockFileStatus);
    sourceStatus = new HadoopFileStatus(hiveConf, mockDfs, mockPath);
    Assert.assertNotNull(sourceStatus.getAclEntries());
    Assert.assertTrue(sourceStatus.getAclEntries().size() == 3);
    Iterables.removeIf(sourceStatus.getAclEntries(), new Predicate<AclEntry>() {

        @Override
        public boolean apply(AclEntry input) {
            if (input.getName() == null) {
                return true;
            }
            return false;
        }
    });
}
Also used : Path(org.apache.hadoop.fs.Path) HadoopFileStatus(org.apache.hadoop.hive.io.HdfsUtils.HadoopFileStatus) FileStatus(org.apache.hadoop.fs.FileStatus) AclStatus(org.apache.hadoop.fs.permission.AclStatus) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) FileSystem(org.apache.hadoop.fs.FileSystem) AclEntry(org.apache.hadoop.fs.permission.AclEntry) HadoopFileStatus(org.apache.hadoop.hive.io.HdfsUtils.HadoopFileStatus) Test(org.junit.Test)

Aggregations

FileStatus (org.apache.hadoop.fs.FileStatus)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 AclEntry (org.apache.hadoop.fs.permission.AclEntry)1 AclStatus (org.apache.hadoop.fs.permission.AclStatus)1 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)1 HadoopFileStatus (org.apache.hadoop.hive.io.HdfsUtils.HadoopFileStatus)1 Test (org.junit.Test)1