本文整理匯總了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());
}
}
示例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);
}
}
}
}
示例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();
}
}
示例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());
}
}