public Logger(List <ulong> blocks, Caching.BlockCache provider) { this.backwardBlock = blocks.Count - 1; this.blocks = blocks; this.currentBlockData = new byte[provider.BlockSize]; this.provider = provider; }
/// <summary> /// Writes the allocations deallocs. /// </summary> /// <param name="allocs">The allocs.</param> public static void WriteAllocationsDeallocs(Caching.BlockCache provider, List <ulong> allocs) { // We can now group them now for each block. for (int i = 0; i < allocs.Count;) { // We obtain the allocation block. uint offset; ulong allocAddress = BlockHelper.GetAllocationBlock(provider.BlockSize, allocs[i], out offset); // We read it and gain access to it. BoolArray array = new BoolArray(provider.Read(BlockType.AllocationBlock, allocAddress)); // We write first data. array.Change(offset); // Continue while we can in this block. i++; for (; i < allocs.Count; i++) { // We quite if not the same block. if (allocAddress != BlockHelper.GetAllocationBlock(provider.BlockSize, allocs[i], out offset)) { break; } // Otherwise write. array.Change(offset); } // We need to write it now. provider.Write(BlockType.AllocationBlock, allocAddress, array.Data); } }
public bool Startup(Caching.BlockCache provider, JournalRecovery recovery) { this.provider = provider; this.allocator = new Allocator(provider); this.readService = new ReadService(provider); // We issue recovery (not written by us but still valid). return(JournalLog.StartupRecovery(this)); }
public bool Startup(Caching.BlockCache provider, JournalRecovery recovery) { this.provider = provider; this.allocator = new Allocator(provider); this.readService = new ReadService(provider); this.journalLog = new JournalLog(allocator); // We issue recovery and ignore operations (certainly not written by us). return(JournalLog.StartupRecovery(this)); }
/// <summary> /// Initializes a new instance of the <see cref="AllocationContext"/> class. /// </summary> /// <param name="availableBlocks">The available blocks.</param> /// <param name="allocator">The allocator.</param> /// <param name="allowDynamic">if set to <c>true</c> [allow dynamic].</param> /// <param name="provider">The provider.</param> public AllocationContext(List <ulong> availableBlocks, IOperation operation, Allocator allocator, bool allowDynamic, Caching.BlockCache provider) { this.availableBlocks = availableBlocks; this.allAllocations = new List <ulong>(availableBlocks); this.allocator = allocator; this.allowDynamic = allowDynamic; this.hint = availableBlocks.Count > 0 ? availableBlocks[availableBlocks.Count - 1] : 0; this.provider = provider; this.operation = operation; // Available blocks must be sorted. availableBlocks.Sort(); }
/// <summary> /// Initializes a new instance of the <see cref="Allocator"/> class. /// </summary> /// <param name="provider">The provider.</param> public unsafe Allocator(Caching.BlockCache provider) { this.provider = provider; byte[] data = provider.Read(BlockType.NoCache, 0); fixed(byte *p = data) { DatabaseHeader *header = (DatabaseHeader *)p; if (!header->IsValid) { throw new DatabaseException("The database header is not valid, not a valid physical database. Must reformat it."); } blockCount = header->BlockCount; } }
/// <summary> /// Nons the safe journal. /// </summary> /// <param name="provider">The provider.</param> /// <param name="context">The context.</param> public NonSafeService(Caching.BlockCache provider, AllocationContext context) { this.provider = provider; this.context = context; this.context.Service = this; }