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