//  do not store locations of last block
 /// <summary>
 /// Serialize a
 /// <see cref="INodeFile"/>
 /// node
 /// </summary>
 /// <param name="node">The node to write</param>
 /// <param name="out">
 /// The
 /// <see cref="System.IO.DataOutputStream"/>
 /// where the fields are written
 /// </param>
 /// <param name="writeBlock">Whether to write block information</param>
 /// <exception cref="System.IO.IOException"/>
 public static void WriteINodeFile(INodeFile file, DataOutput @out, bool writeUnderConstruction
                                   )
 {
     WriteLocalName(file, @out);
     @out.WriteLong(file.GetId());
     @out.WriteShort(file.GetFileReplication());
     @out.WriteLong(file.GetModificationTime());
     @out.WriteLong(file.GetAccessTime());
     @out.WriteLong(file.GetPreferredBlockSize());
     WriteBlocks(file.GetBlocks(), @out);
     SnapshotFSImageFormat.SaveFileDiffList(file, @out);
     if (writeUnderConstruction)
     {
         if (file.IsUnderConstruction())
         {
             @out.WriteBoolean(true);
             FileUnderConstructionFeature uc = file.GetFileUnderConstructionFeature();
             WriteString(uc.GetClientName(), @out);
             WriteString(uc.GetClientMachine(), @out);
         }
         else
         {
             @out.WriteBoolean(false);
         }
     }
     WritePermissionStatus(file, @out);
 }
        // Helper function that writes an INodeUnderConstruction
        // into the output stream
        //
        /// <exception cref="System.IO.IOException"/>
        internal static void WriteINodeUnderConstruction(DataOutputStream @out, INodeFile
                                                         cons, string path)
        {
            WriteString(path, @out);
            @out.WriteLong(cons.GetId());
            @out.WriteShort(cons.GetFileReplication());
            @out.WriteLong(cons.GetModificationTime());
            @out.WriteLong(cons.GetPreferredBlockSize());
            WriteBlocks(cons.GetBlocks(), @out);
            cons.GetPermissionStatus().Write(@out);
            FileUnderConstructionFeature uc = cons.GetFileUnderConstructionFeature();

            WriteString(uc.GetClientName(), @out);
            WriteString(uc.GetClientMachine(), @out);
            @out.WriteInt(0);
        }
示例#3
0
 /// <summary>Load the under-construction files section, and update the lease map</summary>
 /// <exception cref="System.IO.IOException"/>
 internal void LoadFilesUnderConstructionSection(InputStream @in)
 {
     while (true)
     {
         FsImageProto.FilesUnderConstructionSection.FileUnderConstructionEntry entry = FsImageProto.FilesUnderConstructionSection.FileUnderConstructionEntry
                                                                                       .ParseDelimitedFrom(@in);
         if (entry == null)
         {
             break;
         }
         // update the lease manager
         INodeFile file = dir.GetInode(entry.GetInodeId()).AsFile();
         FileUnderConstructionFeature uc = file.GetFileUnderConstructionFeature();
         Preconditions.CheckState(uc != null);
         // file must be under-construction
         fsn.leaseManager.AddLease(uc.GetClientName(), entry.GetFullPath());
     }
 }
示例#4
0
            /// <exception cref="System.IO.IOException"/>
            private void Save(OutputStream @out, INodeFile n)
            {
                FsImageProto.INodeSection.INodeFile.Builder b = BuildINodeFile(n, parent.GetSaverContext
                                                                                   ());
                if (n.GetBlocks() != null)
                {
                    foreach (Block block in n.GetBlocks())
                    {
                        b.AddBlocks(PBHelper.Convert(block));
                    }
                }
                FileUnderConstructionFeature uc = n.GetFileUnderConstructionFeature();

                if (uc != null)
                {
                    FsImageProto.INodeSection.FileUnderConstructionFeature f = ((FsImageProto.INodeSection.FileUnderConstructionFeature
                                                                                 )FsImageProto.INodeSection.FileUnderConstructionFeature.NewBuilder().SetClientName
                                                                                    (uc.GetClientName()).SetClientMachine(uc.GetClientMachine()).Build());
                    b.SetFileUC(f);
                }
                FsImageProto.INodeSection.INode r = ((FsImageProto.INodeSection.INode)BuildINodeCommon
                                                         (n).SetType(FsImageProto.INodeSection.INode.Type.File).SetFile(b).Build());
                r.WriteDelimitedTo(@out);
            }