/// <exception cref="System.IO.IOException"/> private void SaveNameSystemSection(FsImageProto.FileSummary.Builder summary) { FSNamesystem fsn = context.GetSourceNamesystem(); OutputStream @out = sectionOutputStream; BlockIdManager blockIdManager = fsn.GetBlockIdManager(); FsImageProto.NameSystemSection.Builder b = FsImageProto.NameSystemSection.NewBuilder ().SetGenstampV1(blockIdManager.GetGenerationStampV1()).SetGenstampV1Limit(blockIdManager .GetGenerationStampV1Limit()).SetGenstampV2(blockIdManager.GetGenerationStampV2( )).SetLastAllocatedBlockId(blockIdManager.GetLastAllocatedBlockId()).SetTransactionId (context.GetTxId()); // We use the non-locked version of getNamespaceInfo here since // the coordinating thread of saveNamespace already has read-locked // the namespace for us. If we attempt to take another readlock // from the actual saver thread, there's a potential of a // fairness-related deadlock. See the comments on HDFS-2223. b.SetNamespaceId(fsn.UnprotectedGetNamespaceInfo().GetNamespaceID()); if (fsn.IsRollingUpgrade()) { b.SetRollingUpgradeStartTime(fsn.GetRollingUpgradeInfo().GetStartTime()); } FsImageProto.NameSystemSection s = ((FsImageProto.NameSystemSection)b.Build()); s.WriteDelimitedTo(@out); CommitSection(summary, FSImageFormatProtobuf.SectionName.NsInfo); }
/// <exception cref="System.IO.IOException"/> private void DumpNameSection(InputStream @in) { FsImageProto.NameSystemSection s = FsImageProto.NameSystemSection.ParseDelimitedFrom (@in); @out.Write("<NameSection>\n"); O("genstampV1", s.GetGenstampV1()).O("genstampV2", s.GetGenstampV2()).O("genstampV1Limit" , s.GetGenstampV1Limit()).O("lastAllocatedBlockId", s.GetLastAllocatedBlockId()) .O("txid", s.GetTransactionId()); @out.Write("</NameSection>\n"); }
/// <exception cref="System.IO.IOException"/> private void LoadNameSystemSection(InputStream @in) { FsImageProto.NameSystemSection s = FsImageProto.NameSystemSection.ParseDelimitedFrom (@in); BlockIdManager blockIdManager = fsn.GetBlockIdManager(); blockIdManager.SetGenerationStampV1(s.GetGenstampV1()); blockIdManager.SetGenerationStampV2(s.GetGenstampV2()); blockIdManager.SetGenerationStampV1Limit(s.GetGenstampV1Limit()); blockIdManager.SetLastAllocatedBlockId(s.GetLastAllocatedBlockId()); imgTxId = s.GetTransactionId(); if (s.HasRollingUpgradeStartTime() && fsn.GetFSImage().HasRollbackFSImage()) { // we set the rollingUpgradeInfo only when we make sure we have the // rollback image fsn.SetRollingUpgradeInfo(true, s.GetRollingUpgradeStartTime()); } }