/// <exception cref="System.IO.IOException"></exception> private void Defrag(TernaryBool generateCommitTimestamp) { DefragmentConfig config = new DefragmentConfig(SourceFile(), BackupFile()); config.Db4oConfig(NewConfiguration()); config.ForceBackupDelete(true); if (!generateCommitTimestamp.IsUnspecified()) { config.Db4oConfig().GenerateCommitTimestamps(generateCommitTimestamp.DefiniteYes( )); } Db4objects.Db4o.Defragment.Defragment.Defrag(config); }
/// <exception cref="System.IO.IOException"></exception> private void Defragment(bool registerTranslator) { DefragmentConfig defragConfig = new DefragmentConfig(TempFile()); defragConfig.Db4oConfig(Config(registerTranslator)); defragConfig.ForceBackupDelete(true); Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig); }
/// <exception cref="System.IO.IOException"></exception> private void RunDefrag(string testFileName) { IConfiguration config = Db4oFactory.NewConfiguration(); config.AllowVersionUpdates(true); ConfigureForTest(config); IObjectContainer oc = Db4oFactory.OpenFile(config, testFileName); oc.Close(); string backupFileName = Path.GetTempFileName(); try { DefragmentConfig defragConfig = new DefragmentConfig(testFileName, backupFileName ); defragConfig.ForceBackupDelete(true); ConfigureForTest(defragConfig.Db4oConfig()); defragConfig.ReadOnly(!DefragmentInReadWriteMode()); Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig); } finally { File4.Delete(backupFileName); } }
protected override IObjectContainer CreateDatabase(IConfiguration config) { var origFile = new File(GetAbsolutePath()); if (origFile.Exists()) { try { var backupFile = GetAbsolutePath() + ".defrag.backup"; IIdMapping mapping = new InMemoryIdMapping(); // new // BTreeIDMapping(getAbsolutePath()+".defrag.mapping",4096,1,1000); var defragConfig = new DefragmentConfig(GetAbsolutePath(), backupFile , mapping); defragConfig.ForceBackupDelete(true); // FIXME Cloning is ugly - wrap original in Decorator within // DefragContext instead? var clonedConfig = (IConfiguration)((IDeepClone)config).DeepClone(null ); defragConfig.Db4oConfig(clonedConfig); Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig, new _IDefragmentListener_30 ()); } catch (IOException e) { Runtime.PrintStackTrace(e); } } return(base.CreateDatabase(config)); }
private void Defrag(IConfiguration config) { Sharpen.IO.File origFile = new Sharpen.IO.File(GetAbsolutePath()); if (origFile.Exists()) { try { string backupFile = GetAbsolutePath() + ".defrag.backup"; IIdMapping mapping = new InMemoryIdMapping(); // new // BTreeIDMapping(getAbsolutePath()+".defrag.mapping",4096,1,1000); DefragmentConfig defragConfig = new DefragmentConfig(GetAbsolutePath(), backupFile , mapping); defragConfig.ForceBackupDelete(true); // FIXME Cloning is ugly - wrap original in Decorator within // DefragContext instead? IConfiguration clonedConfig = (IConfiguration)((IDeepClone)config).DeepClone(null ); defragConfig.Db4oConfig(clonedConfig); Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig, new _IDefragmentListener_64 ()); } catch (IOException e) { Sharpen.Runtime.PrintStackTrace(e); } } }
private void Defrag(string fileName, int blockSize) { DefragmentConfig config = new DefragmentConfig(fileName); config.Db4oConfig(Config(blockSize)); config.ForceBackupDelete(true); Db4objects.Db4o.Defragment.Defragment.Defrag(config); }
private DefragmentConfig NewDefragmentConfig(string sourceFile, string backupFile ) { DefragmentConfig config = new DefragmentConfig(sourceFile, backupFile); config.Db4oConfig(NewConfiguration()); return(config); }
/// <exception cref="System.Exception"></exception> protected virtual void Defragment(string fileName) { string targetFile = fileName + ".defrag.backup"; DefragmentConfig defragConfig = new DefragmentConfig(fileName, targetFile); defragConfig.ForceBackupDelete(true); defragConfig.Db4oConfig(CloneConfiguration()); Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig); }
/// <exception cref="System.IO.IOException"></exception> private void Defrag(string fname) { DefragmentConfig config = new DefragmentConfig(fname); config.Db4oConfig(NewConfiguration()); config.StoredClassFilter(IgnoreClassFilter(typeof(StoredClassFilterTestCase.SimpleClass ))); Db4objects.Db4o.Defragment.Defragment.Defrag(config); }
private DefragmentConfig DefragmentConfig(MemoryStorage storage) { DefragmentConfig defragConfig = new DefragmentConfig(Uri, TempFile(), new InMemoryIdMapping ()); defragConfig.Db4oConfig(Config(storage)); defragConfig.BackupStorage(BackupStorage()); return(defragConfig); }
public static DefragmentConfig DefragConfig(string sourceFile, IEmbeddedConfiguration db4oConfig, bool forceBackupDelete) { var defragConfig = new DefragmentConfig(sourceFile, DefragmentTestCaseBase .BackupFileNameFor(sourceFile)); defragConfig.ForceBackupDelete(forceBackupDelete); defragConfig.Db4oConfig(Db4oConfig(db4oConfig)); return(defragConfig); }
private void DefragFileDataBase() { EnsureCloseDb4OContainer(); var defragConfig = new DefragmentConfig(Db4oDataBaseFilePath); defragConfig.Db4oConfig(GetEmbeddedConfiguration()); defragConfig.ForceBackupDelete(true); Defragment.Defrag(defragConfig); }
public void SetDb4OConfiguration() { // #example: Use the database-configuration DefragmentConfig config = new DefragmentConfig("database.db4o"); // It's best to use the very same configuration you use for the regular database IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration(); config.Db4oConfig(configuration); Defragment.Defrag(config); // #end example }
/// <exception cref="System.Exception"></exception> public virtual void TestCOR775() { Prepare(); VerifyDB(); DefragmentConfig config = new DefragmentConfig(TempFile(), Defgared); config.ForceBackupDelete(true); //config.storedClassFilter(new AvailableClassFilter()); config.Db4oConfig(GetConfiguration()); Db4objects.Db4o.Defragment.Defragment.Defrag(config); VerifyDB(); }
private void DefragFileDataBase() { CloseDb4OContainer(); var clientConfig = Db4oEmbedded.NewConfiguration(); SetCommonConfiguration(clientConfig.Common, false); var defragConfig = new DefragmentConfig(DataBaseFilePath); defragConfig.Db4oConfig(clientConfig); defragConfig.ForceBackupDelete(true); Defragment.Defrag(defragConfig); }
/// <exception cref="System.IO.IOException"></exception> public static void AssertIndex(string fieldName, string databaseFileName, IClosure4 configProvider) { ForceIndex(databaseFileName, ((IEmbeddedConfiguration)configProvider.Run())); var defragConfig = new DefragmentConfig(databaseFileName, DefragmentTestCaseBase .BackupFileNameFor(databaseFileName)); defragConfig.Db4oConfig(((IEmbeddedConfiguration)configProvider.Run())); Db4o.Defragment.Defragment.Defrag(defragConfig); IObjectContainer db = Db4oEmbedded.OpenFile(((IEmbeddedConfiguration)configProvider .Run()), databaseFileName); var query = db.Query(); query.Constrain(typeof(Data)); query.Descend(fieldName).Constrain(Value); var result = query.Execute(); Assert.AreEqual(1, result.Count); db.Close(); }
public void DefragmentDatabase() { bool defragmentError = false; try { CloseDatabase(); DefragmentConfig defragConfig = new DefragmentConfig( BookStoreGUI.Properties.Settings.Default.DatabaseFilePath, BookStoreGUI.Properties.Settings.Default.DatabaseBackupFilePath); defragConfig.Db4oConfig(DBConfiguration.Configuration); defragConfig.ForceBackupDelete(true); Defragment.Defrag(defragConfig); } catch (Exception ex) { defragmentError = true; throw new DatabaseException("Could not defragment the database.", ex); } finally { if (defragmentError == false) { try { if (File.Exists(BookStoreGUI.Properties.Settings.Default.DatabaseBackupFilePath) == true) { File.Delete(BookStoreGUI.Properties.Settings.Default.DatabaseBackupFilePath); } } catch (Exception) { } } } }