throw new DiskErrorException("Invalid value configured for " + DFS_DATANODE_FAILED_VOLUMES_TOLERATED_KEY + " - " + maxVolumeFailuresTolerated + ". Value configured is >= " throw new DiskErrorException("Too many failed volumes - " + "current valid volumes: " + goodLocations.size() + ", volumes configured: " + dataDirs.size() throw new DiskErrorException("Too many failed volumes - " + "current valid volumes: " + goodLocations.size() + ", volumes configured: " + dataDirs.size() throw new DiskErrorException("All directories in " + DFS_DATANODE_DATA_DIR_KEY + " are invalid: " + failedLocations);
new File(publicDirDestPath.toUri().getPath())); } else { throw new DiskChecker.DiskErrorException( "Disk Validator is null!");
throw new DiskErrorException("No space available in any of the local directories."); throw new DiskErrorException("Could not find any valid local " + "directory for " + pathStr);
throw new DiskErrorException("No space available in any of the local directories."); throw new DiskErrorException("Could not find any valid local " + "directory for " + pathStr);
throw new DiskErrorException("No space available in any of the local directories."); throw new DiskErrorException("Could not find any valid local " + "directory for " + pathStr);
throw new DiskErrorException("No space available in any of the local directories."); throw new DiskErrorException("Could not find any valid local " + "directory for " + pathStr);
throw new DiskErrorException("Could not find any valid local " + "directory for " + pathStr);
throw new DiskErrorException("Could not find any valid local " + "directory for " + pathStr);
throw new DiskErrorException("Invalid volume failure " + " config value: " + volFailuresTolerated); throw new DiskErrorException("Too many failed volumes - " + "current valid volumes: " + storage.getNumStorageDirs() + ", volumes configured: " + volsConfigured
throw new DiskErrorException("Invalid volume failure " + " config value: " + volFailuresTolerated); throw new DiskErrorException("Too many failed volumes - " + "current valid volumes: " + storage.getNumStorageDirs() + ", volumes configured: " + volsConfigured
doThrow(new DiskChecker.DiskErrorException("broken")) .when(brokenVolume).checkDirs();
FsPermission actual = stat.getPermission(); if (!stat.isDir()) throw new DiskErrorException("not a directory: " + path.toString()); FsAction user = actual.getUserAction(); if (!user.implies(FsAction.READ)) throw new DiskErrorException("directory is not readable: " + path.toString()); if (!user.implies(FsAction.WRITE)) throw new DiskErrorException("directory is not writable: " + path.toString());
this.validVolsRequired = volsConfigured - volFailuresTolerated; if (validVolsRequired < 1 || validVolsRequired > storage.getNumStorageDirs()) { throw new DiskErrorException("Too many failed volumes - " + "current valid volumes: " + storage.getNumStorageDirs() + ", volumes configured: " + volsConfigured
throw new DiskErrorException("DataNode failed volumes:" + sb);
/** * Make an instance of DataNode after ensuring that at least one of the * given data directories (and their parent directories, if necessary) * can be created. * @param dataDirs List of directories, where the new DataNode instance should * keep its files. * @param conf Configuration instance to use. * @return DataNode instance for given list of data dirs and conf, or null if * no directory from this directory list can be created. * @throws IOException */ public static DataNode makeInstance(String[] dataDirs, Configuration conf) throws IOException { ArrayList<File> dirs = new ArrayList<File>(); for (int i = 0; i < dataDirs.length; i++) { File data = new File(dataDirs[i]); try { DiskChecker.checkDir(data); dirs.add(data); } catch(DiskErrorException e) { LOG.warn("Invalid directory in dfs.data.dir: " + e.getMessage()); } } if (dirs.size() > 0) return new DataNode(conf, dirs); LOG.error("All directories in dfs.data.dir are invalid."); return null; }
/** * Make an instance of DataNode after ensuring that at least one of the * given data directories (and their parent directories, if necessary) * can be created. * @param dataDirs List of directories, where the new DataNode instance should * keep its files. * @param conf Configuration instance to use. * @return DataNode instance for given list of data dirs and conf, or null if * no directory from this directory list can be created. * @throws IOException */ public static DataNode makeInstance(String[] dataDirs, Configuration conf) throws IOException { ArrayList<File> dirs = new ArrayList<File>(); for (int i = 0; i < dataDirs.length; i++) { File data = new File(dataDirs[i]); try { DiskChecker.checkDir(data); dirs.add(data); } catch(DiskErrorException e) { LOG.warn("Invalid directory in dfs.data.dir: " + e.getMessage()); } } if (dirs.size() > 0) return new DataNode(conf, dirs); LOG.error("All directories in dfs.data.dir are invalid."); return null; }
timeLastCheckDisk = System.currentTimeMillis(); } catch(DiskErrorException de) { handleDiskError(de.getMessage()); } finally { checkingDisk.set(false);
/** * 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 (!dir.isDirectory()) { throw new DiskErrorException("Not a directory: " + dir.toString()); } 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()); } }
private void _checkDirs(boolean isDir, FsPermission perm, boolean success) throws Throwable { File localDir = make(stub(File.class).returning(true).from.exists()); when(localDir.mkdir()).thenReturn(true); Path dir = mock(Path.class); LocalFileSystem fs = make(stub(LocalFileSystem.class) .returning(localDir).from.pathToFile(dir)); FileStatus stat = make(stub(FileStatus.class) .returning(perm).from.getPermission()); when(stat.isDirectory()).thenReturn(isDir); when(fs.getFileStatus(dir)).thenReturn(stat); try { DiskChecker.checkDir(fs, dir, perm); verify(stat).isDirectory(); verify(fs, times(2)).getFileStatus(dir); verify(stat, times(2)).getPermission(); assertTrue("checkDir success", success); } catch (DiskErrorException e) { assertFalse("checkDir success", success); e.printStackTrace(); } System.out.println("checkDir success: "+ success); } }
/** Get a path from the local FS for reading. We search through all the * configured dirs for the file's existence and return the complete * path to the file when we find one */ public Path getLocalPathToRead(String pathStr, Configuration conf) throws IOException { Context ctx = confChanged(conf); int numDirs = ctx.localDirs.length; int numDirsSearched = 0; //remove the leading slash from the path (to make sure that the uri //resolution results in a valid path on the dir being checked) if (pathStr.startsWith("/")) { pathStr = pathStr.substring(1); } while (numDirsSearched < numDirs) { Path file = new Path(ctx.localDirs[numDirsSearched], pathStr); if (ctx.localFS.exists(file)) { return file; } numDirsSearched++; } //no path found throw new DiskErrorException ("Could not find " + pathStr +" in any of" + " the configured local directories"); }