/// <summary> /// Dbreeze instantiator /// </summary> /// <param name="dbreezeConfiguration"></param> public DBreezeEngine(DBreezeConfiguration dbreezeConfiguration) { ConstructFromConfiguration(dbreezeConfiguration); //if (Configuration != null) // Configuration = dbreezeConfiguration; ////Setting up in backup DbreezeFolderName, there must be found at least TransJournal and Scheme. ////Configuration.Backup.SynchronizeBackup has more information //if (Configuration.Backup.IsActive) //{ // Configuration.Backup.DBreezeFolderName = Configuration.DBreezeDataFolderName; // ////Running backup synchronization // //Configuration.Backup.SynchronizeBackup(); //} //MainFolder = Configuration.DBreezeDataFolderName; //InitDb(); ////Console.WriteLine("DBreeze notification: Don't forget in the dispose function of your DLL or main application thread"); ////Console.WriteLine(" to dispose DBreeze engine: if(_engine != null) _engine.Dispose(); "); ////Console.WriteLine(" to get graceful finilization of all working threads! "); }
/// <summary> /// Constructing Dbreeze from dbreezeConfiguration /// </summary> /// <param name="dbreezeConfiguration"></param> internal void ConstructFromConfiguration(DBreezeConfiguration dbreezeConfiguration) { if (Configuration != null) { Configuration = dbreezeConfiguration; } else { throw new Exception("DBreeze.DBreezeEngine.DBreezeEngine: please supply DBreezeConfiguration"); } //Setting up in backup DbreezeFolderName, there must be found at least TransJournal and Scheme. //Configuration.Backup.SynchronizeBackup has more information if (Configuration.Backup.IsActive) { Configuration.Backup.DBreezeFolderName = Configuration.DBreezeDataFolderName; ////Running backup synchronization //Configuration.Backup.SynchronizeBackup(); } if (dbreezeConfiguration.Storage == DBreezeConfiguration.eStorage.RemoteInstance && !RemoteEngine) { throw new Exception("DBreeze.DBreezeEngine.DBreezeEngine: remote instance must be initiated via new DBreezeRemoteEngine"); } MainFolder = Configuration.DBreezeDataFolderName; InitDb(); //Console.WriteLine("DBreeze notification: Don't forget in the dispose function of your DLL or main application thread"); //Console.WriteLine(" to dispose DBreeze engine: if(_engine != null) _engine.Dispose(); "); //Console.WriteLine(" to get graceful finilization of all working threads! "); }
/// <summary> /// DBreezeRemoteEngine instantiator /// </summary> /// <param name="dbreezeConfiguration"></param> public DBreezeRemoteEngine(DBreezeConfiguration dbreezeConfiguration) { if (dbreezeConfiguration == null) throw new Exception("DBreeze.DbreezeRemoteEngine.DbreezeRemoteEngine: dbreezeConfiguration is NULL"); conf = dbreezeConfiguration; this.RemoteEngine = true; }
public DBreezeInstance(IPathProvider pathProvider) { var dbConf = new DBreezeConfiguration() { DBreezeDataFolderName = Path.Combine(pathProvider.BasePath, "DBR"), Storage = DBreezeConfiguration.eStorage.DISK }; this.engine = new DBreezeEngine(dbConf); }
/// <summary> /// DBreezeRemoteEngine instantiator /// </summary> /// <param name="dbreezeConfiguration"></param> public DBreezeRemoteEngine(DBreezeConfiguration dbreezeConfiguration) { if (dbreezeConfiguration == null) { throw new Exception("DBreeze.DbreezeRemoteEngine.DbreezeRemoteEngine: dbreezeConfiguration is NULL"); } conf = dbreezeConfiguration; this.RemoteEngine = true; }
/// <summary> /// Constructing Dbreeze from dbreezeConfiguration /// </summary> /// <param name="dbreezeConfiguration"></param> internal void ConstructFromConfiguration(DBreezeConfiguration dbreezeConfiguration) { if (Configuration != null) Configuration = dbreezeConfiguration; else throw new Exception("DBreeze.DBreezeEngine.DBreezeEngine: please supply DBreezeConfiguration"); //Setting up in backup DbreezeFolderName, there must be found at least TransJournal and Scheme. //Configuration.Backup.SynchronizeBackup has more information if (Configuration.Backup.IsActive) { Configuration.Backup.DBreezeFolderName = Configuration.DBreezeDataFolderName; ////Running backup synchronization //Configuration.Backup.SynchronizeBackup(); } if (dbreezeConfiguration.Storage == DBreezeConfiguration.eStorage.RemoteInstance && !RemoteEngine) throw new Exception("DBreeze.DBreezeEngine.DBreezeEngine: remote instance must be initiated via new DBreezeRemoteEngine"); MainFolder = Configuration.DBreezeDataFolderName; InitDb(); //Console.WriteLine("DBreeze notification: Don't forget in the dispose function of your DLL or main application thread"); //Console.WriteLine(" to dispose DBreeze engine: if(_engine != null) _engine.Dispose(); "); //Console.WriteLine(" to get graceful finilization of all working threads! "); }
public void CreateDbOnFsAndInsertAndSelectObject() { var conf = new DBreezeConfiguration { DBreezeDataFolderName = this.path, Storage = DBreezeConfiguration.eStorage.DISK }; using (var engine = new DBreezeEngine(conf)) using (var tran = engine.GetTransaction()) { var folder = new TestClass { Name = "Name" }; tran.Insert<int, DbCustomSerializer<TestClass>>("objects", 1, folder); tran.Commit(); Assert.AreEqual("Name", (tran.Select<int, DbCustomSerializer<TestClass>>("objects", 1).Value.Get as TestClass).Name); } }
public void GetObjectListOnPersistedStorage() { var conf = new DBreezeConfiguration { DBreezeDataFolderName = this.persistentDBreezePath, Storage = DBreezeConfiguration.eStorage.DISK }; using (var engine = new DBreezeEngine(conf)) { var storage = new FileTransmissionStorage(engine); for (int i = 1; i <= 10; ++i) { this.remoteFile.Setup(m => m.Id).Returns("RemoteObjectId" + i.ToString()); var obj = new FileTransmissionObject(TransmissionType.UPLOAD_NEW_FILE, this.localFile.Object, this.remoteFile.Object); Assert.DoesNotThrow(() => storage.SaveObject(obj)); Assert.That(storage.GetObjectList().Count, Is.EqualTo(i)); Assert.That(storage.GetObjectList().First(foo => foo.LocalPath == this.localFile.Object.FullName && foo.RemoteObjectId == "RemoteObjectId" + i.ToString()), Is.Not.Null); } } using (var engine = new DBreezeEngine(conf)) { var storage = new FileTransmissionStorage(engine); for (int i = 1; i <= 10; ++i) { Assert.That(storage.GetObjectList().First(foo => foo.LocalPath == this.localFile.Object.FullName && foo.RemoteObjectId == "RemoteObjectId" + i.ToString()), Is.Not.Null); } Assert.That(storage.GetObjectList().Count, Is.EqualTo(10)); } }
/// <summary> /// With backup /// </summary> public void StartTest() { lock (lockInitDb) { if (engine == null) { DBreezeConfiguration conf = new DBreezeConfiguration() { DBreezeDataFolderName = @"D:\temp\DBreezeTest\DBR1", // DBreezeDataFolderName = @"E:\temp\DBreezeTest\DBR1", // DBreezeDataFolderName = @"C:\tmp", Storage = DBreezeConfiguration.eStorage.DISK, // Storage = DBreezeConfiguration.eStorage.MEMORY, //Backup = new Backup() //{ // BackupFolderName = @"D:\temp\DBreezeTest\DBR1\Bup", // IncrementalBackupFileIntervalMin = 30 //} }; //conf.AlternativeTablesLocations.Add("t11",@"D:\temp\DBreezeTest\DBR1\INT"); //conf.AlternativeTablesLocations.Add("mem_*", String.Empty); //conf.AlternativeTablesLocations.Add("t2", @"D:\temp\DBreezeTest\DBR1\INT"); //conf.AlternativeTablesLocations.Add("t*", @"D:\temp\DBreezeTest\DBR1\INT"); engine = new DBreezeEngine(conf); } } // enumtest(); //MATRIX_BUILD(); // MATRIX_READOUT_V2(); // TestSecondaryIndexPreparation(); //TestNewStorageLayer(); // TestMemoryStorage(); //TestClosestToPrefix(); // testC6(); //testC7(); //testC8(); //testC9(); //testC10(); //testF_004(); // testF_003(); //testF_009(); // testF_010(); // testF_001(); //testC14(); //testC15(); //testC16(); //TestKrome(); //testF_002(); //TestSFI1(); //TestSFI2(); //TestMixedStorageMode(); //TestIterators(); //TestIteratorsv11(); //testbackwardwithStrings(); //TestBackUp(); //TestSelectBackwardStartWith_WRITE(); //TestSelectBackwardStartWith_READ(); //TR(); //NetworkTest(); //NetworkTestDisk(); Test_valueIsUsed(); }
public void NetworkTestDisk() { if (engine == null) { DBreezeConfiguration conf = new DBreezeConfiguration() { DBreezeDataFolderName = @"D:\temp\DBreezeTest\TestPuppy", Storage = DBreezeConfiguration.eStorage.DISK, }; engine = new DBreezeEngine(conf); } //using (var tran = engine.GetTransaction()) //{ // tran.Insert<int, string>("t1", 1, "dsfsfsdfsdfsdf"); // tran.Commit(); //} using (var tran = engine.GetTransaction()) { Console.WriteLine(tran.Count("t1")); var row = tran.Select<int, string>("t1", 1); if (row.Exists) Console.WriteLine(row.Value); } }
// <summary> /// /// </summary> public void NetworkTest() { if (remoteEngine == null) { DBreezeConfiguration conf = new DBreezeConfiguration() { // DBreezeDataFolderName = @"D:\temp\DBreezeTest\DBR1", DBreezeDataFolderName = @"TestPuppy", //Here must be folder name in protoected database, later we have to take care alternative locations. Storage = DBreezeConfiguration.eStorage.RemoteInstance, }; conf.RICommunicator = new RemoteInstanceCommunicator(); remoteEngine = new DBreezeRemoteEngine(conf); } //using (var tran = remoteEngine.GetTransaction()) //{ // for (int i = 1; i < 100000; i++) // tran.Insert<int, string>("t1", i, "ds" + i); // tran.Commit(); //} using (var tran = remoteEngine.GetTransaction()) { Console.WriteLine(tran.Count("t1")); var row = tran.Select<int, string>("t1", 700); if (row.Exists) Console.WriteLine(row.Value); } }