/** {@inheritDoc} */ @Override public void mkdirs(IgfsPath path) { igfs.mkdirs(path); }
/** {@inheritDoc} */ @Override public void mkdirs(IgfsPath path) { mkdirs(path, null); }
/** {@inheritDoc} */ @Override public void mkdirs(IgfsPath path, @Nullable Map<String, String> props) { igfs.mkdirs(path, props); }
@Override public Boolean call() throws Exception { U.awaitQuiet(barrier); try { igfs.mkdirs(SUBSUBDIR); } catch (IgniteException ignored) { return false; } return true; } });
@Override public void run() { try { int lvl = rand.nextInt(lvlCnt) + 1; IgfsPath parentPath = dirPaths.get(lvl).get(rand.nextInt(dirPaths.get(lvl).size())); IgfsPath path = new IgfsPath(parentPath, "newDir-" + dirCtr.incrementAndGet()); U.awaitQuiet(barrier); igfs.mkdirs(path); } catch (IgniteException ignore) { // No-op. } } };
/** * * @throws Exception If failed. */ @Test public void testMkdirsInsideSymlink() throws Exception { if (U.isWindows()) return; createSymlinks(); igfs.mkdirs(SUBSUBDIR); assertTrue(Files.isDirectory(dirLinkDest.toPath().resolve("subdir/subsubdir"))); assertTrue(Files.isDirectory(dirLinkSrc.toPath().resolve("subdir/subsubdir"))); }
/** * * @throws Exception If failed. */ @Test public void testMkdirsInsideSymlink() throws Exception { if (U.isWindows()) return; createSymlinks(); igfs.mkdirs(SUBSUBDIR); assertTrue(Files.isDirectory(dirLinkDest.toPath().resolve("subdir/subsubdir"))); assertTrue(Files.isDirectory(dirLinkSrc.toPath().resolve("subdir/subsubdir"))); }
/** * Create the given directories and files in the given IGFS. * * @param igfs IGFS. * @param dirs Directories. * @param files Files. * @throws Exception If failed. */ @SuppressWarnings("EmptyTryBlock") public static void create(IgfsImpl igfs, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files) throws Exception { if (dirs != null) { for (IgfsPath dir : dirs) igfs.mkdirs(dir); } if (files != null) { for (IgfsPath file : files) { try (OutputStream ignored = igfs.create(file, true)) { // No-op. } igfs.await(file); } } }
@Override public void apply(Integer level, IgfsPath levelDir) { try { for (int i = 0; i < FILES_COUNT; ++i) { IgfsPath filePath = new IgfsPath(levelDir, "file" + Integer.toString(i)); createFile(igfs, filePath, true, chunk); totalSize.getAndAdd(chunk.length); } if (level < DIRS_MAX_DEEP) { for (int dir = 0; dir < DIRS_COUNT; dir++) { IgfsPath dirPath = new IgfsPath(levelDir, "dir" + Integer.toString(dir)); igfs.mkdirs(dirPath); apply(level + 1, dirPath); } } } catch (Exception e) { fail(e.getMessage()); } } };
@Override public void apply(Integer level, IgfsPath levelDir) { try { for (int i = 0; i < FILES_COUNT; ++i) { IgfsPath filePath = new IgfsPath(levelDir, "file" + Integer.toString(i)); createFile(igfs, filePath, true, chunk); totalSize.getAndAdd(chunk.length); } if (level < DIRS_MAX_DEEP) { for (int dir = 0; dir < DIRS_COUNT; dir++) { IgfsPath dirPath = new IgfsPath(levelDir, "dir" + Integer.toString(dir)); igfs.mkdirs(dirPath); apply(level + 1, dirPath); } } } catch (Exception e) { fail(e.getMessage()); } } };
/** * Test mkdirs in case parent is the root directory. * * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") @Test public void testMkdirsParentRoot() throws Exception { Map<String, String> props = null; if (permissionsSupported()) props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info. igfs.mkdirs(DIR, props); checkExist(igfs, igfsSecondary, DIR); if (permissionsSupported()) { if (dual) // check permission only since Hadoop Fs will always have user and group: assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfsSecondary.permissions(DIR.toString())); // We check only permission because IGFS client adds username and group name explicitly. assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfs.info(DIR).properties().get(IgfsUtils.PROP_PERMISSION)); } }
igfs.mkdirs(new IgfsPath("/x"), null); checkExist(igfs, igfsSecondary, new IgfsPath("/x")); igfs.mkdirs(new IgfsPath("/k/l"), null); checkExist(igfs, igfsSecondary, new IgfsPath("/k/l")); igfs.mkdirs(new IgfsPath("/x/y"), null); checkExist(igfs, igfsSecondary, new IgfsPath("/x/y")); igfs.mkdirs(new IgfsPath("/a/b/c/d"), null); checkExist(igfs, igfsSecondary, new IgfsPath("/a/b/c/d")); igfs.mkdirs(new IgfsPath("/a/b/c/d/e"), null); checkExist(igfs, igfsSecondary, new IgfsPath("/a/b/c/d/e")); igfs.mkdirs(new IgfsPath("/d/f"), null); igfs.mkdirs(new IgfsPath("/d/f/something/else"), null); igfs.mkdirs(SUBSUBDIR, props);
/** * * @throws Exception If failed. */ @Test public void testSecondarySize() throws Exception { igfs.mkdirs(SUBDIR); createFile(igfsSecondary, FILE, chunk); createFile(igfsSecondary, new IgfsPath(SUBDIR, "file2"), chunk); assertEquals(chunk.length, igfs.size(FILE)); assertEquals(chunk.length * 2, igfs.size(SUBDIR)); }
/** * Test mkdirs in case parent exists remotely, but some part of the parent path doesn't exist locally. * * @throws Exception If failed. */ @Test public void testMkdirsParentPathMissingPartially() throws Exception { Map<String, String> props = null; if (permissionsSupported()) props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info. create(igfsSecondary, paths(DIR, SUBDIR), null); create(igfs, paths(DIR), null); igfs.mkdirs(SUBSUBDIR, props); // Ensure that directory was created and properties are propagated. checkExist(igfs, SUBDIR); checkExist(igfs, igfsSecondary, SUBSUBDIR); if (permissionsSupported()) { // Check only permissions because user and group will always be present in Hadoop secondary filesystem. assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfsSecondary.permissions(SUBSUBDIR.toString())); // We check only permission because IGFS client adds username and group name explicitly. assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION)); } }
/** * Test mkdirs in case parent exists remotely, but no parents exist locally. * * @throws Exception If failed. */ @Test public void testMkdrisParentPathMissing() throws Exception { Map<String, String> props = null; if (permissionsSupported()) props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info. create(igfsSecondary, paths(DIR, SUBDIR), null); create(igfs, null, null); igfs.mkdirs(SUBSUBDIR, props); // Ensure that directory was created and properties are propagated. checkExist(igfs, DIR); checkExist(igfs, SUBDIR); checkExist(igfs, igfsSecondary, SUBSUBDIR); if (permissionsSupported()) { // Check only permission because in case of Hadoop secondary Fs user and group will always be present: assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfsSecondary.permissions(SUBSUBDIR.toString())); // We check only permission because IGFS client adds username and group name explicitly. assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION)); } }
igfs.mkdirs(dir); // Will generate 2 EVT_IGFS_DIR_RENAMED events.
igfs.mkdirs(dir); // Will generate 2 EVT_IGFS_DIR_CREATED events.
igfs.mkdirs(dir); // Will generate EVT_IGFS_DIR_CREATED.
igfs.mkdirs(dir);
assert igfs.info(new IgfsPath("/k/l")).isFile(); igfs.mkdirs(new IgfsPath("/x/y"), null); try { try (IgfsOutputStream os = igfs.create(new IgfsPath("/x/y"), true)) {}