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


Java FileUtil.canRead方法代码示例

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


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

示例1: checkAccessByFileMethods

import org.apache.hadoop.fs.FileUtil; //导入方法依赖的package包/类
/**
 * Checks that the current running process can read, write, and execute the
 * given directory by using methods of the File object.
 * 
 * @param dir File to check
 * @throws DiskErrorException if dir is not readable, not writable, or not
 *   executable
 */
private static void checkAccessByFileMethods(File dir)
    throws DiskErrorException {
  if (!FileUtil.canRead(dir)) {
    throw new DiskErrorException("Directory is not readable: "
                                 + dir.toString());
  }

  if (!FileUtil.canWrite(dir)) {
    throw new DiskErrorException("Directory is not writable: "
                                 + dir.toString());
  }

  if (!FileUtil.canExecute(dir)) {
    throw new DiskErrorException("Directory is not executable: "
                                 + dir.toString());
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:26,代码来源:DiskChecker.java

示例2: readCheckpointTime

import org.apache.hadoop.fs.FileUtil; //导入方法依赖的package包/类
/**
 * Determine the checkpoint time of the specified StorageDirectory
 *
 * @param sd StorageDirectory to check
 * @return If file exists and can be read, last checkpoint time. If not, 0L.
 * @throws IOException On errors processing file pointed to by sd
 */
static long readCheckpointTime(StorageDirectory sd) throws IOException {
  File timeFile = NNStorage.getStorageFile(sd, NameNodeFile.TIME);
  long timeStamp = 0L;
  if (timeFile.exists() && FileUtil.canRead(timeFile)) {
    DataInputStream in = new DataInputStream(new FileInputStream(timeFile));
    try {
      timeStamp = in.readLong();
      in.close();
      in = null;
    } finally {
      IOUtils.cleanup(LOG, in);
    }
  }
  return timeStamp;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:FSImagePreTransactionalStorageInspector.java

示例3: getFsImageName

import org.apache.hadoop.fs.FileUtil; //导入方法依赖的package包/类
/**
 * @return The first image file with the given txid and image type.
 */
public File getFsImageName(long txid, NameNodeFile nnf) {
  for (Iterator<StorageDirectory> it = dirIterator(NameNodeDirType.IMAGE);
      it.hasNext();) {
    StorageDirectory sd = it.next();
    File fsImage = getStorageFile(sd, nnf, txid);
    if (FileUtil.canRead(sd.getRoot()) && fsImage.exists()) {
      return fsImage;
    }
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:NNStorage.java

示例4: getFsImage

import org.apache.hadoop.fs.FileUtil; //导入方法依赖的package包/类
/**
 * @return The first image file whose txid is the same with the given txid and
 * image type is one of the given types.
 */
public File getFsImage(long txid, EnumSet<NameNodeFile> nnfs) {
  for (Iterator<StorageDirectory> it = dirIterator(NameNodeDirType.IMAGE);
      it.hasNext();) {
    StorageDirectory sd = it.next();
    for (NameNodeFile nnf : nnfs) {
      File fsImage = getStorageFile(sd, nnf, txid);
      if (FileUtil.canRead(sd.getRoot()) && fsImage.exists()) {
        return fsImage;
      }
    }
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:NNStorage.java

示例5: findFile

import org.apache.hadoop.fs.FileUtil; //导入方法依赖的package包/类
/**
 * Return the first readable storage file of the given name
 * across any of the 'current' directories in SDs of the
 * given type, or null if no such file exists.
 */
private File findFile(NameNodeDirType dirType, String name) {
  for (StorageDirectory sd : dirIterable(dirType)) {
    File candidate = new File(sd.getCurrentDir(), name);
    if (FileUtil.canRead(sd.getCurrentDir()) &&
        candidate.exists()) {
      return candidate;
    }
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:NNStorage.java

示例6: validate

import org.apache.hadoop.fs.FileUtil; //导入方法依赖的package包/类
private void validate(final List<String> values)
throws IllegalArgumentException {
  for (String file : values) {
    File f = new File(file);
    if (!FileUtil.canRead(f)) {
      fail("File: " + f.getAbsolutePath()
        + " does not exist, or is not readable.");
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:StreamJob.java

示例7: getAbsolutePath

import org.apache.hadoop.fs.FileUtil; //导入方法依赖的package包/类
/**
 * Returns the full path name of this file if it is listed in the path
 */
public File getAbsolutePath(String filename) {
  if (pathenv == null || pathSep == null || fileSep == null) {
    return null;
  }
  int val = -1;
  String classvalue = pathenv + pathSep;

  while (((val = classvalue.indexOf(pathSep)) >= 0)
      && classvalue.length() > 0) {
    // Extract each entry from the pathenv
    String entry = classvalue.substring(0, val).trim();
    File f = new File(entry);

    if (f.isDirectory()) {
      // this entry in the pathenv is a directory.
      // see if the required file is in this directory
      f = new File(entry + fileSep + filename);
    }
    // see if the filename matches and we can read it
    if (f.isFile() && FileUtil.canRead(f)) {
      return f;
    }
    classvalue = classvalue.substring(val + 1).trim();
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:PathFinder.java


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