Пример #1
0
        public void Stop()
        {
            // Check point before we stop
            CheckPoint();

            lock (lockObject) {
                // We can't stop a database that hasn't started
                if (databaseStarted == false || treeSystem == null)
                {
                    return;
                }

                // Close the store
                fileStore.Close();
                // Stop the buffer manager
                bufferManager.Stop();
                // Offer up all the internal objects to the GC
                bufferManager = null;
                fileStore     = null;

                // Clear the internal state
                treeSystem      = null;
                databaseStarted = false;
            }
        }
Пример #2
0
        public void Stop()
        {
            CheckPoint();

            lock (lockObject) {
                // We can't stop a database that hasn't started
                if (databaseStarted == false || treeSystem == null)
                {
                    return;
                }

                // Offer up all the internal objects to the GC
                store = null;

                // Clear the internal state
                treeSystem      = null;
                databaseStarted = false;
            }
        }
Пример #3
0
        public bool Start()
        {
            lock (lockObject) {
                treeSystem = new StoreTreeSystem(store, branchNodeSize, leafNodeSize, heapNodeCacheSize, branchNodeCacheSize);
                treeSystem.Create();
                treeSystem.CheckPoint();

                // The actual database
                StoreTreeSystem treeStore;

                // Get the header area
                IArea headerArea = store.GetArea(-1);
                int   magicValue = headerArea.ReadInt4();
                // If header area magic value is zero, then we assume this is a brand
                // new database and initialize it with the configuration information
                // given.
                if (magicValue == 0)
                {
                    // Create a tree store inside the file store,
                    treeStore = new StoreTreeSystem(store, branchNodeSize, leafNodeSize, heapNodeCacheSize,
                                                    branchNodeCacheSize);
                    // Create the tree and returns a pointer to the tree,
                    long treePointer = treeStore.Create();

                    // Create an area object with state information about the tree
                    IAreaWriter awriter = store.CreateArea(128);
                    awriter.WriteInt4(0x0101);                     // The version value
                    awriter.WriteInt8(treePointer);
                    awriter.WriteInt4(branchNodeSize);
                    awriter.WriteInt4(leafNodeSize);
                    awriter.Finish();
                    long         dummy = awriter.Id;
                    IMutableArea harea = store.GetMutableArea(-1);
                    harea.WriteInt4(0x092BA001);                     // The magic value
                    harea.WriteInt8(awriter.Id);
                    harea.CheckOut();
                }
                else if (magicValue == 0x092BA001)
                {
                    long apointer = headerArea.ReadInt8();
                    // The area that contains configuration details,
                    IArea initArea = store.GetArea(apointer);
                    int   version  = initArea.ReadInt4();
                    if (version != 0x0101)
                    {
                        throw new IOException("Unknown version in tree initialization area");
                    }

                    // Read the pointer to the tree store
                    long treePointer = initArea.ReadInt8();
                    // Read the branch and leaf node sizes as set when the database was
                    // created.
                    int ibranchNodeSize = initArea.ReadInt4();
                    int ileafNodeSize   = initArea.ReadInt4();

                    // Create the tree store
                    treeStore = new StoreTreeSystem(store, ibranchNodeSize, ileafNodeSize, heapNodeCacheSize,
                                                    branchNodeCacheSize);
                    // Initialize the tree
                    treeStore.Init(treePointer);
                }
                else
                {
                    throw new IOException("Data is corrupt, invalid magic value in store");
                }

                // Set the point of the tree store
                treeStore.CheckPoint();

                // Set up final internal state and return true
                treeSystem      = treeStore;
                databaseStarted = true;
                return(true);
            }
        }
Пример #4
0
        public void Stop()
        {
            // Check point before we stop
            CheckPoint();

            lock (lockObject) {
                // We can't stop a database that hasn't started
                if (!started || treeSystem == null)
                    return;

                // Close the store
                fileStore.Close();
                // Stop the buffer manager
                bufferManager.Stop();
                // Offer up all the internal objects to the GC
                bufferManager = null;
                fileStore = null;

                // Clear the internal state
                treeSystem = null;
                started = false;

            }
        }
