Пример #1
0
            /// <summary>Load the created list in a DirectoryDiff</summary>
            /// <exception cref="System.IO.IOException"/>
            private IList <INode> LoadCreatedList(InputStream @in, INodeDirectory dir, int size
                                                  )
            {
                IList <INode> clist = new AList <INode>(size);

                for (long c = 0; c < size; c++)
                {
                    FsImageProto.SnapshotDiffSection.CreatedListEntry entry = FsImageProto.SnapshotDiffSection.CreatedListEntry
                                                                              .ParseDelimitedFrom(@in);
                    INode created = SnapshotFSImageFormat.LoadCreated(entry.GetName().ToByteArray(),
                                                                      dir);
                    clist.AddItem(created);
                }
                return(clist);
            }
Пример #2
0
        /// <exception cref="System.IO.IOException"/>
        private void DumpSnapshotDiffSection(InputStream @in)
        {
            @out.Write("<SnapshotDiffSection>");
            while (true)
            {
                FsImageProto.SnapshotDiffSection.DiffEntry e = FsImageProto.SnapshotDiffSection.DiffEntry
                                                               .ParseDelimitedFrom(@in);
                if (e == null)
                {
                    break;
                }
                @out.Write("<diff>");
                O("inodeid", e.GetInodeId());
                switch (e.GetType())
                {
                case FsImageProto.SnapshotDiffSection.DiffEntry.Type.Filediff:
                {
                    for (int i = 0; i < e.GetNumOfDiff(); ++i)
                    {
                        @out.Write("<filediff>");
                        FsImageProto.SnapshotDiffSection.FileDiff f = FsImageProto.SnapshotDiffSection.FileDiff
                                                                      .ParseDelimitedFrom(@in);
                        O("snapshotId", f.GetSnapshotId()).O("size", f.GetFileSize()).O("name", f.GetName
                                                                                            ().ToStringUtf8());
                        @out.Write("</filediff>\n");
                    }
                    break;
                }

                case FsImageProto.SnapshotDiffSection.DiffEntry.Type.Directorydiff:
                {
                    for (int i = 0; i < e.GetNumOfDiff(); ++i)
                    {
                        @out.Write("<dirdiff>");
                        FsImageProto.SnapshotDiffSection.DirectoryDiff d = FsImageProto.SnapshotDiffSection.DirectoryDiff
                                                                           .ParseDelimitedFrom(@in);
                        O("snapshotId", d.GetSnapshotId()).O("isSnapshotroot", d.GetIsSnapshotRoot()).O("childrenSize"
                                                                                                        , d.GetChildrenSize()).O("name", d.GetName().ToStringUtf8());
                        for (int j = 0; j < d.GetCreatedListSize(); ++j)
                        {
                            FsImageProto.SnapshotDiffSection.CreatedListEntry ce = FsImageProto.SnapshotDiffSection.CreatedListEntry
                                                                                   .ParseDelimitedFrom(@in);
                            @out.Write("<created>");
                            O("name", ce.GetName().ToStringUtf8());
                            @out.Write("</created>\n");
                        }
                        foreach (long did in d.GetDeletedINodeList())
                        {
                            @out.Write("<deleted>");
                            O("inode", did);
                            @out.Write("</deleted>\n");
                        }
                        foreach (int dRefid in d.GetDeletedINodeRefList())
                        {
                            @out.Write("<deleted>");
                            O("inodereference-index", dRefid);
                            @out.Write("</deleted>\n");
                        }
                        @out.Write("</dirdiff>\n");
                    }
                    break;
                }

                default:
                {
                    break;
                }
                }
                @out.Write("</diff>");
            }
            @out.Write("</SnapshotDiffSection>\n");
        }