當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。