/** {@inheritDoc} */ @SuppressWarnings("ConstantConditions") @Override public Map<String, String> properties(String path) { return igfsEx.info(new IgfsPath(path)).properties(); }
/** * 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)); }
IgniteUuid.randomUuid(), null, status.properties(), status.accessTime(), status.modificationTime() null, igfsCtx.igfs().evictExclude(curPath, false), status.properties(), status.accessTime(), status.modificationTime()
/** * A copy constructor. All the fields are copied from the copied {@code igfsFile}, but the {@code groupBlockSize} * which is specified separately. * * @param igfsFile The file to copy. * @param grpBlockSize Group block size. */ public IgfsFileImpl(IgfsFile igfsFile, long grpBlockSize) { A.notNull(igfsFile, "igfsFile"); this.path = igfsFile.path(); this.fileId = igfsFile instanceof IgfsFileImpl ? ((IgfsFileImpl)igfsFile).fileId : IgniteUuid.randomUuid(); this.blockSize = igfsFile.blockSize(); this.len = igfsFile.length(); this.grpBlockSize = igfsFile.isFile() ? grpBlockSize : 0L; this.props = igfsFile.properties(); this.accessTime = igfsFile.accessTime(); this.modificationTime = igfsFile.modificationTime(); this.flags = IgfsUtils.flags(igfsFile.isDirectory(), igfsFile.isFile()); }
/** * 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)); } }
/** * Test properties set on missing directory. * * @throws Exception If failed. */ @Test public void testSetPropertiesOnMissingDirectory() throws Exception { if (!propertiesSupported()) return; Map<String, String> propsDir = properties("ownerDir", "groupDir", "0555"); Map<String, String> propsSubDir = properties("ownerSubDir", "groupSubDir", "0666"); create(igfsSecondary, paths(DIR, SUBDIR), null); create(igfs, null, null); igfsSecondaryFileSystem.update(DIR, propsDir); igfsSecondaryFileSystem.update(SUBDIR, propsSubDir); // Ensure properties propagation of the created directories. assertEquals(propsDir, igfs.info(DIR).properties()); assertEquals(propsSubDir, igfs.info(SUBDIR).properties()); }
/** * 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)); } }
/** * 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)); } }
createFileLockId(false), igfsCtx.igfs().evictExclude(path, false), status.properties(), status.accessTime(), status.modificationTime()
/** * Test properties management in meta-cache. * * @throws Exception If failed. */ @Test public void testUpdateProperties() throws Exception { IgfsPath p = path("/tmp/my"); igfs.mkdirs(p); Map<String, String> oldProps = igfs.info(p).properties(); igfs.update(p, F.asMap("a", "1")); igfs.update(p, F.asMap("b", "2")); assertEquals("1", igfs.info(p).property("a")); assertEquals("2", igfs.info(p).property("b")); igfs.update(p, F.asMap("b", "3")); Map<String, String> expProps = new HashMap<>(oldProps); expProps.put("a", "1"); expProps.put("b", "3"); assertEquals("3", igfs.info(p).property("b")); assertEquals(expProps, igfs.info(p).properties()); assertEquals("5", igfs.info(p).property("c", "5")); assertUpdatePropertiesFails(null, null, NullPointerException.class, "Ouch! Argument cannot be null"); assertUpdatePropertiesFails(p, null, NullPointerException.class, "Ouch! Argument cannot be null"); assertUpdatePropertiesFails(null, F.asMap("x", "9"), NullPointerException.class, "Ouch! Argument cannot be null"); assertUpdatePropertiesFails(p, Collections.<String, String>emptyMap(), IllegalArgumentException.class, "Ouch! Argument is invalid"); }
/** * Test properties set on partially missing directory. * * @throws Exception If failed. */ @Test public void testSetPropertiesOnPartiallyMissingDirectory() throws Exception { if (!propertiesSupported()) return; Map<String, String> props = properties("owner", "group", "0555"); create(igfsSecondary, paths(DIR, SUBDIR), null); create(igfs, paths(DIR), null); igfsSecondaryFileSystem.update(SUBDIR, props); // Ensure properties propagation of the created subdirectory. assertEquals(props, igfs.info(SUBDIR).properties()); }
/** * 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 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 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()); }
/** * 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)); }
igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION));
IgniteUuid.randomUuid(), null, status.properties(), status.accessTime(), status.modificationTime() null, igfsCtx.igfs().evictExclude(curPath, false), status.properties(), status.accessTime(), status.modificationTime()
/** * A copy constructor. All the fields are copied from the copied {@code igfsFile}, but the {@code groupBlockSize} * which is specified separately. * * @param igfsFile The file to copy. * @param grpBlockSize Group block size. */ public IgfsFileImpl(IgfsFile igfsFile, long grpBlockSize) { A.notNull(igfsFile, "igfsFile"); this.path = igfsFile.path(); this.fileId = igfsFile instanceof IgfsFileImpl ? ((IgfsFileImpl)igfsFile).fileId : IgniteUuid.randomUuid(); this.blockSize = igfsFile.blockSize(); this.len = igfsFile.length(); this.grpBlockSize = igfsFile.isFile() ? grpBlockSize : 0L; this.props = igfsFile.properties(); this.accessTime = igfsFile.accessTime(); this.modificationTime = igfsFile.modificationTime(); this.flags = IgfsUtils.flags(igfsFile.isDirectory(), igfsFile.isFile()); }
createFileLockId(false), igfsCtx.igfs().evictExclude(path, false), status.properties(), status.accessTime(), status.modificationTime()