Ejemplo n.º 1
0
            /// <exception cref="System.IO.IOException"/>
            private INodeReference LoadINodeReference(FsImageProto.INodeReferenceSection.INodeReference
                                                      r)
            {
                long  referredId = r.GetReferredId();
                INode referred   = fsDir.GetInode(referredId);

                INodeReference.WithCount withCount = (INodeReference.WithCount)referred.GetParentReference
                                                         ();
                if (withCount == null)
                {
                    withCount = new INodeReference.WithCount(null, referred);
                }
                INodeReference @ref;

                if (r.HasDstSnapshotId())
                {
                    // DstReference
                    @ref = new INodeReference.DstReference(null, withCount, r.GetDstSnapshotId());
                }
                else
                {
                    @ref = new INodeReference.WithName(null, withCount, r.GetName().ToByteArray(), r.
                                                       GetLastSnapshotId());
                }
                return(@ref);
            }
Ejemplo n.º 2
0
            /// <exception cref="System.IO.IOException"/>
            public virtual INodeReference.WithCount LoadINodeReferenceWithCount(bool isSnapshotINode
                                                                                , DataInput @in, FSImageFormat.Loader loader)
            {
                bool firstReferred = @in.ReadBoolean();

                INodeReference.WithCount withCount;
                if (firstReferred)
                {
                    INode referred = loader.LoadINodeWithLocalName(isSnapshotINode, @in, true);
                    withCount = new INodeReference.WithCount(null, referred);
                    referenceMap[withCount.GetId()] = withCount;
                }
                else
                {
                    long id = @in.ReadLong();
                    withCount = referenceMap[id];
                }
                return(withCount);
            }
Ejemplo n.º 3
0
            /// <exception cref="System.IO.IOException"/>
            public virtual void WriteINodeReferenceWithCount(INodeReference.WithCount withCount
                                                             , DataOutput @out, bool writeUnderConstruction)
            {
                INode referred      = withCount.GetReferredINode();
                long  id            = withCount.GetId();
                bool  firstReferred = !referenceMap.Contains(id);

                @out.WriteBoolean(firstReferred);
                if (firstReferred)
                {
                    FSImageSerialization.SaveINode2Image(referred, @out, writeUnderConstruction, this
                                                         );
                    referenceMap[id] = withCount;
                }
                else
                {
                    @out.WriteLong(id);
                }
            }