private void createTabletDirectories(VolumeManager fs, SortedSet<Text> dirInfo) throws IOException { for (Text dir : dirInfo) { if (!fs.mkdirs(new Path(dir.toString()))) throw new IOException("Failed to create tablet directory: " + dir); } } }
private static void initDirs(VolumeManager fs, UUID uuid, String[] baseDirs, boolean print) throws IOException { for (String baseDir : baseDirs) { fs.mkdirs(new Path(new Path(baseDir, ServerConstants.VERSION_DIR), "" + ServerConstants.DATA_VERSION), new FsPermission("700")); // create an instance id Path iidLocation = new Path(baseDir, ServerConstants.INSTANCE_ID_DIR); fs.mkdirs(iidLocation); fs.createNewFile(new Path(iidLocation, uuid.toString())); if (print) log.info("Initialized volume {}", baseDir); } }
private static void createDirectories(VolumeManager fs, String... dirs) throws IOException { for (String s : dirs) { Path dir = new Path(s); try { FileStatus fstat = fs.getFileStatus(dir); if (!fstat.isDirectory()) { log.error("FATAL: location {} exists but is not a directory", dir); return; } } catch (FileNotFoundException fnfe) { // attempt to create directory, since it doesn't exist if (!fs.mkdirs(dir)) { log.error("FATAL: unable to create directory {}", dir); return; } } } }
private Path createNewBulkDir(ServerContext context, VolumeManager fs, Table.ID tableId) throws IOException { Path tempPath = fs.matchingFileSystem(new Path(bulkInfo.sourceDir), ServerConstants.getTablesDirs(context)); if (tempPath == null) throw new IOException(bulkInfo.sourceDir + " is not in a volume configured for Accumulo"); String tableDir = tempPath.toString(); if (tableDir == null) throw new IOException(bulkInfo.sourceDir + " is not in a volume configured for Accumulo"); Path directory = new Path(tableDir + "/" + tableId); fs.mkdirs(directory); UniqueNameAllocator namer = context.getUniqueNameAllocator(); while (true) { Path newBulkDir = new Path(directory, Constants.BULK_PREFIX + namer.getNextName()); if (fs.mkdirs(newBulkDir)) return newBulkDir; log.warn("Failed to create {} for unknown reason", newBulkDir); sleepUninterruptibly(3, TimeUnit.SECONDS); } }
private static Path createTmpDir(ServerContext context, String tabletDirectory) throws IOException { VolumeManager fs = context.getVolumeManager(); Path result = null; while (result == null) { result = new Path(tabletDirectory + Path.SEPARATOR + "tmp/idxReduce_" + String.format("%09d", new SecureRandom().nextInt(Integer.MAX_VALUE))); try { fs.getFileStatus(result); result = null; continue; } catch (FileNotFoundException fne) { // found an unused temp directory } fs.mkdirs(result); // try to reserve the tmp dir // In some versions of hadoop, two clients concurrently trying to create the same directory // might both return true // Creating a file is not subject to this, so create a special file to make sure we solely // will use this directory if (!fs.createNewFile(new Path(result, "__reserve"))) result = null; } return result; }
private static Path createNewBulkDir(ServerContext context, VolumeManager fs, String sourceDir, Table.ID tableId) throws IOException { Path tempPath = fs.matchingFileSystem(new Path(sourceDir), ServerConstants.getTablesDirs(context)); if (tempPath == null) throw new IOException(sourceDir + " is not in a volume configured for Accumulo"); String tableDir = tempPath.toString(); if (tableDir == null) throw new IOException(sourceDir + " is not in a volume configured for Accumulo"); Path directory = new Path(tableDir + "/" + tableId); fs.mkdirs(directory); // only one should be able to create the lock file // the purpose of the lock file is to avoid a race // condition between the call to fs.exists() and // fs.mkdirs()... if only hadoop had a mkdir() function // that failed when the dir existed UniqueNameAllocator namer = context.getUniqueNameAllocator(); while (true) { Path newBulkDir = new Path(directory, Constants.BULK_PREFIX + namer.getNextName()); if (fs.exists(newBulkDir)) // sanity check throw new IOException("Dir exist when it should not " + newBulkDir); if (fs.mkdirs(newBulkDir)) return newBulkDir; log.warn("Failed to create {} for unknown reason", newBulkDir); sleepUninterruptibly(3, TimeUnit.SECONDS); } }
private void checkTabletDir() throws IOException { if (!tableDirChecked) { FileStatus[] files = null; try { files = getTabletServer().getFileSystem().listStatus(location); } catch (FileNotFoundException ex) { // ignored } if (files == null) { if (location.getName().startsWith(Constants.CLONE_PREFIX)) log.debug("Tablet {} had no dir, creating {}", extent, location); // its a clone dir... else log.warn("Tablet {} had no dir, creating {}", extent, location); getTabletServer().getFileSystem().mkdirs(location); } tableDirChecked = true; } }
public static void exportTable(VolumeManager fs, ServerContext context, String tableName, Table.ID tableID, String exportDir) throws Exception { fs.mkdirs(new Path(exportDir)); Path exportMetaFilePath = fs.getVolumeByPath(new Path(exportDir)).getFileSystem() .makeQualified(new Path(exportDir, Constants.EXPORT_FILE));
VolumeManager fs = environment.getFileSystem(); fs.mkdirs(new Path(tableInfo.importDir));
lowDirectory = Constants.DEFAULT_TABLET_LOCATION; Path lowDirectoryPath = new Path(volume + "/" + tableId + "/" + lowDirectory); if (fs.exists(lowDirectoryPath) || fs.mkdirs(lowDirectoryPath)) { FileSystem pathFs = fs.getVolumeByPath(lowDirectoryPath).getFileSystem(); return lowDirectoryPath.makeQualified(pathFs.getUri(), pathFs.getWorkingDirectory()) if (fs.exists(lowDirectoryPath)) throw new IllegalStateException("Dir exist when it should not " + lowDirectoryPath); if (fs.mkdirs(lowDirectoryPath)) { FileSystem lowDirectoryFs = fs.getVolumeByPath(lowDirectoryPath).getFileSystem(); return lowDirectoryPath
String newPath = fs.choose(chooserEnv, ServerConstants.getBaseUris(context)) + Constants.HDFS_TABLES_DIR + Path.SEPARATOR + RootTable.ID; fs.mkdirs(new Path(newPath)); if (!fs.rename(oldPath, new Path(newPath))) { throw new IOException("Failed to move root tablet from " + oldPath + " to " + newPath);
@Override public Repo<Master> call(long tid, Master master) throws Exception { VolumeManager fs = master.getFileSystem(); fs.mkdirs(new Path(tableInfo.defaultTabletDir)); // read in the splitDir info file and create a directory for each item if (tableInfo.getInitialSplitSize() > 0) { SortedSet<Text> dirInfo = Utils .getSortedSetFromFile(master.getInputStream(tableInfo.getSplitDirsFile()), false); createTabletDirectories(master.getFileSystem(), dirInfo); } return new PopulateMetadata(tableInfo); }
pool.submit(() -> { try { vm.mkdirs(new Path(newLocation)); } catch (IOException ex) {
@Override public void run() { try { vm.mkdirs(new Path(newLocation)); } catch (IOException ex) { // nevermind } } });
private static void initDirs(VolumeManager fs, UUID uuid, String[] baseDirs, boolean print) throws IOException { for (String baseDir : baseDirs) { fs.mkdirs(new Path(new Path(baseDir, ServerConstants.VERSION_DIR), "" + ServerConstants.DATA_VERSION), new FsPermission("700")); // create an instance id Path iidLocation = new Path(baseDir, ServerConstants.INSTANCE_ID_DIR); fs.mkdirs(iidLocation); fs.createNewFile(new Path(iidLocation, uuid.toString())); if (print) log.info("Initialized volume " + baseDir); } }
private static void createDirectories(VolumeManager fs, String... dirs) throws IOException { for (String s : dirs) { Path dir = new Path(s); try { FileStatus fstat = fs.getFileStatus(dir); if (!fstat.isDirectory()) { log.error("FATAL: location " + dir + " exists but is not a directory"); return; } } catch (FileNotFoundException fnfe) { // attempt to create directory, since it doesn't exist if (!fs.mkdirs(dir)) { log.error("FATAL: unable to create directory " + dir); return; } } } }
@Override public Repo<Master> call(long tid, Master master) throws Exception { VolumeManager fs = master.getFileSystem(); fs.mkdirs(new Path(tableInfo.dir)); return new PopulateMetadata(tableInfo); }
private static Path createTmpDir(AccumuloConfiguration acuConf, VolumeManager fs) throws IOException { String accumuloDir = fs.choose(Optional.<String> absent(), ServerConstants.getBaseUris()); Path result = null; while (result == null) { result = new Path(accumuloDir + Path.SEPARATOR + "tmp/idxReduce_" + String.format("%09d", new Random().nextInt(Integer.MAX_VALUE))); try { fs.getFileStatus(result); result = null; continue; } catch (FileNotFoundException fne) { // found an unused temp directory } fs.mkdirs(result); // try to reserve the tmp dir // In some versions of hadoop, two clients concurrently trying to create the same directory // might both return true // Creating a file is not subject to this, so create a special file to make sure we solely // will use this directory if (!fs.createNewFile(new Path(result, "__reserve"))) result = null; } return result; }
private void checkTabletDir() throws IOException { if (!tableDirChecked) { FileStatus[] files = null; try { files = getTabletServer().getFileSystem().listStatus(location); } catch (FileNotFoundException ex) { // ignored } if (files == null) { if (location.getName().startsWith(Constants.CLONE_PREFIX)) log.debug("Tablet " + extent + " had no dir, creating " + location); // its a clone dir... else log.warn("Tablet " + extent + " had no dir, creating " + location); getTabletServer().getFileSystem().mkdirs(location); } tableDirChecked = true; } }