Search in sources :

Example 6 with PermissionStatus

use of org.apache.hadoop.fs.permission.PermissionStatus in project hadoop by apache.

the class TestEncryptionZoneManager method setup.

@Before
public void setup() {
    this.mockedDir = mock(FSDirectory.class);
    this.mockedINodesInPath = mock(INodesInPath.class);
    this.defaultPermission = new PermissionStatus("test", "test", new FsPermission((short) 755));
    this.rootINode = new INodeDirectory(0L, "".getBytes(), defaultPermission, System.currentTimeMillis());
    this.firstINode = new INodeDirectory(1L, "first".getBytes(), defaultPermission, System.currentTimeMillis());
    this.secondINode = new INodeDirectory(2L, "second".getBytes(), defaultPermission, System.currentTimeMillis());
    when(this.mockedDir.hasReadLock()).thenReturn(true);
    when(this.mockedDir.hasWriteLock()).thenReturn(true);
    when(this.mockedDir.getInode(0L)).thenReturn(rootINode);
    when(this.mockedDir.getInode(1L)).thenReturn(firstINode);
    when(this.mockedDir.getInode(2L)).thenReturn(secondINode);
}
Also used : FsPermission(org.apache.hadoop.fs.permission.FsPermission) PermissionStatus(org.apache.hadoop.fs.permission.PermissionStatus) Before(org.junit.Before)

Example 7 with PermissionStatus

use of org.apache.hadoop.fs.permission.PermissionStatus in project hadoop by apache.

the class TestFSPermissionChecker method createINodeDirectory.

private static INodeDirectory createINodeDirectory(INodeDirectory parent, String name, String owner, String group, short perm) throws IOException {
    PermissionStatus permStatus = PermissionStatus.createImmutable(owner, group, FsPermission.createImmutable(perm));
    INodeDirectory inodeDirectory = new INodeDirectory(HdfsConstants.GRANDFATHER_INODE_ID, name.getBytes("UTF-8"), permStatus, 0L);
    parent.addChild(inodeDirectory);
    return inodeDirectory;
}
Also used : PermissionStatus(org.apache.hadoop.fs.permission.PermissionStatus)

Example 8 with PermissionStatus

use of org.apache.hadoop.fs.permission.PermissionStatus in project hadoop by apache.

the class FSImageLoader method getAclStatus.

/**
   * Return the JSON formatted ACL status of the specified file.
   * @param path a path specifies a file
   * @return JSON formatted AclStatus
   * @throws IOException if failed to serialize fileStatus to JSON.
   */
String getAclStatus(String path) throws IOException {
    PermissionStatus p = getPermissionStatus(path);
    List<AclEntry> aclEntryList = getAclEntryList(path);
    FsPermission permission = p.getPermission();
    AclStatus.Builder builder = new AclStatus.Builder();
    builder.owner(p.getUserName()).group(p.getGroupName()).addEntries(aclEntryList).setPermission(permission).stickyBit(permission.getStickyBit());
    AclStatus aclStatus = builder.build();
    return JsonUtil.toJsonString(aclStatus);
}
Also used : AclStatus(org.apache.hadoop.fs.permission.AclStatus) AclEntry(org.apache.hadoop.fs.permission.AclEntry) FsPermission(org.apache.hadoop.fs.permission.FsPermission) PermissionStatus(org.apache.hadoop.fs.permission.PermissionStatus)

Example 9 with PermissionStatus

use of org.apache.hadoop.fs.permission.PermissionStatus in project hadoop by apache.

the class TestTruncateQuotaUpdate method createMockFile.

private INodeFile createMockFile(long size, short replication) {
    ArrayList<BlockInfo> blocks = new ArrayList<>();
    long createdSize = 0;
    while (createdSize < size) {
        long blockSize = Math.min(BLOCKSIZE, size - createdSize);
        BlockInfo bi = newBlock(blockSize, replication);
        blocks.add(bi);
        createdSize += BLOCKSIZE;
    }
    PermissionStatus perm = new PermissionStatus("foo", "bar", FsPermission.createImmutable((short) 0x1ff));
    return new INodeFile(++nextMockINodeId, new byte[0], perm, 0, 0, blocks.toArray(new BlockInfo[blocks.size()]), replication, BLOCKSIZE);
}
Also used : BlockInfo(org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo) ArrayList(java.util.ArrayList) PermissionStatus(org.apache.hadoop.fs.permission.PermissionStatus)

Example 10 with PermissionStatus

use of org.apache.hadoop.fs.permission.PermissionStatus in project hadoop by apache.

the class TestUpgradeDomainBlockPlacementPolicy method setup.

@Before
public void setup() throws IOException {
    StaticMapping.resetMap();
    Configuration conf = new HdfsConfiguration();
    conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, DEFAULT_BLOCK_SIZE);
    conf.setInt(DFSConfigKeys.DFS_BYTES_PER_CHECKSUM_KEY, DEFAULT_BLOCK_SIZE / 2);
    conf.setClass(DFSConfigKeys.DFS_BLOCK_REPLICATOR_CLASSNAME_KEY, BlockPlacementPolicyWithUpgradeDomain.class, BlockPlacementPolicy.class);
    conf.setClass(DFSConfigKeys.DFS_NAMENODE_HOSTS_PROVIDER_CLASSNAME_KEY, CombinedHostFileManager.class, HostConfigManager.class);
    hostsFileWriter.initialize(conf, "temp/upgradedomainpolicy");
    cluster = new MiniDFSCluster.Builder(conf).numDataNodes(6).racks(racks).hosts(hosts).build();
    cluster.waitActive();
    nameNodeRpc = cluster.getNameNodeRpc();
    namesystem = cluster.getNamesystem();
    perm = new PermissionStatus("TestDefaultBlockPlacementPolicy", null, FsPermission.getDefault());
    refreshDatanodeAdminProperties();
}
Also used : MiniDFSCluster(org.apache.hadoop.hdfs.MiniDFSCluster) Configuration(org.apache.hadoop.conf.Configuration) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) PermissionStatus(org.apache.hadoop.fs.permission.PermissionStatus) Before(org.junit.Before)

Aggregations

PermissionStatus (org.apache.hadoop.fs.permission.PermissionStatus)33 FsPermission (org.apache.hadoop.fs.permission.FsPermission)11 Configuration (org.apache.hadoop.conf.Configuration)9 IOException (java.io.IOException)7 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)6 Test (org.junit.Test)6 Path (org.apache.hadoop.fs.Path)5 Before (org.junit.Before)5 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)4 Block (org.apache.hadoop.hdfs.protocol.Block)3 BlockInfoContiguous (org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoContiguous)3 StorageException (com.microsoft.azure.storage.StorageException)2 DataOutputStream (java.io.DataOutputStream)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)2 FileAlreadyExistsException (org.apache.hadoop.fs.FileAlreadyExistsException)2 BlockInfo (org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)2