Пример #1
0
 public TestResourceStore()
 {
     RemoveDBFiles();
     MyPalStorage.ResourceCacheSize = 16;
     MyPalStorage.CreateDatabase();
     DoOpenDatabase();
 }
Пример #2
0
 public override void SetUp()
 {
     RemoveDBFiles();
     MyPalStorage.ResourceCacheSize = 16;
     MyPalStorage.CreateDatabase();
     MyPalStorage.OpenDatabase();
     _storage = MyPalStorage.Storage;
 }
Пример #3
0
 protected void InitStorage()
 {
     RemoveDBFiles();
     MyPalStorage.ResourceCacheSize = 16;
     MyPalStorage.CreateDatabase();
     MyPalStorage.OpenDatabase();
     _storage = MyPalStorage.Storage;
     IndexConstructor.WorkDir = MyPalStorage.DBPath;
 }
Пример #4
0
        [Test] public void StressTest()
        {
            for (int i = 0; i < 100; i++)
            {
                RemoveDBFiles();
                MyPalStorage.CreateDatabase();
                MyPalStorage.OpenDatabase();
                _storage = MyPalStorage.Storage;

                MyPalStorage.CloseDatabase();
                _storage = null;
                try
                {
                    RemoveDBFiles();
                }
                catch (Exception e)
                {
                    Console.WriteLine(" Error cleaning DB files: " + e.Message);
                }
            }
        }
Пример #5
0
        private void ProcessDB()
        {
            if (!DBHelper.DatabaseExists(MyPalStorage.DBPath, "MyPal"))
            {
                Console.WriteLine("Omea database not found");
                return;
            }

            DBStructure dbStructure = new DBStructure(MyPalStorage.DBPath, "MyPal");

            dbStructure.ProgressListenerEvent += new DBStructure.ProgressEventHandler(dbStructure_ProgressListenerEvent);

            Console.WriteLine("Loading database...");

            bool structureCorrupted = false;

            try
            {
                dbStructure.LoadStructure(true);
            }
            catch (Exception)
            {
                structureCorrupted = true;
            }

            if (structureCorrupted || !AllTablesExist(dbStructure))
            {
                Console.WriteLine("Rebuilding database structure...");
                dbStructure.Shutdown();

                MyPalStorage.CreateDatabase();
                dbStructure = new DBStructure(MyPalStorage.DBPath, "MyPal");
                dbStructure.LoadStructure(true);
                _forceRebuild = true;
            }

            if (_defrag)
            {
                Console.WriteLine("Defragmenting database...");
                dbStructure.Defragment();
            }
            else if (!dbStructure.IsDatabaseCorrect())
            {
                Console.WriteLine("Database indexes are corrupt. Rebuilding...");
                dbStructure.RebuildIndexes();
            }
            else if (_forceRebuild)
            {
                Console.WriteLine("Performing forced rebuild of database indexes...");
                dbStructure.RebuildIndexes(true);
            }
            else if (_lowCheck)
            {
                dbStructure.LowLevelCheck( );
                return;
            }

            if (_dbdump)
            {
                Console.WriteLine("Dumping database...");
                dbStructure.Dump();
            }

            IDatabase db = dbStructure.OpenDatabase();

            if (_calcSpace)
            {
                CalcSpace(db, "ResourceTypes");
                CalcSpace(db, "PropTypes");
                CalcSpace(db, "IntProps");
                CalcSpace(db, "StringProps");
                CalcSpace(db, "LongStringProps");
                CalcSpace(db, "StringListProps");
                CalcSpace(db, "DateProps");
                CalcSpace(db, "BlobProps");
                CalcSpace(db, "DoubleProps");
                CalcSpace(db, "Resources");
                CalcSpace(db, "Links");
                return;
            }

            ResourceStoreRepair rsRepair = new ResourceStoreRepair(db);

            rsRepair.FixErrors       = _fixErrors;
            rsRepair.DumpStructure   = _dump;
            rsRepair.RepairProgress += new RepairProgressEventHandler(RsRepair_OnRepairProgress);
            rsRepair.Run();
        }