/** {@inheritDoc} */ @Nullable @Override public IgfsFile info(IgfsPath path) { return igfs.info(path); }
/** * Get summary for path. * * @param path Path. * @return Summary. * @throws IgniteCheckedException If failed. */ private IgfsPathSummary summary0(IgfsPath path) throws IgniteCheckedException { IgfsFile info = info(path); if (info == null) throw new IgfsPathNotFoundException("Failed to get path summary (path not found): " + path); IgfsPathSummary sum = new IgfsPathSummary(path); summaryRecursive(info, sum); return sum; }
/** * Test info routine when the path doesn't exist remotely. * * @throws Exception If failed. */ @Test public void testInfoPathDoesNotExist() throws Exception { IgfsFile info = null; try { info = igfs.info(DIR); } catch (IgniteException ignore) { // No-op. } assert info == null; }
/** * 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)); }
/** * Test info routine when the path exists both locally and remotely. * * @throws Exception If failed. */ @Test public void testInfo() throws Exception { create(igfs, paths(DIR), null); IgfsFile info = igfs.info(DIR); assert info != null; assertEquals(DIR, info.path()); }
/** * Test info routine when the path doesn't exist locally. * * @throws Exception If failed. */ @Test public void testInfoPathMissing() throws Exception { create(igfsSecondary, paths(DIR), null); create(igfs, null, null); IgfsFile info = igfs.info(DIR); assert info != null; assertEquals(DIR, info.path()); }
/** * 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)); } }
/** * * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") @Test public void testListPathForSymlink() throws Exception { if (U.isWindows()) return; createSymlinks(); assertTrue(igfs.info(DIR).isDirectory()); Collection<IgfsPath> pathes = igfs.listPaths(DIR); Collection<IgfsFile> files = igfs.listFiles(DIR); assertEquals(1, pathes.size()); assertEquals(1, files.size()); assertEquals("filedest", F.first(pathes).name()); assertEquals("filedest", F.first(files).path().name()); }
/** * * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") @Test public void testListPathForSymlink() throws Exception { if (U.isWindows()) return; createSymlinks(); assertTrue(igfs.info(DIR).isDirectory()); Collection<IgfsPath> pathes = igfs.listPaths(DIR); Collection<IgfsFile> files = igfs.listFiles(DIR); assertEquals(1, pathes.size()); assertEquals(1, files.size()); assertEquals("filedest", F.first(pathes).name()); assertEquals("filedest", F.first(files).path().name()); }
/** * Ensure that a DUAL mode file is not propagated to eviction policy * * @throws Exception If failed. */ @Test public void testFileDualExclusion() throws Exception { start(); evictPlc.setExcludePaths(Collections.singleton(FILE_RMT.toString())); // Create file in primary mode. It must not be propagated to eviction policy. igfsPrimary.create(FILE_RMT, true).close(); checkEvictionPolicy(0, 0); int blockSize = igfsPrimary.info(FILE_RMT).blockSize(); append(FILE_RMT, blockSize); checkEvictionPolicy(0, 0); read(FILE_RMT, 0, blockSize); checkEvictionPolicy(0, 0); }
/** * 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 how evictions are handled for a file working in PRIMARY mode. * * @throws Exception If failed. */ @Test public void testFilePrimary() throws Exception { start(); // Create file in primary mode. It must not be propagated to eviction policy. igfsPrimary.create(FILE, true).close(); checkEvictionPolicy(0, 0); int blockSize = igfsPrimary.info(FILE).blockSize(); append(FILE, blockSize); checkEvictionPolicy(0, 0); read(FILE, 0, blockSize); checkEvictionPolicy(0, 0); }
/** * 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()); }
/** * @throws Exception If failed. */ @Test public void testAffinity() throws Exception { long fileSize = 32L * 1024 * 1024; IgfsPath filePath = new IgfsPath("/file"); try (OutputStream os = igfs.create(filePath, true)) { for(int i = 0; i < fileSize / chunk.length; ++i) os.write(chunk); } long len = igfs.info(filePath).length(); int start = 0; // Check default maxLen (maxLen = 0) for (int i = 0; i < igfs.context().data().groupBlockSize() / 1024; i++) { Collection<IgfsBlockLocation> blocks = igfs.affinity(filePath, start, len); assertEquals(F.first(blocks).start(), start); assertEquals(start + len, F.last(blocks).start() + F.last(blocks).length()); len -= 1024 * 2; start += 1024; } }
/** * 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 how evictions are handled for a file working in PRIMARY mode. * * @throws Exception If failed. */ @Test public void testFileDual() throws Exception { start(); igfsPrimary.create(FILE_RMT, true).close(); checkEvictionPolicy(0, 0); int blockSize = igfsPrimary.info(FILE_RMT).blockSize(); // File write. append(FILE_RMT, blockSize); checkEvictionPolicy(1, blockSize); // One more write. append(FILE_RMT, blockSize); checkEvictionPolicy(2, blockSize * 2); // Read. read(FILE_RMT, 0, blockSize); checkEvictionPolicy(2, blockSize * 2); }