Ejemplo n.º 1
0
 private DirectoryWithSnapshotFeature.DirectoryDiff FindNext()
 {
     for (; this.i.HasNext();)
     {
         DirectoryWithSnapshotFeature.DirectoryDiff diff = this.i.Next();
         if (diff.IsSnapshotRoot())
         {
             return(diff);
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
            /// <exception cref="System.IO.IOException"/>
            private void SerializeDirDiffList(INodeDirectory dir, IList <INodeReference> refList
                                              , OutputStream @out)
            {
                DirectoryWithSnapshotFeature sf = dir.GetDirectoryWithSnapshotFeature();

                if (sf != null)
                {
                    IList <DirectoryWithSnapshotFeature.DirectoryDiff> diffList = sf.GetDiffs().AsList
                                                                                      ();
                    FsImageProto.SnapshotDiffSection.DiffEntry entry = ((FsImageProto.SnapshotDiffSection.DiffEntry
                                                                         )FsImageProto.SnapshotDiffSection.DiffEntry.NewBuilder().SetInodeId(dir.GetId())
                                                                        .SetType(FsImageProto.SnapshotDiffSection.DiffEntry.Type.Directorydiff).SetNumOfDiff
                                                                            (diffList.Count).Build());
                    entry.WriteDelimitedTo(@out);
                    for (int i = diffList.Count - 1; i >= 0; i--)
                    {
                        // reverse order!
                        DirectoryWithSnapshotFeature.DirectoryDiff             diff = diffList[i];
                        FsImageProto.SnapshotDiffSection.DirectoryDiff.Builder db   = FsImageProto.SnapshotDiffSection.DirectoryDiff
                                                                                      .NewBuilder().SetSnapshotId(diff.GetSnapshotId()).SetChildrenSize(diff.GetChildrenSize
                                                                                                                                                            ()).SetIsSnapshotRoot(diff.IsSnapshotRoot());
                        INodeDirectoryAttributes copy = diff.snapshotINode;
                        if (!diff.IsSnapshotRoot() && copy != null)
                        {
                            db.SetName(ByteString.CopyFrom(copy.GetLocalNameBytes())).SetSnapshotCopy(FSImageFormatPBINode.Saver.BuildINodeDirectory
                                                                                                          (copy, parent.GetSaverContext()));
                        }
                        // process created list and deleted list
                        IList <INode> created = diff.GetChildrenDiff().GetList(Diff.ListType.Created);
                        db.SetCreatedListSize(created.Count);
                        IList <INode> deleted = diff.GetChildrenDiff().GetList(Diff.ListType.Deleted);
                        foreach (INode d in deleted)
                        {
                            if (d.IsReference())
                            {
                                refList.AddItem(d.AsReference());
                                db.AddDeletedINodeRef(refList.Count - 1);
                            }
                            else
                            {
                                db.AddDeletedINode(d.GetId());
                            }
                        }
                        ((FsImageProto.SnapshotDiffSection.DirectoryDiff)db.Build()).WriteDelimitedTo(@out
                                                                                                      );
                        SaveCreatedList(created, @out);
                    }
                }
            }