@Override public INode getChild(byte[] name, int snapshotId) { return getParent().getChild(name, snapshotId); }
public INode getChild(INodeDirectory currentINode, byte[] name, int snapshotId) { final DirectoryDiff diff = diffs.getDiffById(snapshotId); return diff != null ? diff.getChild(name, true, currentINode) : currentINode.getChild(name, Snapshot.CURRENT_STATE_ID); }
INode curr = parent.getChild(startAfters.get(i), Snapshot.CURRENT_STATE_ID); if (curr == null) {
/** * Search for the given INode in the children list and the deleted lists of * snapshots. * @return {@link Snapshot#CURRENT_STATE_ID} if the inode is in the children * list; {@link Snapshot#NO_SNAPSHOT_ID} if the inode is neither in the * children list nor in any snapshot; otherwise the snapshot id of the * corresponding snapshot diff list. */ public int searchChild(INode inode) { INode child = getChild(inode.getLocalNameBytes(), Snapshot.CURRENT_STATE_ID); if (child != inode) { // inode is not in parent's children list, thus inode must be in // snapshot. identify the snapshot id and later add it into the path DirectoryDiffList diffs = getDiffs(); if (diffs == null) { return Snapshot.NO_SNAPSHOT_ID; } return diffs.findSnapshotDeleted(inode); } else { return Snapshot.CURRENT_STATE_ID; } }
/** @return the child with the given name. */ INode getChild(byte[] name, boolean checkPosterior, INodeDirectory currentDir) { for(DirectoryDiff d = this; ; d = d.getPosterior()) { final Container<INode> returned = d.diff.accessPrevious(name); if (returned != null) { // the diff is able to determine the inode return returned.getElement(); } else if (!checkPosterior) { // Since checkPosterior is false, return null, i.e. not found. return null; } else if (d.getPosterior() == null) { // no more posterior diff, get from current inode. return currentDir.getChild(name, Snapshot.CURRENT_STATE_ID); } } }
/** * Load a node stored in the created list from fsimage. * @param createdNodeName The name of the created node. * @param parent The directory that the created list belongs to. * @return The created node. */ public static INode loadCreated(byte[] createdNodeName, INodeDirectory parent) throws IOException { // the INode in the created list should be a reference to another INode // in posterior SnapshotDiffs or one of the current children for (DirectoryDiff postDiff : parent.getDiffs()) { final INode d = postDiff.getChildrenDiff().getDeleted(createdNodeName); if (d != null) { return d; } // else go to the next SnapshotDiff } // use the current child INode currentChild = parent.getChild(createdNodeName, Snapshot.CURRENT_STATE_ID); if (currentChild == null) { throw new IOException("Cannot find an INode associated with the INode " + DFSUtil.bytes2String(createdNodeName) + " in created list while loading FSImage."); } return currentChild; }
private static INodesInPath dstForRenameTo( INodesInPath srcIIP, INodesInPath dstIIP) throws IOException { INode dstINode = dstIIP.getLastINode(); if (dstINode != null && dstINode.isDirectory()) { byte[] childName = srcIIP.getLastLocalName(); // new dest might exist so look it up. INode childINode = dstINode.asDirectory().getChild( childName, dstIIP.getPathSnapshotId()); dstIIP = INodesInPath.append(dstIIP, childINode, childName); } return dstIIP; }
/** Is this inode in the latest snapshot? */ public final boolean isInLatestSnapshot(final int latestSnapshotId) { if (latestSnapshotId == Snapshot.CURRENT_STATE_ID || latestSnapshotId == Snapshot.NO_SNAPSHOT_ID) { return false; } // if parent is a reference node, parent must be a renamed node. We can // stop the check at the reference node. if (parent != null && parent.isReference()) { return true; } final INodeDirectory parentDir = getParent(); if (parentDir == null) { // root return true; } if (!parentDir.isInLatestSnapshot(latestSnapshotId)) { return false; } final INode child = parentDir.getChild(getLocalNameBytes(), latestSnapshotId); if (this == child) { return true; } return child != null && child.isReference() && this == child.asReference().getReferredINode(); }
INode childINode = tmpParent.getChild(tmpChild.getLocalNameBytes(), Snapshot.CURRENT_STATE_ID); if (childINode == null || !childINode.equals(tmpChild)) {
} else { curNode = dir.getChild(childName, isSnapshot ? snapshotId : CURRENT_STATE_ID);
@Override public INode getChild(byte[] name, int snapshotId) { return getParent().getChild(name, snapshotId); }
@Override public INode getChild(byte[] name, int snapshotId) { return getParent().getChild(name, snapshotId); }
public INode getChild(INodeDirectory currentINode, byte[] name, int snapshotId) { final DirectoryDiff diff = diffs.getDiffById(snapshotId); return diff != null ? diff.getChild(name, true, currentINode) : currentINode.getChild(name, Snapshot.CURRENT_STATE_ID); }
public INode getChild(INodeDirectory currentINode, byte[] name, int snapshotId) { final DirectoryDiff diff = diffs.getDiffById(snapshotId); return diff != null ? diff.getChild(name, true, currentINode) : currentINode.getChild(name, Snapshot.CURRENT_STATE_ID); }
/** * Search for the given INode in the children list and the deleted lists of * snapshots. * @return {@link Snapshot#CURRENT_STATE_ID} if the inode is in the children * list; {@link Snapshot#NO_SNAPSHOT_ID} if the inode is neither in the * children list nor in any snapshot; otherwise the snapshot id of the * corresponding snapshot diff list. */ public int searchChild(INode inode) { INode child = getChild(inode.getLocalNameBytes(), Snapshot.CURRENT_STATE_ID); if (child != inode) { // inode is not in parent's children list, thus inode must be in // snapshot. identify the snapshot id and later add it into the path DirectoryDiffList diffs = getDiffs(); if (diffs == null) { return Snapshot.NO_SNAPSHOT_ID; } return diffs.findSnapshotDeleted(inode); } else { return Snapshot.CURRENT_STATE_ID; } }
/** * Search for the given INode in the children list and the deleted lists of * snapshots. * @return {@link Snapshot#CURRENT_STATE_ID} if the inode is in the children * list; {@link Snapshot#NO_SNAPSHOT_ID} if the inode is neither in the * children list nor in any snapshot; otherwise the snapshot id of the * corresponding snapshot diff list. */ public int searchChild(INode inode) { INode child = getChild(inode.getLocalNameBytes(), Snapshot.CURRENT_STATE_ID); if (child != inode) { // inode is not in parent's children list, thus inode must be in // snapshot. identify the snapshot id and later add it into the path DirectoryDiffList diffs = getDiffs(); if (diffs == null) { return Snapshot.NO_SNAPSHOT_ID; } return diffs.findSnapshotDeleted(inode); } else { return Snapshot.CURRENT_STATE_ID; } }
/** @return the child with the given name. */ INode getChild(byte[] name, boolean checkPosterior, INodeDirectory currentDir) { for(DirectoryDiff d = this; ; d = d.getPosterior()) { final Container<INode> returned = d.diff.accessPrevious(name); if (returned != null) { // the diff is able to determine the inode return returned.getElement(); } else if (!checkPosterior) { // Since checkPosterior is false, return null, i.e. not found. return null; } else if (d.getPosterior() == null) { // no more posterior diff, get from current inode. return currentDir.getChild(name, Snapshot.CURRENT_STATE_ID); } } }
/** @return the child with the given name. */ INode getChild(byte[] name, boolean checkPosterior, INodeDirectory currentDir) { for(DirectoryDiff d = this; ; d = d.getPosterior()) { final Container<INode> returned = d.diff.accessPrevious(name); if (returned != null) { // the diff is able to determine the inode return returned.getElement(); } else if (!checkPosterior) { // Since checkPosterior is false, return null, i.e. not found. return null; } else if (d.getPosterior() == null) { // no more posterior diff, get from current inode. return currentDir.getChild(name, Snapshot.CURRENT_STATE_ID); } } }
/** Is this inode in the latest snapshot? */ public final boolean isInLatestSnapshot(final int latestSnapshotId) { if (latestSnapshotId == Snapshot.CURRENT_STATE_ID || latestSnapshotId == Snapshot.NO_SNAPSHOT_ID) { return false; } // if parent is a reference node, parent must be a renamed node. We can // stop the check at the reference node. if (parent != null && parent.isReference()) { return true; } final INodeDirectory parentDir = getParent(); if (parentDir == null) { // root return true; } if (!parentDir.isInLatestSnapshot(latestSnapshotId)) { return false; } final INode child = parentDir.getChild(getLocalNameBytes(), latestSnapshotId); if (this == child) { return true; } return child != null && child.isReference() && this == child.asReference().getReferredINode(); }
/** Is this inode in the latest snapshot? */ public final boolean isInLatestSnapshot(final int latestSnapshotId) { if (latestSnapshotId == Snapshot.CURRENT_STATE_ID || latestSnapshotId == Snapshot.NO_SNAPSHOT_ID) { return false; } // if parent is a reference node, parent must be a renamed node. We can // stop the check at the reference node. if (parent != null && parent.isReference()) { return true; } final INodeDirectory parentDir = getParent(); if (parentDir == null) { // root return true; } if (!parentDir.isInLatestSnapshot(latestSnapshotId)) { return false; } final INode child = parentDir.getChild(getLocalNameBytes(), latestSnapshotId); if (this == child) { return true; } return child != null && child.isReference() && this == child.asReference().getReferredINode(); }