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


Java FsPermission.getAclBit方法代码示例

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


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

示例1: processPath

import org.apache.hadoop.fs.permission.FsPermission; //导入方法依赖的package包/类
@Override
protected void processPath(PathData item) throws IOException {
  out.println("# file: " + item);
  out.println("# owner: " + item.stat.getOwner());
  out.println("# group: " + item.stat.getGroup());
  FsPermission perm = item.stat.getPermission();
  if (perm.getStickyBit()) {
    out.println("# flags: --" +
      (perm.getOtherAction().implies(FsAction.EXECUTE) ? "t" : "T"));
  }

  AclStatus aclStatus = item.fs.getAclStatus(item.path);
  List<AclEntry> entries = perm.getAclBit() ? aclStatus.getEntries()
      : Collections.<AclEntry> emptyList();
  ScopedAclEntries scopedEntries = new ScopedAclEntries(
    AclUtil.getAclFromPermAndEntries(perm, entries));
  printAclEntriesForSingleScope(aclStatus, perm,
      scopedEntries.getAccessEntries());
  printAclEntriesForSingleScope(aclStatus, perm,
      scopedEntries.getDefaultEntries());
  out.println();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:AclCommands.java

示例2: processPath

import org.apache.hadoop.fs.permission.FsPermission; //导入方法依赖的package包/类
@Override
protected void processPath(PathData item) throws IOException {
  out.println("# file: " + item);
  out.println("# owner: " + item.stat.getOwner());
  out.println("# group: " + item.stat.getGroup());
  FsPermission perm = item.stat.getPermission();
  if (perm.getStickyBit()) {
    out.println("# flags: --" +
      (perm.getOtherAction().implies(FsAction.EXECUTE) ? "t" : "T"));
  }

  AclStatus aclStatus = null;
  List<AclEntry> entries = null;
  if (perm.getAclBit()) {
    aclStatus = item.fs.getAclStatus(item.path);
    entries = aclStatus.getEntries();
  } else {
    aclStatus = null;
    entries = Collections.<AclEntry> emptyList();
  }
  ScopedAclEntries scopedEntries = new ScopedAclEntries(
    AclUtil.getAclFromPermAndEntries(perm, entries));
  printAclEntriesForSingleScope(aclStatus, perm,
      scopedEntries.getAccessEntries());
  printAclEntriesForSingleScope(aclStatus, perm,
      scopedEntries.getDefaultEntries());
  out.println();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:29,代码来源:AclCommands.java

示例3: toJsonString

import org.apache.hadoop.fs.permission.FsPermission; //导入方法依赖的package包/类
/** Convert a HdfsFileStatus object to a Json string. */
public static String toJsonString(final HdfsFileStatus status,
    boolean includeType) {
  if (status == null) {
    return null;
  }
  final Map<String, Object> m = new TreeMap<String, Object>();
  m.put("pathSuffix", status.getLocalName());
  m.put("type", PathType.valueOf(status));
  if (status.isSymlink()) {
    m.put("symlink", status.getSymlink());
  }

  m.put("length", status.getLen());
  m.put("owner", status.getOwner());
  m.put("group", status.getGroup());
  FsPermission perm = status.getPermission();
  m.put("permission", toString(perm));
  if (perm.getAclBit()) {
    m.put("aclBit", true);
  }
  if (perm.getEncryptedBit()) {
    m.put("encBit", true);
  }
  m.put("accessTime", status.getAccessTime());
  m.put("modificationTime", status.getModificationTime());
  m.put("blockSize", status.getBlockSize());
  m.put("replication", status.getReplication());
  m.put("fileId", status.getFileId());
  m.put("childrenNum", status.getChildrenNum());
  m.put("storagePolicy", status.getStoragePolicy());
  ObjectMapper mapper = new ObjectMapper();
  try {
    return includeType ?
        toJsonString(FileStatus.class, m) : mapper.writeValueAsString(m);
  } catch (IOException ignored) {
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:40,代码来源:JsonUtil.java

示例4: toCopyListingFileStatus

import org.apache.hadoop.fs.permission.FsPermission; //导入方法依赖的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

示例5: preserveAttributes

import org.apache.hadoop.fs.permission.FsPermission; //导入方法依赖的package包/类
/**
 * Preserve the attributes of the source to the target.
 * The method calls {@link #shouldPreserve(FileAttribute)} to check what
 * attribute to preserve.
 * @param src source to preserve
 * @param target where to preserve attributes
 * @param preserveRawXAttrs true if raw.* xattrs should be preserved
 * @throws IOException if fails to preserve attributes
 */
protected void preserveAttributes(PathData src, PathData target,
    boolean preserveRawXAttrs)
    throws IOException {
  if (shouldPreserve(FileAttribute.TIMESTAMPS)) {
    target.fs.setTimes(
        target.path,
        src.stat.getModificationTime(),
        src.stat.getAccessTime());
  }
  if (shouldPreserve(FileAttribute.OWNERSHIP)) {
    target.fs.setOwner(
        target.path,
        src.stat.getOwner(),
        src.stat.getGroup());
  }
  if (shouldPreserve(FileAttribute.PERMISSION) ||
      shouldPreserve(FileAttribute.ACL)) {
    target.fs.setPermission(
        target.path,
        src.stat.getPermission());
  }
  if (shouldPreserve(FileAttribute.ACL)) {
    FsPermission perm = src.stat.getPermission();
    if (perm.getAclBit()) {
      List<AclEntry> srcEntries =
          src.fs.getAclStatus(src.path).getEntries();
      List<AclEntry> srcFullEntries =
          AclUtil.getAclFromPermAndEntries(perm, srcEntries);
      target.fs.setAcl(target.path, srcFullEntries);
    }
  }
  final boolean preserveXAttrs = shouldPreserve(FileAttribute.XATTR);
  if (preserveXAttrs || preserveRawXAttrs) {
    Map<String, byte[]> srcXAttrs = src.fs.getXAttrs(src.path);
    if (srcXAttrs != null) {
      Iterator<Entry<String, byte[]>> iter = srcXAttrs.entrySet().iterator();
      while (iter.hasNext()) {
        Entry<String, byte[]> entry = iter.next();
        final String xattrName = entry.getKey();
        if (xattrName.startsWith(RAW) || preserveXAttrs) {
          target.fs.setXAttr(target.path, entry.getKey(), entry.getValue());
        }
      }
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:56,代码来源:CommandWithDestination.java


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