@Override public boolean mkdirs(Path f) throws IOException { return unsafeFileSystem.mkdirs(f); }
@Override public boolean mkdirs(Path f) throws IOException { return originalFs.mkdirs(f); }
private static void unzipPythonLibrary(Path targetDir) throws IOException { FileSystem targetFs = targetDir.getFileSystem(); ClassLoader classLoader = PythonPlanBinder.class.getClassLoader(); try (ZipInputStream zis = new ZipInputStream(classLoader.getResourceAsStream("python-source.zip"))) { ZipEntry entry = zis.getNextEntry(); while (entry != null) { String fileName = entry.getName(); Path newFile = new Path(targetDir, fileName); if (entry.isDirectory()) { targetFs.mkdirs(newFile); } else { try { LOG.debug("Unzipping to {}.", newFile); FSDataOutputStream fsDataOutputStream = targetFs.create(newFile, FileSystem.WriteMode.NO_OVERWRITE); IOUtils.copyBytes(zis, fsDataOutputStream, false); } catch (Exception e) { zis.closeEntry(); throw new IOException("Failed to unzip flink python library.", e); } } zis.closeEntry(); entry = zis.getNextEntry(); } zis.closeEntry(); } }
private static void internalCopyDirectory(Path sourcePath, Path targetPath, boolean executable, FileSystem sFS, FileSystem tFS) throws IOException { tFS.mkdirs(targetPath); FileStatus[] contents = sFS.listStatus(sourcePath); for (FileStatus content : contents) { String distPath = content.getPath().toString(); if (content.isDir()) { if (distPath.endsWith("/")) { distPath = distPath.substring(0, distPath.length() - 1); } } String localPath = targetPath + distPath.substring(distPath.lastIndexOf("/")); copy(content.getPath(), new Path(localPath), executable); } }
public static Path expandDirectory(Path file, Path targetDirectory) throws IOException { FileSystem sourceFs = file.getFileSystem(); FileSystem targetFs = targetDirectory.getFileSystem(); Path rootDir = null; try (ZipInputStream zis = new ZipInputStream(sourceFs.open(file))) { ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { Path relativePath = new Path(entry.getName()); if (rootDir == null) { // the first entry contains the name of the original directory that was zipped rootDir = relativePath; } Path newFile = new Path(targetDirectory, relativePath); if (entry.isDirectory()) { targetFs.mkdirs(newFile); } else { try (FSDataOutputStream fileStream = targetFs.create(newFile, FileSystem.WriteMode.NO_OVERWRITE)) { // do not close the streams here as it prevents access to further zip entries IOUtils.copyBytes(zis, fileStream, false); } } zis.closeEntry(); } } return new Path(targetDirectory, rootDir); }
flinkFileSystem.mkdirs(haDataDirectory);
mkdirs(outPath);
private void createRandomFileInDirectory(Path directory) throws IOException { fs.mkdirs(directory); createFile(new Path(directory, randomName())); }
targetDir.getFileSystem().mkdirs(targetDir);
try { cyclicBarrier.await(); assertThat(fs.mkdirs(Path.fromLocalFile(targetDirectory)), is(true)); } catch (Exception e) { throw new CompletionException(e);
@Test public void testMkdirsReturnsTrueForExistingDirectory() throws Exception { // this test applies to object stores as well, as rely on the fact that they // return true when things are not bad final Path directory = new Path(basePath, randomName()); // make sure the directory exists createRandomFileInDirectory(directory); assertTrue(fs.mkdirs(directory)); }
targetDir.getFileSystem().mkdirs(targetDir);
@Before public void prepare() throws Exception { basePathForTest = new Path(getBasePath(), randomName()); getFileSystem().mkdirs(basePathForTest); }
@Before public void prepare() throws Exception { fs = getFileSystem(); basePath = new Path(getBasePath(), randomName()); fs.mkdirs(basePath); }
verify(fs).mkdirs(path);
@Test public void testMkdirsReturnsTrueWhenCreatingDirectory() throws Exception { // this test applies to object stores as well, as rely on the fact that they // return true when things are not bad final Path directory = new Path(basePath, randomName()); assertTrue(fs.mkdirs(directory)); if (getFileSystemKind() != FileSystemKind.OBJECT_STORE) { assertTrue(fs.exists(directory)); } }
@Test public void testMkdirsFailsForExistingFile() throws Exception { // test is not defined for object stores, they have no proper notion // of directories assumeNotObjectStore(); final Path file = new Path(getBasePath(), randomName()); createFile(file); try { fs.mkdirs(file); fail("should fail with an IOException"); } catch (IOException e) { // good! } }
assertTrue(fs.mkdirs(directory));
@Test public void testMkdirsFailsWithExistingParentFile() throws Exception { // test is not defined for object stores, they have no proper notion // of directories assumeNotObjectStore(); final Path file = new Path(getBasePath(), randomName()); createFile(file); final Path dirUnderFile = new Path(file, randomName()); try { fs.mkdirs(dirUnderFile); fail("should fail with an IOException"); } catch (IOException e) { // good! } }
@Test public void testMkdirsCreatesParentDirectories() throws Exception { // this test applies to object stores as well, as rely on the fact that they // return true when things are not bad final Path directory = new Path(new Path(new Path(basePath, randomName()), randomName()), randomName()); assertTrue(fs.mkdirs(directory)); if (getFileSystemKind() != FileSystemKind.OBJECT_STORE) { assertTrue(fs.exists(directory)); } }