Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PhysicalDatabase"/> class.
        /// </summary>
        /// <param name="journal">The journal.</param>
        public unsafe PhysicalDatabase(IJournal journal, Caching.BlockCache cache, JournalRecovery recovery)
        {
            this.journal = journal;
            this.journal.Startup(cache, recovery);

            // Must make sure we construct the first node if not already there ("default node").
            Block block = journal.ReadService.Read(BlockType.NoCache, 0);

            fixed(byte *p = block.Data)
            {
                DatabaseHeader *header = (DatabaseHeader *)p;

                rootAddress = header->RootObjectAddress;
            }

            // We must initialize it.
            if (rootAddress == 0)
            {
                journal.Execute(new Operations.CreateRootObject());
                block = journal.ReadService.Read(BlockType.NoCache, 0);
                fixed(byte *pp = block.Data)
                {
                    DatabaseHeader *header = (DatabaseHeader *)pp;

                    rootAddress = header->RootObjectAddress;
                }

                Debug.Assert(rootAddress != 0);
            }
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }