/// <exception cref="System.IO.IOException"></exception> public DefragmentServicesImpl(DefragmentConfig defragConfig, IDefragmentListener listener) { _listener = listener; Config4Impl originalConfig = (Config4Impl)defragConfig.Db4oConfig(); IStorage storage = defragConfig.BackupStorage(); if (defragConfig.ReadOnly()) { storage = new NonFlushingStorage(storage); } Config4Impl sourceConfig = PrepareConfig(originalConfig, storage, defragConfig.ReadOnly ()); _sourceDb = (LocalObjectContainer)Db4oFactory.OpenFile(sourceConfig, defragConfig .TempPath()).Ext(); _sourceDb.ShowInternalClasses(true); defragConfig.Db4oConfig().BlockSize(_sourceDb.BlockSize()); if (!originalConfig.GenerateCommitTimestamps().DefiniteNo()) { defragConfig.Db4oConfig().GenerateCommitTimestamps(_sourceDb.Config().GenerateCommitTimestamps ().DefiniteYes()); } _targetDb = FreshTargetFile(defragConfig); _mapping = defragConfig.Mapping(); _mapping.Open(); _defragConfig = defragConfig; }
/// <exception cref="System.IO.IOException"></exception> public DefragmentServicesImpl(DefragmentConfig defragConfig, IDefragmentListener listener) { _listener = listener; var originalConfig = (Config4Impl) defragConfig.Db4oConfig(); var storage = defragConfig.BackupStorage(); if (defragConfig.ReadOnly()) { storage = new NonFlushingStorage(storage); } var sourceConfig = PrepareConfig(originalConfig, storage, defragConfig.ReadOnly ()); _sourceDb = (LocalObjectContainer) Db4oFactory.OpenFile(sourceConfig, defragConfig .TempPath()).Ext(); _sourceDb.ShowInternalClasses(true); defragConfig.Db4oConfig().BlockSize(_sourceDb.BlockSize()); if (!originalConfig.GenerateCommitTimestamps().DefiniteNo()) { defragConfig.Db4oConfig().GenerateCommitTimestamps(_sourceDb.Config().GenerateCommitTimestamps ().DefiniteYes()); } _targetDb = FreshTargetFile(defragConfig); _mapping = defragConfig.Mapping(); _mapping.Open(); _defragConfig = defragConfig; }
/// <exception cref="System.Exception"></exception> public override void SetUp() { _idMapping = ((IIdMapping)((IFunction4)_fixture.Value).Apply(TempFile())); _idMapping.Open(); }
/// <summary>Creates a configuration for a defragmentation run.</summary> /// <remarks> /// Creates a configuration for a defragmentation run. All properties other /// than the provided paths are set to FALSE by default. /// </remarks> /// <param name="origPath"> /// The path to the file to be defragmented. Must exist and must be /// a valid db4o file. /// </param> /// <param name="backupPath"> /// The path to the backup of the original file. No file should /// exist at this position, otherwise it will be OVERWRITTEN if forceBackupDelete() /// is set to true! /// </param> /// <param name="mapping"> /// The Id mapping to be used internally. Pass either a /// <see cref="InMemoryIdMapping">InMemoryIdMapping</see> /// for fastest defragment or a /// <see cref="DatabaseIdMapping">DatabaseIdMapping</see> /// for low memory consumption. /// </param> public DefragmentConfig(string origPath, string backupPath, IIdMapping mapping) { _origPath = origPath; _backupPath = backupPath; _mapping = mapping; }