Exemplo n.º 1
0
        /// <summary>
        /// Serialize a
        /// <see cref="INodeReference"/>
        /// node
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        private static void WriteINodeReference(INodeReference @ref, DataOutput @out, bool
                                                writeUnderConstruction, SnapshotFSImageFormat.ReferenceMap referenceMap)
        {
            WriteLocalName(@ref, @out);
            @out.WriteLong(@ref.GetId());
            @out.WriteShort(0);
            // replication
            @out.WriteLong(0);
            // modification time
            @out.WriteLong(0);
            // access time
            @out.WriteLong(0);
            // preferred block size
            @out.WriteInt(-3);
            // # of blocks
            bool isWithName = @ref is INodeReference.WithName;

            @out.WriteBoolean(isWithName);
            if (!isWithName)
            {
                Preconditions.CheckState(@ref is INodeReference.DstReference);
                // dst snapshot id
                @out.WriteInt(((INodeReference.DstReference)@ref).GetDstSnapshotId());
            }
            else
            {
                @out.WriteInt(((INodeReference.WithName)@ref).GetLastSnapshotId());
            }
            INodeReference.WithCount withCount = (INodeReference.WithCount)@ref.GetReferredINode
                                                     ();
            referenceMap.WriteINodeReferenceWithCount(withCount, @out, writeUnderConstruction
                                                      );
        }
Exemplo n.º 2
0
            /// <exception cref="Org.Apache.Hadoop.Hdfs.Protocol.QuotaExceededException"/>
            internal virtual void RestoreDst(BlockStoragePolicySuite bsps)
            {
                Preconditions.CheckState(oldDstChild != null);
                INodeDirectory dstParent = dstParentIIP.GetLastINode().AsDirectory();

                if (dstParent.IsWithSnapshot())
                {
                    dstParent.UndoRename4DstParent(bsps, oldDstChild, dstIIP.GetLatestSnapshotId());
                }
                else
                {
                    fsd.AddLastINodeNoQuotaCheck(dstParentIIP, oldDstChild);
                }
                if (oldDstChild != null && oldDstChild.IsReference())
                {
                    INodeReference           removedDstRef = oldDstChild.AsReference();
                    INodeReference.WithCount wc            = (INodeReference.WithCount)removedDstRef.GetReferredINode
                                                                 ().AsReference();
                    wc.AddReference(removedDstRef);
                }
            }