org.apache.hadoop.fs.permission.FsPermission#toShort ( )源码实例Demo

下面列出了org.apache.hadoop.fs.permission.FsPermission#toShort ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hadoop   文件: JobHistoryEventHandler.java
private void mkdir(FileSystem fs, Path path, FsPermission fsp)
    throws IOException {
  if (!fs.exists(path)) {
    try {
      fs.mkdirs(path, fsp);
      FileStatus fsStatus = fs.getFileStatus(path);
      LOG.info("Perms after creating " + fsStatus.getPermission().toShort()
          + ", Expected: " + fsp.toShort());
      if (fsStatus.getPermission().toShort() != fsp.toShort()) {
        LOG.info("Explicitly setting permissions to : " + fsp.toShort()
            + ", " + fsp);
        fs.setPermission(path, fsp);
      }
    } catch (FileAlreadyExistsException e) {
      LOG.info("Directory: [" + path + "] already exists.");
    }
  }
}
 
源代码2 项目: hadoop   文件: HistoryFileManager.java
private void mkdir(FileContext fc, Path path, FsPermission fsp)
    throws IOException {
  if (!fc.util().exists(path)) {
    try {
      fc.mkdir(path, fsp, true);

      FileStatus fsStatus = fc.getFileStatus(path);
      LOG.info("Perms after creating " + fsStatus.getPermission().toShort()
          + ", Expected: " + fsp.toShort());
      if (fsStatus.getPermission().toShort() != fsp.toShort()) {
        LOG.info("Explicitly setting permissions to : " + fsp.toShort()
            + ", " + fsp);
        fc.setPermission(path, fsp);
      }
    } catch (FileAlreadyExistsException e) {
      LOG.info("Directory: [" + path + "] already exists.");
    }
  }
}
 
源代码3 项目: hadoop   文件: HistoryFileManager.java
private void makeDoneSubdir(Path path) throws IOException {
  try {
    doneDirFc.getFileStatus(path);
    existingDoneSubdirs.add(path);
  } catch (FileNotFoundException fnfE) {
    try {
      FsPermission fsp = new FsPermission(
          JobHistoryUtils.HISTORY_DONE_DIR_PERMISSION);
      doneDirFc.mkdir(path, fsp, true);
      FileStatus fsStatus = doneDirFc.getFileStatus(path);
      LOG.info("Perms after creating " + fsStatus.getPermission().toShort()
          + ", Expected: " + fsp.toShort());
      if (fsStatus.getPermission().toShort() != fsp.toShort()) {
        LOG.info("Explicitly setting permissions to : " + fsp.toShort()
            + ", " + fsp);
        doneDirFc.setPermission(path, fsp);
      }
      existingDoneSubdirs.add(path);
    } catch (FileAlreadyExistsException faeE) { // Nothing to do.
    }
  }
}
 
源代码4 项目: hadoop   文件: TestDFSPermission.java
private void createAndCheckPermission(OpType op, Path name, short umask,
    FsPermission permission, boolean delete) throws Exception {
  // create the file/directory
  create(op, name, umask, permission);

  // get the short form of the permission
  short permissionNum = (DEFAULT_PERMISSION.equals(permission)) ? MAX_PERMISSION
      : permission.toShort();

  // get the expected permission
  short expectedPermission = (op == OpType.CREATE) ? (short) (~umask
      & permissionNum) : (short) (~umask & permissionNum);

  // check if permission is correctly set
  checkPermission(name, expectedPermission, delete);
}
 
源代码5 项目: big-c   文件: JobHistoryEventHandler.java
private void mkdir(FileSystem fs, Path path, FsPermission fsp)
    throws IOException {
  if (!fs.exists(path)) {
    try {
      fs.mkdirs(path, fsp);
      FileStatus fsStatus = fs.getFileStatus(path);
      LOG.info("Perms after creating " + fsStatus.getPermission().toShort()
          + ", Expected: " + fsp.toShort());
      if (fsStatus.getPermission().toShort() != fsp.toShort()) {
        LOG.info("Explicitly setting permissions to : " + fsp.toShort()
            + ", " + fsp);
        fs.setPermission(path, fsp);
      }
    } catch (FileAlreadyExistsException e) {
      LOG.info("Directory: [" + path + "] already exists.");
    }
  }
}
 
源代码6 项目: big-c   文件: HistoryFileManager.java
private void mkdir(FileContext fc, Path path, FsPermission fsp)
    throws IOException {
  if (!fc.util().exists(path)) {
    try {
      fc.mkdir(path, fsp, true);

      FileStatus fsStatus = fc.getFileStatus(path);
      LOG.info("Perms after creating " + fsStatus.getPermission().toShort()
          + ", Expected: " + fsp.toShort());
      if (fsStatus.getPermission().toShort() != fsp.toShort()) {
        LOG.info("Explicitly setting permissions to : " + fsp.toShort()
            + ", " + fsp);
        fc.setPermission(path, fsp);
      }
    } catch (FileAlreadyExistsException e) {
      LOG.info("Directory: [" + path + "] already exists.");
    }
  }
}
 
