/// <exception cref="Org.Apache.Hadoop.Hdfs.Protocol.QuotaExceededException"/> internal RenameOperation(FSDirectory fsd, string src, string dst, INodesInPath srcIIP , INodesInPath dstIIP) { this.fsd = fsd; this.src = src; this.dst = dst; this.srcIIP = srcIIP; this.dstIIP = dstIIP; this.srcParentIIP = srcIIP.GetParentINodesInPath(); this.dstParentIIP = dstIIP.GetParentINodesInPath(); BlockStoragePolicySuite bsps = fsd.GetBlockStoragePolicySuite(); srcChild = this.srcIIP.GetLastINode(); srcChildName = srcChild.GetLocalNameBytes(); int srcLatestSnapshotId = srcIIP.GetLatestSnapshotId(); isSrcInSnapshot = srcChild.IsInLatestSnapshot(srcLatestSnapshotId); srcChildIsReference = srcChild.IsReference(); srcParent = this.srcIIP.GetINode(-2).AsDirectory(); // Record the snapshot on srcChild. After the rename, before any new // snapshot is taken on the dst tree, changes will be recorded in the // latest snapshot of the src tree. if (isSrcInSnapshot) { srcChild.RecordModification(srcLatestSnapshotId); } // check srcChild for reference srcRefDstSnapshot = srcChildIsReference ? srcChild.AsReference().GetDstSnapshotId () : Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot.CurrentStateId; oldSrcCounts = new QuotaCounts.Builder().Build(); if (isSrcInSnapshot) { INodeReference.WithName withName = srcParent.ReplaceChild4ReferenceWithName(srcChild , srcLatestSnapshotId); withCount = (INodeReference.WithCount)withName.GetReferredINode(); srcChild = withName; this.srcIIP = INodesInPath.Replace(srcIIP, srcIIP.Length() - 1, srcChild); // get the counts before rename withCount.GetReferredINode().ComputeQuotaUsage(bsps, oldSrcCounts, true); } else { if (srcChildIsReference) { // srcChild is reference but srcChild is not in latest snapshot withCount = (INodeReference.WithCount)srcChild.AsReference().GetReferredINode(); } else { withCount = null; } } }
internal virtual long RemoveDst() { long removedNum = fsd.RemoveLastINode(dstIIP); if (removedNum != -1) { oldDstChild = dstIIP.GetLastINode(); // update the quota count if necessary fsd.UpdateCountForDelete(oldDstChild, dstIIP); dstIIP = INodesInPath.Replace(dstIIP, dstIIP.Length() - 1, null); } return(removedNum); }
internal virtual bool RemoveSrc4OldRename() { long removedSrc = fsd.RemoveLastINode(srcIIP); if (removedSrc == -1) { NameNode.stateChangeLog.Warn("DIR* FSDirRenameOp.unprotectedRenameTo: " + "failed to rename " + src + " to " + dst + " because the source" + " can not be removed"); return(false); } else { // update the quota count if necessary fsd.UpdateCountForDelete(srcChild, srcIIP); srcIIP = INodesInPath.Replace(srcIIP, srcIIP.Length() - 1, null); return(true); } }
/// <exception cref="System.IO.IOException"/> internal virtual long RemoveSrc() { long removedNum = fsd.RemoveLastINode(srcIIP); if (removedNum == -1) { string error = "Failed to rename " + src + " to " + dst + " because the source can not be removed"; NameNode.stateChangeLog.Warn("DIR* FSDirRenameOp.unprotectedRenameTo:" + error); throw new IOException(error); } else { // update the quota count if necessary fsd.UpdateCountForDelete(srcChild, srcIIP); srcIIP = INodesInPath.Replace(srcIIP, srcIIP.Length() - 1, null); return(removedNum); } }