@Override public void run() { try { int lvl = rand.nextInt(lvlCnt) + 1; IgfsPath path = rand.nextInt(childrenDirPerLvl + childrenFilePerLvl) < childrenDirPerLvl ? dirPaths.get(lvl).get(rand.nextInt(dirPaths.get(lvl).size())) : filePaths.get(lvl).get(rand.nextInt(filePaths.get(lvl).size())); U.awaitQuiet(barrier); igfs.update(path, properties("owner", "group", null)); } catch (IgniteException ignore) { // No-op. } } };
/** * Test update on the file when it was opened for write(create) and is not closed yet. * * @throws Exception If failed. */ @Test public void testCreateUpdateNoClose() throws Exception { if (dual) return; if(!propertiesSupported()) return; Map<String, String> props = properties("owner", "group", "0555"); create(igfs, paths(DIR, SUBDIR), null); IgfsOutputStream os = null; try { os = igfs.create(FILE, true); igfs.update(FILE, props); os.close(); } finally { U.closeQuiet(os); } }
/** * Test update when parent is the root. * * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") @Test public void testUpdateParentRoot() throws Exception { if(!propertiesSupported()) return; Map<String, String> props = properties("owner", "group", "0555"); create(igfs, paths(DIR), null); igfs.update(DIR, props); if (dual) assertEquals(props, igfsSecondary.properties(DIR.toString())); assertEquals(props, igfs.info(DIR).properties()); }
/** * Check that exception is thrown in case the path being updated doesn't exist remotely. * * @throws Exception If failed. */ @Test public void testUpdatePathDoesNotExist() throws Exception { final Map<String, String> props = properties("owner", "group", "0555"); assert igfs.update(SUBDIR, props) == null; checkNotExist(igfs, igfsSecondary, SUBDIR); }
/** * Test update in case both local and remote file systems have the same folder structure. * * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") @Test public void testUpdate() throws Exception { if(!propertiesSupported()) return; Map<String, String> props = properties("owner", "group", "0555"); create(igfs, paths(DIR, SUBDIR), paths(FILE)); igfs.update(FILE, props); if (dual) assertEquals(props, igfsSecondary.properties(FILE.toString())); assertEquals(props, igfs.info(FILE).properties()); }
/** * 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)); } }
return; Map<String, String> props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info.
/** * Test update on the file when it was opened for write(create) and is not closed yet. * * @throws Exception If failed. */ @Test public void testAppendUpdateNoClose() throws Exception { if (dual) return; if (appendSupported()) { Map<String, String> props = properties("owner", "group", "0555"); create(igfs, paths(DIR, SUBDIR), null); createFile(igfs, FILE, false); IgfsOutputStream os = null; try { os = igfs.append(FILE, false); if (permissionsSupported()) igfs.update(FILE, props); os.close(); } finally { U.closeQuiet(os); } } }