Пример #5
0
        public bool Start()
        {
            lock (lockObject) {
                // We can't start a database that is already started,
                if (started || treeSystem != null)
                    return false;

                // Make a data.db file with a single TreeSystem structure mapped into it
                const string fileExt = "db";
                const string dbFileName = "data";

                bufferManager = new LoggingBufferManager(path, path, false, maxPageCount, pageSize, fileExt, fileRolloverSize,
                                                          debug, true);
                bufferManager.Start();

                // The backing store
                fileStore = new JournalledFileStore(dbFileName, bufferManager, false);
                fileStore.Open();

                // The actual database
                StoreTreeSystem treeStore;

                // Get the header area
                IArea headerArea = fileStore.GetArea(-1);
                int magicValue = headerArea.ReadInt4();
                // If header area magic value is zero, then we assume this is a brand
                // new database and initialize it with the configuration information
                // given.
                if (magicValue == 0) {
                    // Create a tree store inside the file store,
                    treeStore = new StoreTreeSystem(fileStore, branchNodeSize, leafNodeSize, heapNodeCacheSize,
                                                     branchNodeCacheSize);
                    // Create the tree and returns a pointer to the tree,
                    long treePointer = treeStore.Create();

                    // Create an area object with state information about the tree
                    IAreaWriter area = fileStore.CreateArea(128);
                    area.WriteInt4(0x0101);    // The version value
                    area.WriteInt8(treePointer);
                    area.WriteInt4(branchNodeSize);
                    area.WriteInt4(leafNodeSize);
                    area.Finish();
                    long areaId = area.Id;
                    IMutableArea harea = fileStore.GetMutableArea(-1);
                    harea.WriteInt4(0x092BA001);  // The magic value
                    harea.WriteInt8(areaId);
                    harea.CheckOut();
                } else if (magicValue == 0x092BA001) {
                    long apointer = headerArea.ReadInt8();
                    // The area that contains configuration details,
                    IArea initArea = fileStore.GetArea(apointer);
                    int version = initArea.ReadInt4();
                    if (version != 0x0101)
                        throw new IOException("Unknown version in tree initialization area");

                    // Read the pointer to the tree store
                    long treePointer = initArea.ReadInt8();
                    // Read the branch and leaf node sizes as set when the database was
                    // created.
                    int ibranchNodeSize = initArea.ReadInt4();
                    int ileafNodeSize = initArea.ReadInt4();

                    // Create the tree store
                    treeStore = new StoreTreeSystem(fileStore, ibranchNodeSize, ileafNodeSize, heapNodeCacheSize,
                                                    branchNodeCacheSize);
                    // Initialize the tree
                    treeStore.Init(treePointer);
                } else {
                    throw new IOException("Data is corrupt, invalid magic value in store");
                }

                // Set the point of the tree store
                treeStore.CheckPoint();

                // Set up final internal state and return true
                treeSystem = treeStore;
                started = true;
                return true;
            }
        }
Пример #6
0
        public bool Start()
        {
            lock (lockObject) {
                // We can't start a database that is already started,
                if (databaseStarted || treeSystem != null)
                {
                    return(false);
                }

                // Make a data.koi file with a single TreeSystem structure mapped into it
                const string fileExt    = "cdb";
                const string dbFileName = "data";

                bufferManager = new LoggingBufferManager(path, path, false, maxPageCount, pageSize, fileExt, fileRolloverSize,
                                                         logger, true);
                bufferManager.Start();

                // The backing store
                fileStore = new JournalledFileStore(dbFileName, bufferManager, false);
                fileStore.Open();

                // The actual database
                StoreTreeSystem treeStore;

                // Get the header area
                IArea headerArea = fileStore.GetArea(-1);
                int   magicValue = headerArea.ReadInt4();
                // If header area magic value is zero, then we assume this is a brand
                // new database and initialize it with the configuration information
                // given.
                if (magicValue == 0)
                {
                    // Create a tree store inside the file store,
                    treeStore = new StoreTreeSystem(fileStore, branchNodeSize, leafNodeSize, heapNodeCacheSize,
                                                    branchNodeCacheSize);
                    // Create the tree and returns a pointer to the tree,
                    long treePointer = treeStore.Create();

                    // Create an area object with state information about the tree
                    IAreaWriter awriter = fileStore.CreateArea(128);
                    awriter.WriteInt4(0x0101);                     // The version value
                    awriter.WriteInt8(treePointer);
                    awriter.WriteInt4(branchNodeSize);
                    awriter.WriteInt4(leafNodeSize);
                    awriter.Finish();
                    long         dummy = awriter.Id;
                    IMutableArea harea = fileStore.GetMutableArea(-1);
                    harea.WriteInt4(0x092BA001);                     // The magic value
                    harea.WriteInt8(awriter.Id);
                    harea.CheckOut();
                }
                else if (magicValue == 0x092BA001)
                {
                    long apointer = headerArea.ReadInt8();
                    // The area that contains configuration details,
                    IArea initArea = fileStore.GetArea(apointer);
                    int   version  = initArea.ReadInt4();
                    if (version != 0x0101)
                    {
                        throw new IOException("Unknown version in tree initialization area");
                    }

                    // Read the pointer to the tree store
                    long treePointer = initArea.ReadInt8();
                    // Read the branch and leaf node sizes as set when the database was
                    // created.
                    int ibranchNodeSize = initArea.ReadInt4();
                    int ileafNodeSize   = initArea.ReadInt4();

                    // Create the tree store
                    treeStore = new StoreTreeSystem(fileStore, ibranchNodeSize, ileafNodeSize, heapNodeCacheSize,
                                                    branchNodeCacheSize);
                    // Initialize the tree
                    treeStore.Init(treePointer);
                }
                else
                {
                    throw new IOException("Data is corrupt, invalid magic value in store");
                }

                // Set the point of the tree store
                treeStore.CheckPoint();

                // Set up final internal state and return true
                treeSystem      = treeStore;
                databaseStarted = true;
                return(true);
            }
        }
