Ejemplo n.º 1
0
        public DetailedStorageReport Generate(DetailedReportInput input)
        {
            var dataFile = GenerateDataFileReport(input.NumberOfAllocatedPages, input.NumberOfFreePages, input.NextPageNumber);

            var trees = new List <TreeReport>();

            foreach (var tree in input.Trees)
            {
                var treeReport = GetReport(tree, input.IncludeDetails);

                trees.Add(treeReport);
            }

            foreach (var fst in input.FixedSizeTrees)
            {
                var treeReport = GetReport(fst, input.IncludeDetails);

                trees.Add(treeReport);
            }

            var tables = new List <TableReport>();

            foreach (var table in input.Tables)
            {
                var tableReport = table.GetReport(input.IncludeDetails);
                tables.Add(tableReport);
            }

            var journals = new JournalsReport
            {
                Journals                     = GenerateJournalsReport(input.Journals, input.FlushedJournals),
                LastFlushedJournal           = input.LastFlushedJournalId,
                LastFlushedTransaction       = input.LastFlushedTransactionId,
                TotalWrittenButUnsyncedBytes = input.TotalWrittenButUnsyncedBytes
            };

            var tempBuffers = GenerateTempBuffersReport(input.TempPath, input.JournalPath);

            return(new DetailedStorageReport
            {
                InMemoryState = input.InMemoryStorageState,
                DataFile = dataFile,
                Trees = trees,
                Tables = tables,
                Journals = journals,
                PreAllocatedBuffers = GetReport(new NewPageAllocator(_tx, _tx.RootObjects), input.IncludeDetails),
                ScratchBufferPoolInfo = input.ScratchBufferPoolInfo,
                TempBuffers = tempBuffers,
                TotalEncryptionBufferSize = input.TotalEncryptionBufferSize.ToString()
            });
        }
Ejemplo n.º 2
0
        public DetailedStorageReport Generate(DetailedReportInput input)
        {
            var dataFile = GenerateDataFileReport(input.NumberOfAllocatedPages, input.NumberOfFreePages, input.NextPageNumber);

            long _streamsAllocatedSpaceInBytes = 0;
            long _treesAllocatedSpaceInBytes   = 0;
            var  trees = new List <TreeReport>();

            foreach (var tree in input.Trees)
            {
                var treeReport = GetReport(tree, input.IncludeDetails);
                trees.Add(treeReport);

                if (input.IncludeDetails)
                {
                    continue;
                }

                if (treeReport.Streams == null)
                {
                    _treesAllocatedSpaceInBytes += treeReport.AllocatedSpaceInBytes;
                }
                else
                {
                    _streamsAllocatedSpaceInBytes += treeReport.Streams.AllocatedSpaceInBytes;
                }
            }

            foreach (var fst in input.FixedSizeTrees)
            {
                var treeReport = GetReport(fst, input.IncludeDetails);
                trees.Add(treeReport);

                _treesAllocatedSpaceInBytes += treeReport.AllocatedSpaceInBytes;
            }

            long _tablesAllocatedSpaceInBytes = 0;
            var  tables = new List <TableReport>();

            foreach (var table in input.Tables)
            {
                var tableReport = table.GetReport(input.IncludeDetails, this);
                tables.Add(tableReport);

                _tablesAllocatedSpaceInBytes += tableReport.AllocatedSpaceInBytes;
            }

            var journals = new JournalsReport
            {
                Journals                     = GenerateJournalsReport(input.Journals, input.FlushedJournals),
                LastFlushedJournal           = input.LastFlushedJournalId,
                LastFlushedTransaction       = input.LastFlushedTransactionId,
                TotalWrittenButUnsyncedBytes = input.TotalWrittenButUnsyncedBytes
            };

            var tempBuffers         = GenerateTempBuffersReport(input.TempPath, input.JournalPath);
            var preAllocatedBuffers = GetReport(new NewPageAllocator(_tx, _tx.RootObjects), input.IncludeDetails);

            if (input.IncludeDetails == false && _skippedStreamsDetailsEntry != null)
            {
                // we don't have the actual trees' streams size at this point
                // so we calculate the original size as if we read the streams by:
                // [DataFile allocated space] - [DataFile free space] - [Tables allocated space] - [FixedTrees allocated space] - [pre allocated buffers space]

                var treesCalculatedSpaceInBytes = dataFile.UsedSpaceInBytes - _tablesAllocatedSpaceInBytes - preAllocatedBuffers.AllocatedSpaceInBytes - _treesAllocatedSpaceInBytes;

                foreach (var tree in trees)
                {
                    if (tree.Streams?.Streams != null && tree.Streams.Streams.Count > 0 && tree.Streams.Streams[0].Name == SkippedStreamsDetailsName)
                    {
                        _skippedStreamsDetailsEntry.AllocatedSpaceInBytes = treesCalculatedSpaceInBytes;
                        _skippedStreamsDetailsEntry.Length = treesCalculatedSpaceInBytes;
                        tree.AllocatedSpaceInBytes         = treesCalculatedSpaceInBytes - _streamsAllocatedSpaceInBytes;
                        break;
                    }
                }
            }

            return(new DetailedStorageReport
            {
                InMemoryState = input.InMemoryStorageState,
                DataFile = dataFile,
                Trees = trees,
                Tables = tables,
                Journals = journals,
                PreAllocatedBuffers = preAllocatedBuffers,
                ScratchBufferPoolInfo = input.ScratchBufferPoolInfo,
                TempBuffers = tempBuffers,
                TotalEncryptionBufferSize = input.TotalEncryptionBufferSize.ToString()
            });
        }