源代码7 项目: big-c   文件: HistoryFileManager.java
private void makeDoneSubdir(Path path) throws IOException {
  try {
    doneDirFc.getFileStatus(path);
    existingDoneSubdirs.add(path);
  } catch (FileNotFoundException fnfE) {
    try {
      FsPermission fsp = new FsPermission(
          JobHistoryUtils.HISTORY_DONE_DIR_PERMISSION);
      doneDirFc.mkdir(path, fsp, true);
      FileStatus fsStatus = doneDirFc.getFileStatus(path);
      LOG.info("Perms after creating " + fsStatus.getPermission().toShort()
          + ", Expected: " + fsp.toShort());
      if (fsStatus.getPermission().toShort() != fsp.toShort()) {
        LOG.info("Explicitly setting permissions to : " + fsp.toShort()
            + ", " + fsp);
        doneDirFc.setPermission(path, fsp);
      }
      existingDoneSubdirs.add(path);
    } catch (FileAlreadyExistsException faeE) { // Nothing to do.
    }
  }
}
 
源代码8 项目: big-c   文件: TestDFSPermission.java
private void createAndCheckPermission(OpType op, Path name, short umask,
    FsPermission permission, boolean delete) throws Exception {
  // create the file/directory
  create(op, name, umask, permission);

  // get the short form of the permission
  short permissionNum = (DEFAULT_PERMISSION.equals(permission)) ? MAX_PERMISSION
      : permission.toShort();

  // get the expected permission
  short expectedPermission = (op == OpType.CREATE) ? (short) (~umask
      & permissionNum) : (short) (~umask & permissionNum);

  // check if permission is correctly set
  checkPermission(name, expectedPermission, delete);
}
 
源代码9 项目: hadoop-gpu   文件: FsShellPermissions.java
@Override
public void run(FileStatus file, FileSystem srcFs) throws IOException {
  FsPermission perms = file.getPermission();
  int existing = perms.toShort();
  boolean exeOk = file.isDir() || (existing & 0111) != 0;
  int newperms = ( applyChmod(userType, userMode, 
                              (existing>>>6)&7, exeOk) << 6 |
                   applyChmod(groupType, groupMode, 
                              (existing>>>3)&7, exeOk) << 3 |
                   applyChmod(othersType, othersMode, existing&7, exeOk) );

  if (existing != newperms) {
    try {
      srcFs.setPermission(file.getPath(), 
                            new FsPermission((short)newperms));
    } catch (IOException e) {
      System.err.println(getName() + ": changing permissions of '" + 
                         file.getPath() + "':" + e.getMessage());
    }
  }
}
 
源代码10 项目: super-cloudops   文件: HdfsCossEndpoint.java
/**
 * {@link Acl} to {@link FsPermission}
 * 
 * @param acl
 * @return
 */
final public static FsPermission toFsPermission(ACL acl) {
	int posixPermission = toPosixPermission(acl);
	for (FsPermission fp : ACL_PERMISSSIONS) {
		if (posixPermission == fp.toShort())
			return fp;
	}
	throw new IllegalStateException(format("Unkown acl: %s", acl));
}
 
源代码11 项目: hadoop   文件: FsPermissionExtension.java
/**
 * Constructs a new FsPermissionExtension based on the given FsPermission.
 *
 * @param perm FsPermission containing permission bits
 */
public FsPermissionExtension(FsPermission perm, boolean hasAcl,
    boolean isEncrypted) {
  super(perm.toShort());
  aclBit = hasAcl;
  encryptedBit = isEncrypted;
}
 
源代码12 项目: big-c   文件: FsPermissionExtension.java
/**
 * Constructs a new FsPermissionExtension based on the given FsPermission.
 *
 * @param perm FsPermission containing permission bits
 */
public FsPermissionExtension(FsPermission perm, boolean hasAcl,
    boolean isEncrypted) {
  super(perm.toShort());
  aclBit = hasAcl;
  encryptedBit = isEncrypted;
}
 
源代码13 项目: hadoop   文件: INodeWithAdditionalFields.java
@Override
void setPermission(FsPermission permission) {
  final short mode = permission.toShort();
  updatePermissionStatus(PermissionStatusFormat.MODE, mode);
}
 
源代码14 项目: big-c   文件: INodeWithAdditionalFields.java
@Override
void setPermission(FsPermission permission) {
  final short mode = permission.toShort();
  updatePermissionStatus(PermissionStatusFormat.MODE, mode);
}
 
源代码15 项目: hadoop   文件: PermissionParam.java
/**
 * Constructor.
 * @param value the parameter value.
 */
public PermissionParam(final FsPermission value) {
  super(DOMAIN, value == null? null: value.toShort(), null, null);
}
 
源代码16 项目: big-c   文件: PermissionParam.java
/**
 * Constructor.
 * @param value the parameter value.
 */
public PermissionParam(final FsPermission value) {
  super(DOMAIN, value == null? null: value.toShort(), null, null);
}