@Test public void mkdirs() throws IOException { String parentPath = PathUtils.concatPath(mLocalUfsRoot, getUniqueFileName()); String dirpath = PathUtils.concatPath(parentPath, getUniqueFileName()); mLocalUfs.mkdirs(dirpath); assertTrue(mLocalUfs.isDirectory(dirpath)); File file = new File(dirpath); assertTrue(file.exists()); }
@Override public boolean mkdirs(String path, MkdirsOptions options) throws IOException { path = stripPath(path); File file = new File(path); if (!options.getCreateParent()) { if (file.mkdir()) { setMode(file.getPath(), options.getMode().toShort()); FileUtils.setLocalDirStickyBit(file.getPath()); try { setOwner(file.getPath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}", e.getMessage()); } return true; } return false; } Stack<File> dirsToMake = new Stack<>(); dirsToMake.push(file); File parent = file.getParentFile(); while (parent != null && !parent.exists()) { dirsToMake.push(parent); parent = parent.getParentFile(); } while (!dirsToMake.empty()) { File dirToMake = dirsToMake.pop(); if (dirToMake.mkdir()) { setMode(dirToMake.getAbsolutePath(), options.getMode().toShort()); FileUtils.setLocalDirStickyBit(file.getPath()); try { setOwner(dirToMake.getAbsolutePath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}", e.getMessage()); } } else { return false; } } return true; }
LocalUnderFileSystem extends ConsistentUnderFileSystem implements AtomicFileOutputStreamCallback { @Override public boolean mkdirs(String path, MkdirsOptions options) throws IOException { path = stripPath(path); File file = new File(path); if (!options.getCreateParent()) { if (file.mkdir()) { setMode(file.getPath(), options.getMode().toShort()); FileUtils.setLocalDirStickyBit(file.getPath()); try { setOwner(file.getPath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}", e.getMessage()); } return true; } return false; } Stack<File> dirsToMake = new Stack<>(); dirsToMake.push(file); File parent = file.getParentFile(); while (parent != null && !parent.exists()) { dirsToMake.push(parent); parent = parent.getParentFile(); } while (!dirsToMake.empty()) { File dirToMake = dirsToMake.pop(); if (dirToMake.mkdir()) { setMode(dirToMake.getAbsolutePath(), options.getMode().toShort()); FileUtils.setLocalDirStickyBit(file.getPath()); try { setOwner(dirToMake.getAbsolutePath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}", e.getMessage()); } } else { return false; } } return true; } }
LocalUnderFileSystem extends ConsistentUnderFileSystem implements AtomicFileOutputStreamCallback { @Override public boolean mkdirs(String path, MkdirsOptions options) throws IOException { path = stripPath(path); File file = new File(path); if (!options.getCreateParent()) { if (file.mkdir()) { setMode(file.getPath(), options.getMode().toShort()); FileUtils.setLocalDirStickyBit(file.getPath()); try { setOwner(file.getPath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}", e.getMessage()); } return true; } return false; } Stack<File> dirsToMake = new Stack<>(); dirsToMake.push(file); File parent = file.getParentFile(); while (parent != null && !parent.exists()) { dirsToMake.push(parent); parent = parent.getParentFile(); } while (!dirsToMake.empty()) { File dirToMake = dirsToMake.pop(); if (dirToMake.mkdir()) { setMode(dirToMake.getAbsolutePath(), options.getMode().toShort()); FileUtils.setLocalDirStickyBit(file.getPath()); try { setOwner(dirToMake.getAbsolutePath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}", e.getMessage()); } } else { return false; } } return true; } LocalUnderFileSystem(AlluxioURI uri, UnderFileSystemConfiguration ufsConf); }
LocalUnderFileSystem extends ConsistentUnderFileSystem implements AtomicFileOutputStreamCallback { @Override public boolean mkdirs(String path, MkdirsOptions options) throws IOException { path = stripPath(path); File file = new File(path); if (!options.getCreateParent()) { if (file.mkdir()) { setMode(file.getPath(), options.getMode().toShort()); FileUtils.setLocalDirStickyBit(file.getPath()); try { setOwner(file.getPath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}", e.getMessage()); } return true; } return false; } Stack<File> dirsToMake = new Stack<>(); dirsToMake.push(file); File parent = file.getParentFile(); while (parent != null && !parent.exists()) { dirsToMake.push(parent); parent = parent.getParentFile(); } while (!dirsToMake.empty()) { File dirToMake = dirsToMake.pop(); if (dirToMake.mkdir()) { setMode(dirToMake.getAbsolutePath(), options.getMode().toShort()); FileUtils.setLocalDirStickyBit(file.getPath()); try { setOwner(dirToMake.getAbsolutePath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}", e.getMessage()); } } else { return false; } } return true; } LocalUnderFileSystem(AlluxioURI uri, UnderFileSystemConfiguration ufsConf); @Override String getUnderFSType(); @Override void cleanup(); @Override void close(); @Override OutputStream create(String path, CreateOptions options); @Override OutputStream createDirect(String path, CreateOptions options); @Override boolean deleteDirectory(String path, DeleteOptions options); @Override boolean deleteFile(String path); @Override boolean exists(String path); @Override long getBlockSizeByte(String path); @Override UfsDirectoryStatus getDirectoryStatus(String path); @Override List<String> getFileLocations(String path); @Override List<String> getFileLocations(String path, FileLocationOptions options); @Override UfsFileStatus getFileStatus(String path); @Override long getSpace(String path, SpaceType type); @Override UfsStatus getStatus(String path); @Override boolean isDirectory(String path); @Override boolean isFile(String path); @Override UfsStatus[] listStatus(String path); @Override boolean mkdirs(String path, MkdirsOptions options); @Override InputStream open(String path, OpenOptions options); @Override boolean renameDirectory(String src, String dst); @Override boolean renameFile(String src, String dst); @Override void setOwner(String path, String user, String group); @Override void setMode(String path, short mode); @Override void connectFromMaster(String hostname); @Override void connectFromWorker(String hostname); @Override boolean supportsFlush(); }
LocalUnderFileSystem extends ConsistentUnderFileSystem implements AtomicFileOutputStreamCallback { @Override public boolean mkdirs(String path, MkdirsOptions options) throws IOException { path = stripPath(path); File file = new File(path); if (!options.getCreateParent()) { if (file.mkdir()) { setMode(file.getPath(), options.getMode().toShort()); FileUtils.setLocalDirStickyBit(file.getPath()); try { setOwner(file.getPath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}", e.getMessage()); } return true; } return false; } Stack<File> dirsToMake = new Stack<>(); dirsToMake.push(file); File parent = file.getParentFile(); while (parent != null && !parent.exists()) { dirsToMake.push(parent); parent = parent.getParentFile(); } while (!dirsToMake.empty()) { File dirToMake = dirsToMake.pop(); if (dirToMake.mkdir()) { setMode(dirToMake.getAbsolutePath(), options.getMode().toShort()); FileUtils.setLocalDirStickyBit(file.getPath()); try { setOwner(dirToMake.getAbsolutePath(), options.getOwner(), options.getGroup()); } catch (IOException e) { LOG.warn("Failed to update the ufs dir ownership, default values will be used: {}", e.getMessage()); } } else { return false; } } return true; } LocalUnderFileSystem(AlluxioURI uri, UnderFileSystemConfiguration ufsConf); @Override String getUnderFSType(); @Override void cleanup(); @Override void close(); @Override OutputStream create(String path, CreateOptions options); @Override OutputStream createDirect(String path, CreateOptions options); @Override boolean deleteDirectory(String path, DeleteOptions options); @Override boolean deleteFile(String path); @Override boolean exists(String path); @Override long getBlockSizeByte(String path); @Override UfsDirectoryStatus getDirectoryStatus(String path); @Override List<String> getFileLocations(String path); @Override List<String> getFileLocations(String path, FileLocationOptions options); @Override UfsFileStatus getFileStatus(String path); @Override long getSpace(String path, SpaceType type); @Override UfsStatus getStatus(String path); @Override boolean isDirectory(String path); @Override boolean isFile(String path); @Override UfsStatus[] listStatus(String path); @Override boolean mkdirs(String path, MkdirsOptions options); @Override InputStream open(String path, OpenOptions options); @Override boolean renameDirectory(String src, String dst); @Override boolean renameFile(String src, String dst); @Override void setOwner(String path, String user, String group); @Override void setMode(String path, short mode); @Override void connectFromMaster(String hostname); @Override void connectFromWorker(String hostname); @Override boolean supportsFlush();  }