/** * Get parent entity. * * @return Parent entity. */ public IgfsPathIds parent() { assert ids.length > 1; String[] parentParts = new String[parts.length - 1]; IgniteUuid[] parentIds = new IgniteUuid[ids.length - 1]; System.arraycopy(parts, 0, parentParts, 0, parentParts.length); System.arraycopy(ids, 0, parentIds, 0, parentIds.length); return new IgfsPathIds(path.parent(), parentParts, parentIds); }
@Override public Boolean onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception { fs.mkdirs(path, props); assert !infos.isEmpty(); // Now perform synchronization again starting with the last created parent. IgfsPath parentPath = null; for (IgfsPath curPath : infos.keySet()) { if (parentPath == null || curPath.isSubDirectoryOf(parentPath)) parentPath = curPath; } assert parentPath != null; IgfsEntryInfo parentPathInfo = infos.get(parentPath); synchronize(fs, parentPath, parentPathInfo, path, true, null); if (evts.isRecordable(EventType.EVT_IGFS_DIR_CREATED)) { IgfsPath evtPath = path; while (!parentPath.equals(evtPath)) { pendingEvts.addFirst(new IgfsEvent(evtPath, locNode, EventType.EVT_IGFS_DIR_CREATED)); evtPath = evtPath.parent(); assert evtPath != null; // If this fails, then ROOT does not exist. } } return true; }
@Override public Object call() throws Exception { int id = cnt.incrementAndGet(); IgfsPath f = new IgfsPath(path.parent(), "asdf" + (id > 1 ? "-" + id : "")); try (IgfsOutputStream out = fs.create(f, 0, true, null, 0, 1024, null)) { assertNotNull(out); cleanUp.add(f); // Add all created into cleanup list. U.copy(new IgfsTestInputStream(size, salt), out); } return null; } }, WRITING_THREADS_CNT, "perform-multi-thread-writing");
assert dest != null; if (src.parent() == null) return false; // Root directory cannot be renamed.
/** * Validate parent resolution is correct. * * @param child Child path. * @param parent Expected parent path. */ private void validateParent(String child, @Nullable String parent) { assertEquals(parent == null ? null : new IgfsPath(parent), new IgfsPath(child).parent()); }
@Override public Boolean onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception { IgfsEntryInfo srcInfo = infos.get(src); IgfsEntryInfo srcParentInfo = infos.get(src.parent()); IgfsEntryInfo destInfo = infos.get(dest); IgfsEntryInfo destParentInfo = dest.parent() != null ? infos.get(dest.parent()) : null;
dualParentsContainingPrimaryChildren.add(mode.getKey().parent());
created.put(curPath.parent(), parentInfo);
"found: " + dstPath.parent());
igfs.delete(dir.parent(), false); // Will generate no events.
if (src.parent() == null) throw new IgfsInvalidPathException("Root directory cannot be renamed.");
/** * Test public methods of igfs path. * * @throws Exception In case of any exception. */ @Test public void testMethods() throws Exception { IgfsPath path = new IgfsPath("/a/s/d/f"); validateParent("/a/s/d/f", "/a/s/d"); validateParent("/a/s/d", "/a/s"); validateParent("/a/s", "/a"); validateParent("/a", "/"); validateParent("/", null); assertEquals(new IgfsPath("/a/s/d/f-2"), path.suffix("-2")); assertEquals(Arrays.asList("a", "s", "d", "f"), path.components()); assertEquals(4, path.depth()); assertEquals(3, path.parent().depth()); assertEquals("f", path.name()); assertEquals(path, mu(path)); IgfsPath parent = path.parent(); assertTrue(path.compareTo(new IgfsPath(parent, "e")) > 0); assertTrue(path.compareTo(new IgfsPath(parent, "g")) < 0); }
assertTrue(igfs.delete(dir.parent(), true));
/** * Checks file access & modification time equality in the file itself and in the same file found through * the listing of its parent. * * @param fs The file system. * @param p The file path. * * @return Tuple of access and modification times of the file. */ private T2<Long, Long> checkParentListingTime(IgfsSecondaryFileSystem fs, IgfsPath p) { IgfsFile f0 = fs.info(p); T2<Long, Long> t0 = new T2<>(f0.accessTime(), f0.modificationTime()); // Root cannot be seen through the parent listing: if (!F.eq(IgfsPath.ROOT, p)) { assertNotNull(f0); Collection<IgfsFile> listing = fs.listFiles(p.parent()); IgfsFile f1 = null; for (IgfsFile fi : listing) { if (F.eq(fi.path(), p)) { f1 = fi; break; } } assertNotNull(f1); // file should be found in parent listing. T2<Long, Long> t1 = new T2<>(f1.accessTime(), f1.modificationTime()); assertEquals(t0, t1); } return t0; }
/** * Get parent entity. * * @return Parent entity. */ public IgfsPathIds parent() { assert ids.length > 1; String[] parentParts = new String[parts.length - 1]; IgniteUuid[] parentIds = new IgniteUuid[ids.length - 1]; System.arraycopy(parts, 0, parentParts, 0, parentParts.length); System.arraycopy(ids, 0, parentIds, 0, parentIds.length); return new IgfsPathIds(path.parent(), parentParts, parentIds); }