Exemple #1
0
        /// <summary>
        /// Opens the storage
        /// </summary>
        private void OpenStorage()
        {
            StartTransaction();
            try
            {
                // For metadata assume block size of 512 because blockSize is unknown at this point.
                // 512 is the smallest block size so it will work as long as storage metadata is not
                // longer than 512 bytes
                storageMetadataStream = new StorageStream(new StorageStreamMetadata(null)
                {
                    FirstSegmentPosition = 0,
                    InitializedLength    = 512 - Segment.StructureSize,
                    Length           = 512 - Segment.StructureSize,
                    StreamId         = SystemStreamId.StorageMetadata,
                    StreamTableIndex = -1
                }, this);
                StorageMetadata = StorageMetadata.Load(storageMetadataStream);

                streamTableStreamMetadata = new StorageStreamMetadata(storageMetadataStream)
                {
                    FirstSegmentPosition = blockSize,
                    StreamId             = SystemStreamId.StreamTable,
                    StreamTableIndex     = -1
                };
                streamTableStream = new StorageStream(streamTableStreamMetadata, this);
                streamTable       = new StreamTable(streamTableStream);

                var freeSpaceStreamMetadata = streamTable.Get(SystemStreamId.EmptySpace);
                FreeSpaceStream = new StorageStream(freeSpaceStreamMetadata, this);

                CommitTransaction();
            }
            catch
            {
                RollbackTransaction();
                throw;
            }
        }
Exemple #2
0
        /// <summary>
        /// Opens the storage
        /// </summary>
        private void OpenStorage()
        {
            StartTransaction();
            try
            {
                // For metadata assume block size of 512 because blockSize is unknown at this point.
                // 512 is the smallest block size so it will work as long as storage metadata is not
                // longer than 512 bytes
                storageMetadataStream = new StorageStream(new StorageStreamMetadata(null)
                {
                    FirstSegmentPosition = 0,
                    InitializedLength = 512 - Segment.StructureSize,
                    Length = 512 - Segment.StructureSize,
                    StreamId = SystemStreamId.StorageMetadata,
                    StreamTableIndex = -1
                }, this);
                StorageMetadata = StorageMetadata.Load(storageMetadataStream);

                streamTableStreamMetadata = new StorageStreamMetadata(storageMetadataStream)
                {
                    FirstSegmentPosition = blockSize,
                    StreamId = SystemStreamId.StreamTable,
                    StreamTableIndex = -1
                };
                streamTableStream = new StorageStream(streamTableStreamMetadata, this);
                streamTable = new StreamTable(streamTableStream);

                var freeSpaceStreamMetadata = streamTable.Get(SystemStreamId.EmptySpace);
                FreeSpaceStream = new StorageStream(freeSpaceStreamMetadata, this);

                CommitTransaction();
            }
            catch
            {
                RollbackTransaction();
                throw;
            }
        }