Пример #7
0
        public void Stop()
        {
            CheckPoint();

            lock (lockObject) {
                // We can't stop a database that hasn't started
                if (databaseStarted == false || treeSystem == null)
                    return;

                // Offer up all the internal objects to the GC
                store = null;

                // Clear the internal state
                treeSystem = null;
                databaseStarted = false;
            }
        }
Пример #8
0
        public bool Start()
        {
            lock (lockObject) {
                treeSystem = new StoreTreeSystem(store, branchNodeSize, leafNodeSize, heapNodeCacheSize, branchNodeCacheSize);
                treeSystem.Create();
                treeSystem.CheckPoint();

                // The actual database
                StoreTreeSystem treeStore;

                // Get the header area
                IArea headerArea = store.GetArea(-1);
                int magicValue = headerArea.ReadInt4();
                // If header area magic value is zero, then we assume this is a brand
                // new database and initialize it with the configuration information
                // given.
                if (magicValue == 0) {
                    // Create a tree store inside the file store,
                    treeStore = new StoreTreeSystem(store, branchNodeSize, leafNodeSize, heapNodeCacheSize,
                                                    branchNodeCacheSize);
                    // Create the tree and returns a pointer to the tree,
                    long treePointer = treeStore.Create();

                    // Create an area object with state information about the tree
                    IAreaWriter awriter = store.CreateArea(128);
                    awriter.WriteInt4(0x0101); // The version value
                    awriter.WriteInt8(treePointer);
                    awriter.WriteInt4(branchNodeSize);
                    awriter.WriteInt4(leafNodeSize);
                    awriter.Finish();
                    long dummy = awriter.Id;
                    IMutableArea harea = store.GetMutableArea(-1);
                    harea.WriteInt4(0x092BA001); // The magic value
                    harea.WriteInt8(awriter.Id);
                    harea.CheckOut();
                } else if (magicValue == 0x092BA001) {
                    long apointer = headerArea.ReadInt8();
                    // The area that contains configuration details,
                    IArea initArea = store.GetArea(apointer);
                    int version = initArea.ReadInt4();
                    if (version != 0x0101)
                        throw new IOException("Unknown version in tree initialization area");

                    // Read the pointer to the tree store
                    long treePointer = initArea.ReadInt8();
                    // Read the branch and leaf node sizes as set when the database was
                    // created.
                    int ibranchNodeSize = initArea.ReadInt4();
                    int ileafNodeSize = initArea.ReadInt4();

                    // Create the tree store
                    treeStore = new StoreTreeSystem(store, ibranchNodeSize, ileafNodeSize, heapNodeCacheSize,
                                                    branchNodeCacheSize);
                    // Initialize the tree
                    treeStore.Init(treePointer);

                } else {
                    throw new IOException("Data is corrupt, invalid magic value in store");
                }

                // Set the point of the tree store
                treeStore.CheckPoint();

                // Set up final internal state and return true
                treeSystem = treeStore;
                databaseStarted = true;
                return true;
            }
        }
Пример #9
0
 public void Start()
 {
     lock (lockObject) {
         treeSystem = new StoreTreeSystem(store, branchNodeSize, leafNodeSize, heapNodeCacheSize, branchNodeCacheSize);
         treeSystem.Create();
         treeSystem.CheckPoint();
     }
 }