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)); }
void DefragDatabase() { if (!File.Exists(DatabaseFile)) { return; } DateTime start = DateTime.UtcNow, stop; var backupFile = String.Format( "{0}.bak_{1}.{2}", DatabaseFile, Db4oVersion.Major, Db4oVersion.Minor ); var defragConfig = new DefragmentConfig( DatabaseFile, backupFile ); defragConfig.ForceBackupDelete(true); Defragment.Defrag(defragConfig); stop = DateTime.UtcNow; #if LOG4NET Logger.Debug( String.Format( "DefragDatabase(): defrag took: {0:0.0} ms", (stop - start).TotalMilliseconds ) ); #endif }
/// <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); } }
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); }
/// <exception cref="System.IO.IOException"></exception> private void Defrag() { string backupPath = Path.GetTempFileName(); DefragmentConfig config = new DefragmentConfig(TempFile(), backupPath); config.ForceBackupDelete(true); Db4objects.Db4o.Defragment.Defragment.Defrag(config); Delete(backupPath); }
/// <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() { var backupPath = Path.GetTempFileName(); var config = new DefragmentConfig(TempFile(), backupPath); config.ForceBackupDelete(true); Defragment.Defragment.Defrag(config); Delete(backupPath); }
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); }
public void DeleteBackup() { // #example: Delete the backup after the defragmentation process DefragmentConfig config = new DefragmentConfig("database.db4o"); config.ForceBackupDelete(true); Defragment.Defrag(config); // #end example }
private void DefragFileDataBase() { EnsureCloseDb4OContainer(); var defragConfig = new DefragmentConfig(Db4oDataBaseFilePath); defragConfig.Db4oConfig(GetEmbeddedConfiguration()); defragConfig.ForceBackupDelete(true); Defragment.Defrag(defragConfig); }
/// <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(); }
public void Test() { GenerateDatabaseFile(); var config = new DefragmentConfig(TempFile()); config.ForceBackupDelete(true); var e = Assert.Expect(typeof(InvalidOperationException), delegate { Defragment.Defragment.Defrag(config); }); Assert.IsTrue(e.Message.Contains("Thing"), "Message should contain the missing type name."); }
/// <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); }
public void TestDefragWorksAfterReopening() { Environment().InvokeInstanceMethod(GetType(), "CreateDatabase", db4oFilePath, true); using (var db = Db4oEmbedded.OpenFile(db4oFilePath)) { } var config = new DefragmentConfig(db4oFilePath); config.ForceBackupDelete(true); Defragment.Defragment.Defrag(config); }
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); }
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) { } } } }