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


Java FsPermission.getFileDefault方法代码示例

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


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

示例1: HdfsFileStatus

import org.apache.hadoop.fs.permission.FsPermission; //导入方法依赖的package包/类
/**
 * Constructor
 * @param length the number of bytes the file has
 * @param isdir if the path is a directory
 * @param block_replication the replication factor
 * @param blocksize the block size
 * @param modification_time modification time
 * @param access_time access time
 * @param permission permission
 * @param owner the owner of the path
 * @param group the group of the path
 * @param path the local name in java UTF8 encoding the same as that in-memory
 * @param fileId the file id
 * @param feInfo the file's encryption info
 */
public HdfsFileStatus(long length, boolean isdir, int block_replication,
    long blocksize, long modification_time, long access_time,
    FsPermission permission, String owner, String group, byte[] symlink,
    byte[] path, long fileId, int childrenNum, FileEncryptionInfo feInfo,
    byte storagePolicy) {
  this.length = length;
  this.isdir = isdir;
  this.block_replication = (short)block_replication;
  this.blocksize = blocksize;
  this.modification_time = modification_time;
  this.access_time = access_time;
  this.permission = (permission == null) ? 
      ((isdir || symlink!=null) ? 
          FsPermission.getDefault() : 
          FsPermission.getFileDefault()) :
      permission;
  this.owner = (owner == null) ? "" : owner;
  this.group = (group == null) ? "" : group;
  this.symlink = symlink;
  this.path = path;
  this.fileId = fileId;
  this.childrenNum = childrenNum;
  this.feInfo = feInfo;
  this.storagePolicy = storagePolicy;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:41,代码来源:HdfsFileStatus.java

示例2: create

import org.apache.hadoop.fs.permission.FsPermission; //导入方法依赖的package包/类
/**
 * Same as {@link #create(String, FsPermission, EnumSet, boolean, short, long,
 * Progressable, int, ChecksumOpt)} with the addition of favoredNodes that is
 * a hint to where the namenode should place the file blocks.
 * The favored nodes hint is not persisted in HDFS. Hence it may be honored
 * at the creation time only. HDFS could move the blocks during balancing or
 * replication, to move the blocks from favored nodes. A value of null means
 * no favored nodes for this create
 */
public DFSOutputStream create(String src, 
                           FsPermission permission,
                           EnumSet<CreateFlag> flag, 
                           boolean createParent,
                           short replication,
                           long blockSize,
                           Progressable progress,
                           int buffersize,
                           ChecksumOpt checksumOpt,
                           InetSocketAddress[] favoredNodes) throws IOException {
  checkOpen();
  if (permission == null) {
    permission = FsPermission.getFileDefault();
  }
  FsPermission masked = permission.applyUMask(dfsClientConf.uMask);
  if(LOG.isDebugEnabled()) {
    LOG.debug(src + ": masked=" + masked);
  }
  final DFSOutputStream result = DFSOutputStream.newStreamForCreate(this,
      src, masked, flag, createParent, replication, blockSize, progress,
      buffersize, dfsClientConf.createChecksum(checksumOpt),
      getFavoredNodesStr(favoredNodes));
  beginFileLease(result.getFileId(), result);
  return result;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:DFSClient.java

示例3: getFilePermissions

import org.apache.hadoop.fs.permission.FsPermission; //导入方法依赖的package包/类
/**
 * Get the file permissions specified in the configuration, if they are
 * enabled.
 *
 * @param fs filesystem that the file will be created on.
 * @param conf configuration to read for determining if permissions are
 *          enabled and which to use
 * @param permssionConfKey property key in the configuration to use when
 *          finding the permission
 * @return the permission to use when creating a new file on the fs. If
 *         special permissions are not specified in the configuration, then
 *         the default permissions on the the fs will be returned.
 */
public static FsPermission getFilePermissions(final FileSystem fs,
    final Configuration conf, final String permssionConfKey) {
  boolean enablePermissions = conf.getBoolean(
      HConstants.ENABLE_DATA_FILE_UMASK, false);

  if (enablePermissions) {
    try {
      FsPermission perm = new FsPermission(FULL_RWX_PERMISSIONS);
      // make sure that we have a mask, if not, go default.
      String mask = conf.get(permssionConfKey);
      if (mask == null)
        return FsPermission.getFileDefault();
      // appy the umask
      FsPermission umask = new FsPermission(mask);
      return perm.applyUMask(umask);
    } catch (IllegalArgumentException e) {
      LOG.warn(
          "Incorrect umask attempted to be created: "
              + conf.get(permssionConfKey)
              + ", using default file permissions.", e);
      return FsPermission.getFileDefault();
    }
  }
  return FsPermission.getFileDefault();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:39,代码来源:FSUtils.java

示例4: LocalFSFileOutputStream

import org.apache.hadoop.fs.permission.FsPermission; //导入方法依赖的package包/类
private LocalFSFileOutputStream(Path f, boolean append,
    FsPermission permission) throws IOException {
  File file = pathToFile(f);
  if (!append && permission == null) {
    permission = FsPermission.getFileDefault();
  }
  if (permission == null) {
    this.fos = new FileOutputStream(file, append);
  } else {
    permission = permission.applyUMask(umask);
    if (Shell.WINDOWS && NativeIO.isAvailable()) {
      this.fos = NativeIO.Windows.createFileOutputStreamWithMode(file,
          append, permission.toShort());
    } else {
      this.fos = new FileOutputStream(file, append);
      boolean success = false;
      try {
        setPermission(f, permission);
        success = true;
      } finally {
        if (!success) {
          IOUtils.cleanup(LOG, this.fos);
        }
      }
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:28,代码来源:RawLocalFileSystem.java

示例5: testOnMessageSuccessful

import org.apache.hadoop.fs.permission.FsPermission; //导入方法依赖的package包/类
@Test
public void testOnMessageSuccessful() throws IOException {
  FileStatus[] statuses = {
      new FileStatus(1337, false, 1, 4096, 1, 2, FsPermission.getFileDefault(), "testowner", "testgroup", new Path(TEST_PATH, "bar")),
      new FileStatus(0, true, 0, 0, 3, 4, FsPermission.getDirDefault(), "testowner", "testgroup", new Path(TEST_PATH, "baz"))
  };

  DFS.ListStatusResponse response = getResponse(statuses);

  assertEquals(2, response.getStatusesList().size());
  assertEquals(TEST_PATH_STRING + "/bar", response.getStatusesList().get(0).getPath());
  assertEquals(TEST_PATH_STRING + "/baz", response.getStatusesList().get(1).getPath());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:14,代码来源:TestPDFSProtocol.java

示例6: setPermission

import org.apache.hadoop.fs.permission.FsPermission; //导入方法依赖的package包/类
/**
 * Sets permission.
 * @param permission if permission is null, default value is set
 */
protected void setPermission(FsPermission permission) {
  this.permission = (permission == null) ? 
                    FsPermission.getFileDefault() : permission;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:FileStatus.java


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