当前位置: 首页>>代码示例>>Java>>正文


Java FileStatus.getPermission方法代码示例

本文整理汇总了Java中org.apache.hadoop.fs.FileStatus.getPermission方法的典型用法代码示例。如果您正苦于以下问题:Java FileStatus.getPermission方法的具体用法?Java FileStatus.getPermission怎么用?Java FileStatus.getPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.fs.FileStatus的用法示例。


在下文中一共展示了FileStatus.getPermission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSetPermission

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
@Override
protected void testSetPermission() throws Exception {
  if (Path.WINDOWS) {
    FileSystem fs = FileSystem.get(getProxiedFSConf());
    Path path = new Path(getProxiedFSTestDir(), "foodir");
    fs.mkdirs(path);

    fs = getHttpFSFileSystem();
    FsPermission permission1 = new FsPermission(FsAction.READ_WRITE, FsAction.NONE, FsAction.NONE);
    fs.setPermission(path, permission1);
    fs.close();

    fs = FileSystem.get(getProxiedFSConf());
    FileStatus status1 = fs.getFileStatus(path);
    fs.close();
    FsPermission permission2 = status1.getPermission();
    Assert.assertEquals(permission2, permission1);

    // sticky bit not supported on Windows with local file system, so the
    // subclass skips that part of the test
  } else {
    super.testSetPermission();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestHttpFSFileSystemLocalFileSystem.java

示例2: checkPublicPermsForAll

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
private static boolean checkPublicPermsForAll(FileSystem fs, 
      FileStatus status, FsAction dir, FsAction file) 
  throws IOException {
  FsPermission perms = status.getPermission();
  FsAction otherAction = perms.getOtherAction();
  if (status.isDirectory()) {
    if (!otherAction.implies(dir)) {
      return false;
    }
    
    for (FileStatus child : fs.listStatus(status.getPath())) {
      if(!checkPublicPermsForAll(fs, child, dir, file)) {
        return false;
      }
    }
    return true;
  }
  return (otherAction.implies(file));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:FSDownload.java

示例3: create

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
private FSDataOutputStream create(Path f, Reporter reporter,
    FileStatus srcstat) throws IOException {
  if (destFileSys.exists(f)) {
    destFileSys.delete(f, false);
  }
  if (!preserve_status) {
    return destFileSys.create(f, true, sizeBuf, reporter);
  }

  FsPermission permission = preseved.contains(FileAttribute.PERMISSION)?
      srcstat.getPermission(): null;
  short replication = preseved.contains(FileAttribute.REPLICATION)?
      srcstat.getReplication(): destFileSys.getDefaultReplication(f);
  long blockSize = preseved.contains(FileAttribute.BLOCK_SIZE)?
      srcstat.getBlockSize(): destFileSys.getDefaultBlockSize(f);
  return destFileSys.create(f, permission, true, sizeBuf, replication,
      blockSize, reporter);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:DistCpV1.java

示例4: validateDistCacheFiles

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
/**
 * Validate private/public distributed cache files.
 * 
 * @param filesSizesExpected
 *          list of sizes of expected dist cache files
 * @param distCacheDir
 *          the distributed cache dir to be validated
 * @throws IOException
 * @throws FileNotFoundException
 */
private void validateDistCacheFiles(List<Long> filesSizesExpected, Path distCacheDir)
    throws FileNotFoundException, IOException {
  // RemoteIterator<LocatedFileStatus> iter =
  FileStatus[] statuses = GridmixTestUtils.dfs.listStatus(distCacheDir);
  int numFiles = filesSizesExpected.size();
  assertEquals("Number of files under distributed cache dir is wrong.",
      numFiles, statuses.length);
  for (int i = 0; i < numFiles; i++) {
    FileStatus stat = statuses[i];
    assertTrue("File size of distributed cache file "
        + stat.getPath().toUri().getPath() + " is wrong.",
        filesSizesExpected.remove(stat.getLen()));

    FsPermission perm = stat.getPermission();
    assertEquals("Wrong permissions for distributed cache file "
        + stat.getPath().toUri().getPath(), new FsPermission(
        GenerateDistCacheData.GRIDMIX_DISTCACHE_FILE_PERM), perm);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:TestDistCacheEmulation.java

示例5: checkPermissionOfOther

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
/**
 * Checks for a given path whether the Other permissions on it imply the permission in the passed
 * FsAction
 * 
 * @return true if the path in the uri is visible to all, false otherwise
 * @throws IOException
 */
public boolean checkPermissionOfOther(FileSystem fs, Path path, FsAction action,
    Map<URI, FileStatus> statCache) throws IOException {
  FileStatus status = getFileStatus(fs, path.toUri(), statCache);
  FsPermission perms = status.getPermission();
  FsAction otherAction = perms.getOtherAction();
  return otherAction.implies(action);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:15,代码来源:ClientDistributedCacheManager.java

示例6: stashOriginalFilePermissions

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
@Override
protected void stashOriginalFilePermissions() throws IOException {
  // save off permissions in case we need to
  // rewrite the keystore in flush()
  FileStatus s = fs.getFileStatus(getPath());
  permissions = s.getPermission();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:8,代码来源:JavaKeyStoreProvider.java

示例7: applyNewPermission

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
/**
 * Apply permission against specified file and determine what the
 * new mode would be
 * @param file File against which to apply mode
 * @return File's new mode if applied.
 */
public short applyNewPermission(FileStatus file) {
  FsPermission perms = file.getPermission();
  int existing = perms.toShort();
  boolean exeOk = file.isDirectory() || (existing & 0111) != 0;
  
  return (short)combineModes(existing, exeOk);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:14,代码来源:ChmodParser.java

示例8: loadFromPath

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
private FsPermission loadFromPath(Path p, char[] password)
    throws IOException, NoSuchAlgorithmException, CertificateException {
  try (FSDataInputStream in = fs.open(p)) {
    FileStatus s = fs.getFileStatus(p);
    keyStore.load(in, password);
    return s.getPermission();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:JavaKeyStoreProvider.java

示例9: testRootReadableExecutableInternal

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
private void testRootReadableExecutableInternal(boolean located)
    throws IOException {
  // verify executable permission on root: cd /
  //
  Assert.assertFalse("In root before cd",
      fsView.getWorkingDirectory().isRoot());
  fsView.setWorkingDirectory(new Path("/"));
  Assert.assertTrue("Not in root dir after cd",
    fsView.getWorkingDirectory().isRoot());

  // verify readable
  //
  verifyRootChildren(listStatusInternal(located,
      fsView.getWorkingDirectory()));

  // verify permissions
  //
  final FileStatus rootStatus =
      fsView.getFileStatus(fsView.getWorkingDirectory());
  final FsPermission perms = rootStatus.getPermission();

  Assert.assertTrue("User-executable permission not set!",
      perms.getUserAction().implies(FsAction.EXECUTE));
  Assert.assertTrue("User-readable permission not set!",
      perms.getUserAction().implies(FsAction.READ));
  Assert.assertTrue("Group-executable permission not set!",
      perms.getGroupAction().implies(FsAction.EXECUTE));
  Assert.assertTrue("Group-readable permission not set!",
      perms.getGroupAction().implies(FsAction.READ));
  Assert.assertTrue("Other-executable permission not set!",
      perms.getOtherAction().implies(FsAction.EXECUTE));
  Assert.assertTrue("Other-readable permission not set!",
      perms.getOtherAction().implies(FsAction.READ));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:35,代码来源:ViewFileSystemBaseTest.java

示例10: checkPermissionOfOther

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
/**
 * Checks for a given path whether the Other permissions on it 
 * imply the permission in the passed FsAction
 * @param fs
 * @param path
 * @param action
 * @return true if the path in the uri is visible to all, false otherwise
 * @throws IOException
 */
private static boolean checkPermissionOfOther(FileSystem fs, Path path,
    FsAction action, Map<URI, FileStatus> statCache) throws IOException {
  FileStatus status = getFileStatus(fs, path.toUri(), statCache);
  FsPermission perms = status.getPermission();
  FsAction otherAction = perms.getOtherAction();
  if (otherAction.implies(action)) {
    return true;
  }
  return false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:ClientDistributedCacheManager.java

示例11: checkPermission

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
static FsPermission checkPermission(FileSystem fs,
    String path, FsPermission expected) throws IOException {
  FileStatus s = fs.getFileStatus(new Path(path));
  LOG.info(s.getPath() + ": " + s.isDirectory() + " " + s.getPermission()
      + ":" + s.getOwner() + ":" + s.getGroup());
  if (expected != null) {
    assertEquals(expected, s.getPermission());
    assertEquals(expected.toShort(), s.getPermission().toShort());
  }
  return s.getPermission();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestPermission.java

示例12: isDifferent

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
private boolean isDifferent(FileStatus original) {
  if (owner != null && !owner.equals(original.getOwner())) {
    return true;
  }
  if (group != null && !group.equals(original.getGroup())) {
    return true;
  }
  if (permission != null) {
    FsPermission orig = original.getPermission();
    return original.isDirectory()? !permission.equals(orig):
      !permission.applyUMask(FILE_UMASK).equals(orig);
  }
  return false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:DistCh.java

示例13: toCopyListingFileStatus

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
/**
 * Converts a FileStatus to a CopyListingFileStatus.  If preserving ACLs,
 * populates the CopyListingFileStatus with the ACLs. If preserving XAttrs,
 * populates the CopyListingFileStatus with the XAttrs.
 *
 * @param fileSystem FileSystem containing the file
 * @param fileStatus FileStatus of file
 * @param preserveAcls boolean true if preserving ACLs
 * @param preserveXAttrs boolean true if preserving XAttrs
 * @param preserveRawXAttrs boolean true if preserving raw.* XAttrs
 * @throws IOException if there is an I/O error
 */
public static CopyListingFileStatus toCopyListingFileStatus(
    FileSystem fileSystem, FileStatus fileStatus, boolean preserveAcls, 
    boolean preserveXAttrs, boolean preserveRawXAttrs) throws IOException {
  CopyListingFileStatus copyListingFileStatus =
    new CopyListingFileStatus(fileStatus);
  if (preserveAcls) {
    FsPermission perm = fileStatus.getPermission();
    if (perm.getAclBit()) {
      List<AclEntry> aclEntries = fileSystem.getAclStatus(
        fileStatus.getPath()).getEntries();
      copyListingFileStatus.setAclEntries(aclEntries);
    }
  }
  if (preserveXAttrs || preserveRawXAttrs) {
    Map<String, byte[]> srcXAttrs = fileSystem.getXAttrs(fileStatus.getPath());
    if (preserveXAttrs && preserveRawXAttrs) {
       copyListingFileStatus.setXAttrs(srcXAttrs);
    } else {
      Map<String, byte[]> trgXAttrs = Maps.newHashMap();
      final String rawNS =
          StringUtils.toLowerCase(XAttr.NameSpace.RAW.name());
      for (Map.Entry<String, byte[]> ent : srcXAttrs.entrySet()) {
        final String xattrName = ent.getKey();
        if (xattrName.startsWith(rawNS)) {
          if (preserveRawXAttrs) {
            trgXAttrs.put(xattrName, ent.getValue());
          }
        } else if (preserveXAttrs) {
          trgXAttrs.put(xattrName, ent.getValue());
        }
      }
      copyListingFileStatus.setXAttrs(trgXAttrs);
    }
  }
  return copyListingFileStatus;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:DistCpUtils.java

示例14: testRootReadableExecutable

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
@Test
public void testRootReadableExecutable() throws IOException {
  // verify executable permission on root: cd /
  //
  Assert.assertFalse("In root before cd",
      fsView.getWorkingDirectory().isRoot());
  fsView.setWorkingDirectory(new Path("/"));
  Assert.assertTrue("Not in root dir after cd",
    fsView.getWorkingDirectory().isRoot());

  // verify readable
  //
  verifyRootChildren(fsView.listStatus(fsView.getWorkingDirectory()));

  // verify permissions
  //
  final FileStatus rootStatus =
      fsView.getFileStatus(fsView.getWorkingDirectory());
  final FsPermission perms = rootStatus.getPermission();

  Assert.assertTrue("User-executable permission not set!",
      perms.getUserAction().implies(FsAction.EXECUTE));
  Assert.assertTrue("User-readable permission not set!",
      perms.getUserAction().implies(FsAction.READ));
  Assert.assertTrue("Group-executable permission not set!",
      perms.getGroupAction().implies(FsAction.EXECUTE));
  Assert.assertTrue("Group-readable permission not set!",
      perms.getGroupAction().implies(FsAction.READ));
  Assert.assertTrue("Other-executable permission not set!",
      perms.getOtherAction().implies(FsAction.EXECUTE));
  Assert.assertTrue("Other-readable permission not set!",
      perms.getOtherAction().implies(FsAction.READ));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:34,代码来源:ViewFileSystemBaseTest.java

示例15: toProtoFileStatus

import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
/**
 * Converts a Hadoop {@link FileStatus} instance into a protobuf
 * {@link DFSProtos.FileStatus}
 *
 * @param status
 *          the Hadoop status instance to convert
 * @return a protobuf status instance
 * @throws IOException
 */
static DFS.FileStatus toProtoFileStatus(FileStatus status) throws IOException {
  DFS.FileStatus.Builder builder = DFS.FileStatus.newBuilder();

  builder
    .setLength(status.getLen())
    .setIsDirectory(status.isDirectory())
    .setBlockReplication(status.getReplication())
    .setBlockSize(status.getBlockSize())
    .setModificationTime(status.getModificationTime())
    .setAccessTime(status.getAccessTime());

  // Handling potential null values
  if (status.getPath() != null) {
    builder = builder.setPath(status.getPath().toUri().getPath());
  }
  if (status.getPermission() != null) {
    builder = builder.setPermission(status.getPermission().toExtendedShort());
  }
  if (status.getOwner() != null) {
    builder = builder.setOwner(status.getOwner());
  }
  if (status.getGroup() != null) {
    builder = builder.setGroup(status.getGroup());
  }
  if (status.isSymlink()) {
    builder = builder.setSymlink(status.getSymlink().toString());
  }

  return builder.build();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:40,代码来源:RemoteNodeFileSystem.java


注:本文中的org.apache.hadoop.fs.FileStatus.getPermission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。