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


Java FileUtil.canWrite方法代码示例

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


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

import org.apache.hadoop.fs.FileUtil; //导入方法依赖的package包/类
/**
 * See if any of removed storages is "writable" again, and can be returned
 * into service.
 */
void attemptRestoreRemovedStorage() {
  // if directory is "alive" - copy the images there...
  if(!restoreFailedStorage || removedStorageDirs.size() == 0)
    return; //nothing to restore

  /* We don't want more than one thread trying to restore at a time */
  synchronized (this.restorationLock) {
    LOG.info("NNStorage.attemptRestoreRemovedStorage: check removed(failed) "+
             "storarge. removedStorages size = " + removedStorageDirs.size());
    for(Iterator<StorageDirectory> it
          = this.removedStorageDirs.iterator(); it.hasNext();) {
      StorageDirectory sd = it.next();
      File root = sd.getRoot();
      LOG.info("currently disabled dir " + root.getAbsolutePath() +
               "; type="+sd.getStorageDirType() 
               + ";canwrite="+FileUtil.canWrite(root));
      if(root.exists() && FileUtil.canWrite(root)) {
        LOG.info("restoring dir " + sd.getRoot().getAbsolutePath());
        this.addStorageDir(sd); // restore
        this.removedStorageDirs.remove(sd);
      }
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:NNStorage.java

示例3: initializeControllerPathsFromMtab

import org.apache.hadoop.fs.FileUtil; //导入方法依赖的package包/类
private void initializeControllerPathsFromMtab()
    throws ResourceHandlerException {
  try {
    Map<String, List<String>> parsedMtab = parseMtab();

    //we want to do a bulk update without the paths changing concurrently
    rwLock.writeLock().lock();

    for (CGroupController controller : CGroupController.values()) {
      String name = controller.getName();
      String controllerPath = findControllerInMtab(name, parsedMtab);

      if (controllerPath != null) {
        File f = new File(controllerPath + "/" + this.cGroupPrefix);

        if (FileUtil.canWrite(f)) {
          controllerPaths.put(controller, controllerPath);
        } else {
          String error =
              new StringBuffer("Mount point Based on mtab file: ")
                  .append(MTAB_FILE).append(
                  ". Controller mount point not writable for: ")
                  .append(name).toString();

          LOG.error(error);
          throw new ResourceHandlerException(error);
        }
      } else {

          LOG.warn("Controller not mounted but automount disabled: " + name);
      }
    }
  } catch (IOException e) {
    LOG.warn("Failed to initialize controller paths! Exception: " + e);
    throw new ResourceHandlerException(
        "Failed to initialize controller paths!");
  } finally {
    rwLock.writeLock().unlock();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:41,代码来源:CGroupsHandlerImpl.java

示例4: initializeControllerPaths

import org.apache.hadoop.fs.FileUtil; //导入方法依赖的package包/类
private void initializeControllerPaths() throws IOException {
  String controllerPath;


  Boolean isCentos7 = conf.getBoolean("os.centos7",false);

  if (isCentos7) {
    // centos7
    controllerPath = cgroupMountPath+"/"+CONTROLLER_CPU;  //   "/sys/fs/cgroup/cpu"

  }else {
    Map<String, List<String>> parsedMtab = parseMtab();

    // CPU

    controllerPath = findControllerInMtab(CONTROLLER_CPU, parsedMtab);
  }



  if (controllerPath != null) {
    File f = new File(controllerPath + "/" + this.cgroupPrefix);

    if (FileUtil.canWrite(f)) {
      controllerPaths.put(CONTROLLER_CPU, controllerPath);
    } else {
      throw new IOException("Not able to enforce cpu weights; cannot write "
          + "to cgroup at: " + controllerPath);
    }
  } else {
    throw new IOException("Not able to enforce cpu weights; cannot find "
        + "cgroup for cpu controller in " + getMtabFileName());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:CgroupsLCEResourcesHandler.java


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