Java Code Examples for org.apache.hadoop.fs.permission.PermissionStatus#getUserName()

The following examples show how to use org.apache.hadoop.fs.permission.PermissionStatus#getUserName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FSDirSymlinkOp.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Add the given symbolic link to the fs. Record it in the edits log.
 */
private static INodeSymlink addSymlink(FSDirectory fsd, String path,
    INodesInPath iip, String target, PermissionStatus dirPerms,
    boolean createParent, boolean logRetryCache) throws IOException {
  final long mtime = now();
  final byte[] localName = iip.getLastLocalName();
  if (createParent) {
    Map.Entry<INodesInPath, String> e = FSDirMkdirOp
        .createAncestorDirectories(fsd, iip, dirPerms);
    if (e == null) {
      return null;
    }
    iip = INodesInPath.append(e.getKey(), null, localName);
  }
  final String userName = dirPerms.getUserName();
  long id = fsd.allocateNewInodeId();
  PermissionStatus perm = new PermissionStatus(
      userName, null, FsPermission.getDefault());
  INodeSymlink newNode = unprotectedAddSymlink(fsd, iip.getExistingINodes(),
      localName, id, target, mtime, mtime, perm);
  if (newNode == null) {
    NameNode.stateChangeLog.info("addSymlink: failed to add " + path);
    return null;
  }
  fsd.getEditLog().logSymlink(path, target, mtime, mtime, newNode,
      logRetryCache);

  if(NameNode.stateChangeLog.isDebugEnabled()) {
    NameNode.stateChangeLog.debug("addSymlink: " + path + " is added");
  }
  return newNode;
}
 
Example 2
Source File: FSDirMkdirOp.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static PermissionStatus addImplicitUwx(PermissionStatus parentPerm,
    PermissionStatus perm) {
  FsPermission p = parentPerm.getPermission();
  FsPermission ancestorPerm = new FsPermission(
      p.getUserAction().or(FsAction.WRITE_EXECUTE),
      p.getGroupAction(),
      p.getOtherAction());
  return new PermissionStatus(perm.getUserName(), perm.getGroupName(),
      ancestorPerm);
}
 
Example 3
Source File: FSDirSymlinkOp.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Add the given symbolic link to the fs. Record it in the edits log.
 */
private static INodeSymlink addSymlink(FSDirectory fsd, String path,
    INodesInPath iip, String target, PermissionStatus dirPerms,
    boolean createParent, boolean logRetryCache) throws IOException {
  final long mtime = now();
  final byte[] localName = iip.getLastLocalName();
  if (createParent) {
    Map.Entry<INodesInPath, String> e = FSDirMkdirOp
        .createAncestorDirectories(fsd, iip, dirPerms);
    if (e == null) {
      return null;
    }
    iip = INodesInPath.append(e.getKey(), null, localName);
  }
  final String userName = dirPerms.getUserName();
  long id = fsd.allocateNewInodeId();
  PermissionStatus perm = new PermissionStatus(
      userName, null, FsPermission.getDefault());
  INodeSymlink newNode = unprotectedAddSymlink(fsd, iip.getExistingINodes(),
      localName, id, target, mtime, mtime, perm);
  if (newNode == null) {
    NameNode.stateChangeLog.info("addSymlink: failed to add " + path);
    return null;
  }
  fsd.getEditLog().logSymlink(path, target, mtime, mtime, newNode,
      logRetryCache);

  if(NameNode.stateChangeLog.isDebugEnabled()) {
    NameNode.stateChangeLog.debug("addSymlink: " + path + " is added");
  }
  return newNode;
}
 
Example 4
Source File: FSDirMkdirOp.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static PermissionStatus addImplicitUwx(PermissionStatus parentPerm,
    PermissionStatus perm) {
  FsPermission p = parentPerm.getPermission();
  FsPermission ancestorPerm = new FsPermission(
      p.getUserAction().or(FsAction.WRITE_EXECUTE),
      p.getGroupAction(),
      p.getOtherAction());
  return new PermissionStatus(perm.getUserName(), perm.getGroupName(),
      ancestorPerm);
}