@Override public Object call() throws Exception { for (int cur = cnt.incrementAndGet(); cur < max; cur = cnt.incrementAndGet()) { IgfsFile info = igfs.info(path(cur)); assertNotNull("Expects file exist: " + cur, info); assertTrue("Expects file is a directory: " + cur, info.isDirectory()); } return null; } }, threads, "grid-test-check-directories-exist");
/** * Dump IGFS content. * * @param igfs IGFS. * @param path Path. * @throws Exception If failed. */ private static void dumpIgfs(IgniteFileSystem igfs, IgfsPath path) throws Exception { IgfsFile file = igfs.info(path); assert file != null; System.out.println(file.path()); if (file.isDirectory()) { for (IgfsPath child : igfs.listPaths(path)) dumpIgfs(igfs, child); } else { try (BufferedReader br = new BufferedReader(new InputStreamReader(igfs.open(path)))) { String line = br.readLine(); while (line != null) { System.out.println(line); line = br.readLine(); } } } }
if (!status.isDirectory() && !curPath.equals(endPath)) throw new IgniteCheckedException("Failed to create path the locally because secondary file " + "system directory structure was modified concurrently and the path is not a directory as " + IgfsEntryInfo curInfo = status.isDirectory() ? IgfsUtils.createDirectory( IgniteUuid.randomUuid(),
/** * Convert IGFS file information into Hadoop file status. * * @param file IGFS file information. * @return Hadoop file status. */ private FileStatus convert(IgfsFile file) { return new FileStatus( file.length(), file.isDirectory(), dfltReplication, file.groupBlockSize(), file.modificationTime(), file.accessTime(), permission(file), file.property(IgfsUtils.PROP_USER_NAME, user), file.property(IgfsUtils.PROP_GROUP_NAME, "users"), convert(file.path())) { @Override public String toString() { return "FileStatus [path=" + getPath() + ", isDir=" + isDirectory() + ", len=" + getLen() + "]"; } }; }
/** * 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()); }
/** * Convert IGFS file information into Hadoop file status. * * @param file IGFS file information. * @return Hadoop file status. */ @SuppressWarnings("deprecation") private FileStatus convert(IgfsFile file) { return new FileStatus( file.length(), file.isDirectory(), getDefaultReplication(), file.groupBlockSize(), file.modificationTime(), file.accessTime(), permission(file), file.property(IgfsUtils.PROP_USER_NAME, user), file.property(IgfsUtils.PROP_GROUP_NAME, "users"), convert(file.path())) { @Override public String toString() { return "FileStatus [path=" + getPath() + ", isDir=" + isDir() + ", len=" + getLen() + ", mtime=" + getModificationTime() + ", atime=" + getAccessTime() + ']'; } }; }
/** * Calculates size of directory or file for given ID. * * @param file IGFS File object. * @param sum Summary object that will collect information. * @throws IgniteCheckedException If failed. */ private void summaryRecursive(IgfsFile file, IgfsPathSummary sum) throws IgniteCheckedException { assert file != null; assert sum != null; if (file.isDirectory()) { if (!F.eq(IgfsPath.ROOT, file.path())) sum.directoriesCount(sum.directoriesCount() + 1); for (IgfsFile childFile : listFiles(file.path())) summaryRecursive(childFile, sum); } else { sum.filesCount(sum.filesCount() + 1); sum.totalLength(sum.totalLength() + file.length()); } }
/** * * @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()); }
throw fsException("Failed to open output stream to the file created in " + "the secondary file system because it no longer exists: " + path); else if (status.isDirectory()) throw fsException("Failed to open output stream to the file created in " + "the secondary file system because the path points to a directory: " + path);
assertEquals("Type", false, desc.isDirectory());
assert igfs.info(new IgfsPath("/x/y")).isDirectory();
assert igfs.info(new IgfsPath("/x/y")).isDirectory(); try { try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/x/y"), true)) {
if (!status.isDirectory() && !curPath.equals(endPath)) throw new IgniteCheckedException("Failed to create path the locally because secondary file " + "system directory structure was modified concurrently and the path is not a directory as " + IgfsEntryInfo curInfo = status.isDirectory() ? IgfsUtils.createDirectory( IgniteUuid.randomUuid(),
/** * 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()); }
/** * Calculates size of directory or file for given ID. * * @param file IGFS File object. * @param sum Summary object that will collect information. * @throws IgniteCheckedException If failed. */ private void summaryRecursive(IgfsFile file, IgfsPathSummary sum) throws IgniteCheckedException { assert file != null; assert sum != null; if (file.isDirectory()) { if (!F.eq(IgfsPath.ROOT, file.path())) sum.directoriesCount(sum.directoriesCount() + 1); for (IgfsFile childFile : listFiles(file.path())) summaryRecursive(childFile, sum); } else { sum.filesCount(sum.filesCount() + 1); sum.totalLength(sum.totalLength() + file.length()); } }
throw fsException("Failed to open output stream to the file created in " + "the secondary file system because it no longer exists: " + path); else if (status.isDirectory()) throw fsException("Failed to open output stream to the file created in " + "the secondary file system because the path points to a directory: " + path);