if (priorDiff != null && priorDiff.getSnapshotId() == prior) { priorChildrenDiff = priorDiff.getChildrenDiff(); priorChildrenDiff.destroyCreatedList(reclaimContext, dir);
INodeDirectory dir) { final List<DirectoryDiff> subList = new ArrayList<>(); final int toSnapshotId = get(toIndex - 1).getSnapshotId(); for (SkipListNode current = getNode(fromIndex); current != null;) { SkipListNode next = null; for (int level = current.level(); level >= 0; level--) { next = current.getSkipNode(level); if (next != null && next.getDiff().compareTo(toSnapshotId) <= 0) { childrenDiff = current.getChildrenDiff(level); break; new DirectoryDiff(curDiff.getSnapshotId(), dir, childrenDiff)); if (current.getDiff().compareTo(toSnapshotId) == 0) { break;
/** Used to record the modification of a symlink node */ public INode saveChild2Snapshot(INodeDirectory currentINode, final INode child, final int latestSnapshotId, final INode snapshotCopy) { Preconditions.checkArgument(!child.isDirectory(), "child is a directory, child=%s", child); Preconditions.checkArgument(latestSnapshotId != Snapshot.CURRENT_STATE_ID); final DirectoryDiff diff = diffs.checkAndAddLatestSnapshotDiff( latestSnapshotId, currentINode); if (diff.getChild(child.getLocalNameBytes(), false, currentINode) != null) { // it was already saved in the latest snapshot earlier. return child; } diff.diff.modify(snapshotCopy, child); return child; }
Snapshot s1 = sdir1Node.getSnapshot(DFSUtil.string2Bytes("s1")); assertEquals(s2222.getId(), fooDiffs.get(3).getSnapshotId()); assertEquals(s333.getId(), fooDiffs.get(2).getSnapshotId()); assertEquals(s22.getId(), fooDiffs.get(1).getSnapshotId()); assertEquals(s1.getId(), fooDiffs.get(0).getSnapshotId()); INodeFile bar1 = fsdir.getINode4Write(bar1_dir1.toString()).asFile(); List<FileDiff> bar1Diffs = bar1.getDiffs().asList(); fooDiffs = foo.getDiffs().asList(); assertEquals(4, fooDiffs.size()); assertEquals(s2222.getId(), fooDiffs.get(3).getSnapshotId()); bar1Diffs = bar1.getDiffs().asList(); assertEquals(3, bar1Diffs.size());
diffInPb.getDeletedINodeList(), diffInPb.getDeletedINodeRefList()); DirectoryDiff diff = new DirectoryDiff(snapshotId, copy, null, childrenSize, clist, dlist, useRoot); diffs.addFirst(diff);
if (priorDiff != null && priorDiff.getSnapshotId() == prior) { List<INode> cList = priorDiff.diff.getList(ListType.CREATED); List<INode> dList = priorDiff.diff.getList(ListType.DELETED); if (priorDiff != null && priorDiff.getSnapshotId() == prior) { for (INode cNode : priorDiff.getChildrenDiff().getList( ListType.CREATED)) { if (priorCreated.containsKey(cNode)) { for (INode dNode : priorDiff.getChildrenDiff().getList( ListType.DELETED)) { if (priorDeleted == null || !priorDeleted.containsKey(dNode)) {
assertEquals(1, diffList.size()); DirectoryDiff diff = diffList.get(0); assertTrue(diff.getChildrenDiff().getList(ListType.CREATED).isEmpty()); assertTrue(diff.getChildrenDiff().getList(ListType.DELETED).isEmpty()); assertEquals(1, diffList.size()); diff = diffList.get(0); assertTrue(diff.getChildrenDiff().getList(ListType.CREATED).isEmpty()); assertTrue(diff.getChildrenDiff().getList(ListType.DELETED).isEmpty());
DirectoryDiffList diffList = dirNode.getDiffs(); assertEquals(1, diffList.asList().size()); assertEquals(snapshot1.getId(), diffList.getLast().getSnapshotId()); diffList = fsdir.getINode(metaChangeDir.toString()).asDirectory() .getDiffs();
diffInPb.getDeletedINodeList(), diffInPb.getDeletedINodeRefList()); DirectoryDiff diff = new DirectoryDiff(snapshotId, copy, null, childrenSize, clist, dlist, useRoot); diffs.addFirst(diff);
List<DirectoryDiff> dir1DiffList = dir1Node.getDiffs().asList(); assertEquals(1, dir1DiffList.size()); List<INode> dList = dir1DiffList.get(0).getChildrenDiff() .getList(ListType.DELETED); assertTrue(dList.isEmpty()); List<INode> cList = dir1DiffList.get(0).getChildrenDiff() .getList(ListType.CREATED); assertEquals(1, cList.size()); .asDirectory(); Snapshot s0 = testNode.getSnapshot(DFSUtil.string2Bytes("s0")); assertEquals(s0.getId(), diff.getSnapshotId()); assertEquals("file", diff.getChildrenDiff().getList(ListType.DELETED) .get(0).getLocalName()); dList = dir2DiffList.get(0).getChildrenDiff().getList(ListType.DELETED); assertEquals(1, dList.size()); final Path foo_s2 = SnapshotTestHelper.getSnapshotPath(dir2, "s2",
if (priorDiff != null && priorDiff.getSnapshotId() == prior) { priorChildrenDiff = priorDiff.getChildrenDiff(); counts.add(priorChildrenDiff.destroyCreatedList(bsps, dir, collectedBlocks, removedINodes));
List<DirectoryDiff> diffs = fooDir.getDiffs().asList(); assertEquals(1, diffs.size()); assertEquals(s2.getId(), diffs.get(0).getSnapshotId());
assertEquals(1, diffList.size()); Snapshot s1 = dir1Node.getSnapshot(DFSUtil.string2Bytes("s1")); assertEquals(s1.getId(), diffList.get(0).getSnapshotId()); ChildrenDiff diff = diffList.get(0).getChildrenDiff(); assertEquals(0, diff.getList(ListType.CREATED).size()); assertEquals(0, diff.getList(ListType.DELETED).size());
List<DirectoryDiff> dir2Diffs = dir2Node.getDiffs().asList(); assertEquals(1, dir2Diffs.size()); assertEquals(s2.getId(), dir2Diffs.get(0).getSnapshotId()); ChildrenDiff childrenDiff = dir2Diffs.get(0).getChildrenDiff(); assertEquals(0, childrenDiff.getList(ListType.DELETED).size()); assertEquals(1, childrenDiff.getList(ListType.CREATED).size()); List<DirectoryDiff> fooDiffs = fooNode.asDirectory().getDiffs().asList(); assertEquals(1, fooDiffs.size()); assertEquals(s1.getId(), fooDiffs.get(0).getSnapshotId()); dir2Diffs = dir2Node.getDiffs().asList(); assertEquals(2, dir2Diffs.size()); assertEquals(s2.getId(), dir2Diffs.get(0).getSnapshotId()); assertEquals(s3.getId(), dir2Diffs.get(1).getSnapshotId()); childrenDiff = dir2Diffs.get(0).getChildrenDiff(); assertEquals(0, childrenDiff.getList(ListType.DELETED).size()); assertEquals(1, childrenDiff.getList(ListType.CREATED).size()); assertTrue(childrenDiff.getList(ListType.CREATED).get(0) == fooNode); childrenDiff = dir2Diffs.get(1).getChildrenDiff(); assertEquals(0, childrenDiff.getList(ListType.DELETED).size()); assertEquals(0, childrenDiff.getList(ListType.CREATED).size()); fooDiffs = fooNode.asDirectory().getDiffs().asList(); assertEquals(2, fooDiffs.size()); assertEquals(s1.getId(), fooDiffs.get(0).getSnapshotId()); assertEquals(s3.getId(), fooDiffs.get(1).getSnapshotId());
if (priorDiff != null && priorDiff.getSnapshotId() == prior) { priorChildrenDiff = priorDiff.getChildrenDiff(); counts.add(priorChildrenDiff.destroyCreatedList(bsps, dir, collectedBlocks, removedINodes));
assertEquals(1, diffList.size()); Snapshot s1 = dir1Node.getSnapshot(DFSUtil.string2Bytes("s1")); assertEquals(s1.getId(), diffList.get(0).getSnapshotId()); ChildrenDiff diff = diffList.get(0).getChildrenDiff();
assertEquals(s1.getId(), diff.getSnapshotId()); assertTrue(diff.getChildrenDiff().getList(ListType.DELETED).isEmpty()); assertTrue(diff.getChildrenDiff().getList(ListType.CREATED).isEmpty());
List<DirectoryDiff> dir1Diffs = dir1Node.getDiffs().asList(); assertEquals(1, dir1Diffs.size()); assertEquals(s1.getId(), dir1Diffs.get(0).getSnapshotId()); ChildrenDiff childrenDiff = dir1Diffs.get(0).getChildrenDiff(); assertEquals(0, childrenDiff.getList(ListType.DELETED).size()); assertEquals(1, childrenDiff.getList(ListType.CREATED).size());
if (priorDiff != null && priorDiff.getSnapshotId() == prior) { List<INode> cList = priorDiff.diff.getList(ListType.CREATED); List<INode> dList = priorDiff.diff.getList(ListType.DELETED); if (priorDiff != null && priorDiff.getSnapshotId() == prior) { for (INode cNode : priorDiff.getChildrenDiff().getList( ListType.CREATED)) { if (priorCreated.containsKey(cNode)) { for (INode dNode : priorDiff.getChildrenDiff().getList( ListType.DELETED)) { if (priorDeleted == null || !priorDeleted.containsKey(dNode)) {
assertEquals(1, diffList.size()); DirectoryDiff diff = diffList.get(0); assertTrue(diff.getChildrenDiff().getList(ListType.CREATED).isEmpty()); assertTrue(diff.getChildrenDiff().getList(ListType.DELETED).isEmpty()); assertEquals(1, diffList.size()); diff = diffList.get(0); assertTrue(diff.getChildrenDiff().getList(ListType.CREATED).isEmpty()); assertTrue(diff.getChildrenDiff().getList(ListType.DELETED).isEmpty());