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)); } }
public MSR(string fileName, TrieSettings trieSettings, DBreezeConfiguration configuration) { this._fileName = fileName; this._configuration = configuration; this._trieSettings = trieSettings; DefaultPointerLen = this._trieSettings.POINTER_LENGHT; InitFiles(); }
public DbreezeCustomerRepository(DirectoryInfo folder) { _dBreezeConfiguration = new DBreezeConfiguration { DBreezeDataFolderName = folder.FullName }; _engine = new DBreezeEngine(_dBreezeConfiguration); //Setting default serializer for DBreeze CustomSerializator.ByteArraySerializator = ProtobufSerializer.SerializeProtobuf; CustomSerializator.ByteArrayDeSerializator = ProtobufSerializer.DeserializeProtobuf; }
public DBreezeEngine(IDBreezeConfig config) { this.config = config; var dbConfig = new DBreezeConfiguration() { DBreezeDataFolderName = config.RootCacheDirectory, Storage = config.StorageBackend }; engine = new global::DBreeze.DBreezeEngine(dbConfig); }
public NosqlPersistence(string path) { this.path = path; isObject = !typeof(T).IsValueType; var configuration = new DBreezeConfiguration { DBreezeDataFolderName = path }; db = new DBreezeEngine(configuration); transaction = db.GetTransaction(); commitTimer = new Timer(CommitTimerFired, null, MaxUncommittedTime, MaxUncommittedTime); }
public FSR(string fileName, TrieSettings trieSettings, DBreezeConfiguration configuration) { this._fileName = fileName; this._configuration = configuration; this._trieSettings = trieSettings; DefaultPointerLen = this._trieSettings.POINTER_LENGHT; _backupIsActive = this._configuration.Backup.IsActive; //Transforms fileName into ulong digit ulFileName = this._configuration.Backup.BackupFNP.ParseFilename(Path.GetFileNameWithoutExtension(this._fileName)); InitFiles(); }
/// <summary> /// /// </summary> static Datalog() { string _path = YamlConfig.ServerConfSetting.GetPath("\\Data"); DBreezeConfiguration conf = new DBreezeConfiguration() { DBreezeDataFolderName = _path, Storage = DBreezeConfiguration.eStorage.DISK, }; dbEngine = new DBreezeEngine(conf); DBreeze.Utils.CustomSerializator.ByteArraySerializator = ProtobufSerializer.SerializeProtobuf; DBreeze.Utils.CustomSerializator.ByteArrayDeSerializator = ProtobufSerializer.DeserializeProtobuf; }
public StorageLayer(string fileName, TrieSettings trieSettings, DBreezeConfiguration configuration) { if (trieSettings.StorageWasOverriden) { switch (trieSettings.AlternativeTableStorageType) { case DBreezeConfiguration.eStorage.DISK: _tableStorage = (IStorage) new FSR(fileName, trieSettings, configuration); break; case DBreezeConfiguration.eStorage.MEMORY: _tableStorage = (IStorage) new MSR(fileName, trieSettings, configuration); break; case DBreezeConfiguration.eStorage.RemoteInstance: _tableStorage = (IStorage) new RISR(fileName, trieSettings, configuration); break; } } else { switch (configuration.Storage) { case DBreezeConfiguration.eStorage.DISK: _tableStorage = (IStorage) new FSR(fileName, trieSettings, configuration); break; case DBreezeConfiguration.eStorage.MEMORY: _tableStorage = (IStorage) new MSR(fileName, trieSettings, configuration); break; case DBreezeConfiguration.eStorage.RemoteInstance: _tableStorage = (IStorage) new RISR(fileName, trieSettings, configuration); break; } } }
public static DBreezeEngine GetDatabaseEngine(string dbPath) { if (db == null || DbPath != dbPath) { DbPath = dbPath; var databasePath = string.IsNullOrEmpty(dbPath) ? ApplicationData.Current.LocalFolder.Path + @"\EReaderDB" : dbPath; var dbConfig = new DBreezeConfiguration() { DBreezeDataFolderName = databasePath, Storage = DBreezeConfiguration.eStorage.DISK }; db = new DBreezeEngine(dbConfig); } return(db); }
public static DBreezeEngine GetDatabaseEngine(string dbPath) { if (_db == null || DbPath != dbPath) { DbPath = dbPath; var dbConfig = new DBreezeConfiguration { DBreezeDataFolderName = dbPath, Storage = DBreezeConfiguration.eStorage.DISK }; _db = new DBreezeEngine(dbConfig); IsDisposed = false; } return(_db); }
public static DBreezeEngine GetDatabaseEngine(string dbPath) { if (_db == null || DbPath != dbPath || _db.Disposed || !_db.IsDatabaseOperable) { BLogger.I("Initializing db engine. Path: {path}", dbPath); DbPath = dbPath; var dbConfig = new DBreezeConfiguration { DBreezeDataFolderName = dbPath, Storage = DBreezeConfiguration.eStorage.DISK }; _db = new DBreezeEngine(dbConfig); IsDisposed = false; BLogger.I("Db engine initialized. Path: {path}", dbPath); } return(_db); }
public RISR(string fileName, TrieSettings trieSettings, DBreezeConfiguration configuration) { this._fileName = fileName; this._configuration = configuration; this._trieSettings = trieSettings; DefaultPointerLen = this._trieSettings.POINTER_LENGTH; _backupIsActive = this._configuration.Backup.IsActive; //Transforms fileName into ulong digit ulFileName = this._configuration.Backup.BackupFNP.ParseFilename(Path.GetFileNameWithoutExtension(this._fileName)); //Setting up RemoteCommander RIC = new DBreeze.Storage.RemoteInstance.RemoteInstanceCommander(configuration.RICommunicator); InitFiles(); }
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 StorageLayer(string fileName, TrieSettings trieSettings, DBreezeConfiguration configuration) { if (trieSettings.StorageWasOverriden) { switch (trieSettings.AlternativeTableStorageType) { case DBreezeConfiguration.eStorage.DISK: _tableStorage = (IStorage) new FSR(fileName, trieSettings, configuration); break; case DBreezeConfiguration.eStorage.MEMORY: _tableStorage = (IStorage)new MSR(fileName, trieSettings, configuration); break; case DBreezeConfiguration.eStorage.RemoteInstance: _tableStorage = (IStorage)new RISR(fileName, trieSettings, configuration); break; } } else { switch (configuration.Storage) { case DBreezeConfiguration.eStorage.DISK: _tableStorage = (IStorage)new FSR(fileName, trieSettings, configuration); break; case DBreezeConfiguration.eStorage.MEMORY: _tableStorage = (IStorage)new MSR(fileName, trieSettings, configuration); break; case DBreezeConfiguration.eStorage.RemoteInstance: _tableStorage = (IStorage)new RISR(fileName, trieSettings, configuration); break; } } }
public DatabaseConnection() { DBreezeDataFolderName = Path.Combine(ClientConfigReader.NodeCommanderDataDirectory, "dBreeze"); EngineConfiguration = new DBreezeConfiguration() { DBreezeDataFolderName = DBreezeDataFolderName, }; Engine = new DBreezeEngine(EngineConfiguration); CustomSerializator.ByteArraySerializator = (object o) => { return(NetJSON.NetJSON.Serialize(o).To_UTF8Bytes()); }; CustomSerializator.ByteArrayDeSerializator = (byte[] bt, Type t) => { return(NetJSON.NetJSON.Deserialize(t, bt.UTF8_GetString())); }; Engine.Scheme.DeleteTable("BlockchainHeight"); Engine.Scheme.DeleteTable("TS_BlockchainHeight"); Engine.Scheme.DeleteTable("Mining"); Engine.Scheme.DeleteTable("TS_Mining"); Engine.Scheme.DeleteTable("Reorg"); Engine.Scheme.DeleteTable("TS_Reorg"); }
public DBreezeWrapper(string databaseDirectory, string backupDirectoryPath, uint backupInterval = 300) { _databaseDirectory = databaseDirectory; _backupDirectoryPath = backupDirectoryPath; _backupInterval = backupInterval; if (IsDirectoryLocked(databaseDirectory) == true) { throw new Exception("Error in DBreezeWrapper::DBreezeWrapper. Database directory is locked!"); } if (IsDirectoryLocked(backupDirectoryPath) == true) { throw new Exception("Error in DBreezeWrapper::DBreezeWrapper. Backup database directory is locked!"); } DirectoryInfo directoryInfo = new DirectoryInfo(databaseDirectory); if (directoryInfo.Exists == false) { directoryInfo.Create(); } directoryInfo = new DirectoryInfo(backupDirectoryPath); if (directoryInfo.Exists == false) { directoryInfo.Create(); } try { _configDBreeze = new DBreezeConfiguration(); _configDBreeze.DBreezeDataFolderName = databaseDirectory; _dBreezeEngine = new DBreezeEngine(_configDBreeze); _backup = _configDBreeze.Backup; _backup.IncrementalBackupFileIntervalMin = _backupInterval; _backup.BackupFolderName = BackupDirectoryPath; } catch (Exception ex) { Dispose(); throw ex; } }
public DbReezeModuleConfiguration() { Configuration = new DBreezeConfiguration(); }
//public TcpRaftNode(List<TcpClusterEndPoint> clusterEndPoints, List<RaftNodeSettings> raftNodes, string dbreezePath, Func<string, ulong, byte[], bool> OnCommit, int port = 4250, IWarningLog log = null) //public TcpRaftNode(List<TcpClusterEndPoint> clusterEndPoints, List<RaftEntitySettings> raftNodes, string dbreezePath, Func<string, ulong, byte[], bool> OnCommit, int port = 4250, IWarningLog log = null) public TcpRaftNode(NodeSettings nodeSettings, string dbreezePath, Func <string, ulong, byte[], bool> OnCommit, int port = 4250, IWarningLog log = null) { if (nodeSettings == null) { nodeSettings = new NodeSettings(); } this.NodeSettings = nodeSettings; this.log = log; this.port = port; DBreezeConfiguration conf = new DBreezeConfiguration() { DBreezeDataFolderName = dbreezePath, Storage = DBreezeConfiguration.eStorage.DISK, }; conf.AlternativeTablesLocations.Add("mem_*", String.Empty); dbEngine = new DBreezeEngine(conf); //if (clusterEndPoints != null) //{ // var bt = clusterEndPoints.SerializeBiser(); // var decoder = new Biser.Decoder(bt); // this.clusterEndPoints = new List<TcpClusterEndPoint>(); // decoder.GetCollection(() => { return TcpClusterEndPoint.BiserDecode(extDecoder: decoder); }, this.clusterEndPoints, false); // //this.clusterEndPoints.AddRange(clusterEndPoints.SerializeProtobuf().DeserializeProtobuf<List<TcpClusterEndPoint>>()); //} spider = new TcpSpider(this); //bool firstNode = true; if (this.NodeSettings.RaftEntitiesSettings == null) { this.NodeSettings.RaftEntitiesSettings = new List <RaftEntitySettings>(); } if (this.NodeSettings.RaftEntitiesSettings.Where(r => r.EntityName.ToLower() == "default").Count() < 1) { this.NodeSettings.RaftEntitiesSettings.Add(new RaftEntitySettings()); } foreach (var re_settings in this.NodeSettings.RaftEntitiesSettings) { //if (firstNode) //{ // re_settings.EntityName = "default"; // firstNode = false; //} if (String.IsNullOrEmpty(re_settings.EntityName)) { throw new Exception("Raft.Net: entities must have unique names. Change RaftNodeSettings.EntityName."); } if (this.raftNodes.ContainsKey(re_settings.EntityName)) { throw new Exception("Raft.Net: entities must have unique names. Change RaftNodeSettings.EntityName."); } var rn = new RaftNode(re_settings ?? new RaftEntitySettings(), this.dbEngine, this.spider, this.log, OnCommit); #if DEBUG rn.Verbose = re_settings.VerboseRaft; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DEBUG PURPOSES #endif rn.SetNodesQuantityInTheCluster((uint)this.NodeSettings.TcpClusterEndPoints.Count); //!!!!!!!!!!!! ENABLE 1 for debug, make it dynamic (but not less then 3 if not DEBUG) rn.NodeAddress.NodeAddressId = port; //for debug/emulation purposes rn.NodeAddress.NodeUId = Guid.NewGuid().ToByteArray().Substring(8, 8).To_Int64_BigEndian(); this.raftNodes[re_settings.EntityName] = rn; rn.NodeStart(); } }
public RISR(string fileName, TrieSettings trieSettings, DBreezeConfiguration configuration) { this._fileName = fileName; this._configuration = configuration; this._trieSettings = trieSettings; DefaultPointerLen = this._trieSettings.POINTER_LENGTH; _backupIsActive = this._configuration.Backup.IsActive; //Transforms fileName into ulong digit ulFileName = this._configuration.Backup.BackupFNP.ParseFilename(Path.GetFileNameWithoutExtension(this._fileName)); //Setting up RemoteCommander RIC = new DBreeze.Storage.RemoteInstance.RemoteInstanceCommander(configuration.RICommunicator); InitFiles(); }
public Backup(DBreezeConfiguration configuration) { this.configuration = configuration; }
/// <summary> /// RemoteTablesHandler /// </summary> /// <param name="configuration">configuration.DBreezeDataFolderName must be filled and for portable IFileSystemFactory instantiated</param> public RemoteTablesHandler(DBreezeConfiguration configuration) { this.configuration = configuration; }
/// <summary> /// /// </summary> /// <param name="backupFolderName">Folder where will be restored incremental backup</param> public Backup(string backupFolderName, DBreezeConfiguration configuration) { this.configuration = configuration; this._backupFolderName = backupFolderName; this.InitBackupFolder(); }
/// <summary> /// RemoteTablesHandler /// </summary> /// <param name="configuration">configuration.DBreezeDataFolderName must be filled and for portable IFileSystemFactory instantiated</param> public RemoteTablesHandler(DBreezeConfiguration configuration) { this.configuration = configuration; }
public Backup(DBreezeConfiguration configuration) { this.configuration = configuration; }
/// <summary> /// /// </summary> /// <param name="backupFolderName">Folder where will be restored incremental backup</param> public Backup(string backupFolderName, DBreezeConfiguration configuration) { this.configuration = configuration; this._backupFolderName = backupFolderName; this.InitBackupFolder(); }
public FSR(string fileName, TrieSettings trieSettings, DBreezeConfiguration configuration) { this._fileName = fileName; this._configuration = configuration; this._trieSettings = trieSettings; DefaultPointerLen = this._trieSettings.POINTER_LENGTH; _backupIsActive = this._configuration.Backup.IsActive; //Transforms fileName into ulong digit ulFileName = this._configuration.Backup.BackupFNP.ParseFilename(Path.GetFileNameWithoutExtension(this._fileName)); InitFiles(); }
public MSR(string fileName, TrieSettings trieSettings,DBreezeConfiguration configuration) { this._fileName = fileName; this._configuration = configuration; this._trieSettings = trieSettings; DefaultPointerLen = this._trieSettings.POINTER_LENGTH; InitFiles(); }
/// <summary> /// FSFactory /// </summary> /// <param name="configuration">configuration.FSFactory must be instantiated for portable</param> public BackupRestorer(DBreezeConfiguration configuration) { this.configuration = configuration; }