/** {@inheritDoc} */ @Nullable @Override public IgfsFile update(IgfsPath path, Map<String, String> props) { return igfs.update(path, props); }
@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. } } };
/** * Check root property update. * * @throws Exception If failed. */ private void checkRootPropertyUpdate(String prop, String setVal, String expGetVal) throws Exception { igfs.update(IgfsPath.ROOT, Collections.singletonMap(prop, setVal)); igfs.clear(); IgfsFile file = igfs.info(IgfsPath.ROOT); assert file != null; Map<String,String> props = file.properties(); assertEquals(expGetVal, props.get(prop)); }
/** * 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 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()); }
/** * 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); } } }
/** * 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 update when parent is the root and the path being updated is missing locally. * * @param props Properties. * @throws Exception If failed. */ protected void doUpdateParentRootPathMissing(Map<String, String> props) throws Exception { if (!propertiesSupported()) return; create(igfsSecondary, paths(DIR), null); create(igfs, null, null); igfs.update(DIR, props); checkExist(igfs, DIR); assertTrue(propertiesContains(igfsSecondary.properties(DIR.toString()), props)); assertTrue(propertiesContains(igfs.info(DIR).properties(), props)); }
/** * Test update in case file exists remotely, but some part of the path doesn't exist locally. * * @throws Exception If failed. */ @Test public void testUpdatePathMissingPartially() throws Exception { if(!propertiesSupported()) return; Map<String, String> propsSubDir = properties("subDirOwner", "subDirGroup", "0555"); Map<String, String> propsFile = properties("fileOwner", "fileGroup", "0666"); create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE)); create(igfs, paths(DIR), null); // Set different properties to the sub-directory. igfsSecondaryFileSystem.update(SUBDIR, propsSubDir); igfs.update(FILE, propsFile); // Ensure missing entries were re-created locally. checkExist(igfs, SUBDIR, FILE); // Ensure properties propagation. assertEquals(propsSubDir, igfsSecondary.properties(SUBDIR.toString())); assertEquals(propsSubDir, igfs.info(SUBDIR).properties()); assertEquals(propsFile, igfsSecondary.properties(FILE.toString())); assertEquals(propsFile, igfs.info(FILE).properties()); }
/** * Test update in case file exists remotely, but neither the file nor all it's parents exist locally. * * @throws Exception If failed. */ @Test public void testUpdatePathMissing() throws Exception { if(!propertiesSupported()) return; Map<String, String> propsSubDir = properties("subDirOwner", "subDirGroup", "0555"); Map<String, String> propsFile = properties("fileOwner", "fileGroup", "0666"); create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE)); create(igfs, null, null); // Set different properties to the sub-directory. igfsSecondaryFileSystem.update(SUBDIR, propsSubDir); igfs.update(FILE, propsFile); // Ensure missing entries were re-created locally. checkExist(igfs, DIR, SUBDIR, FILE); // Ensure properties propagation. assertEquals(propsSubDir, igfsSecondary.properties(SUBDIR.toString())); assertEquals(propsSubDir, igfs.info(SUBDIR).properties()); assertEquals(propsFile, igfsSecondary.properties(FILE.toString())); assertEquals(propsFile, igfs.info(FILE).properties()); }
/** {@inheritDoc} */ @Nullable @Override public IgfsFile update(IgfsPath path, Map<String, String> props) { return igfs.update(path, props); }