コード例 #1
0
        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));
            }
        }
コード例 #2
0
ファイル: MSR.cs プロジェクト: EnergonV/BestCS
        public MSR(string fileName, TrieSettings trieSettings, DBreezeConfiguration configuration)
        {
            this._fileName      = fileName;
            this._configuration = configuration;
            this._trieSettings  = trieSettings;
            DefaultPointerLen   = this._trieSettings.POINTER_LENGHT;

            InitFiles();
        }
コード例 #3
0
        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;
        }
コード例 #4
0
ファイル: DBreezeEngine.cs プロジェクト: yjpark/liget
        public DBreezeEngine(IDBreezeConfig config)
        {
            this.config = config;
            var dbConfig = new DBreezeConfiguration()
            {
                DBreezeDataFolderName = config.RootCacheDirectory,
                Storage = config.StorageBackend
            };

            engine = new global::DBreeze.DBreezeEngine(dbConfig);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: FSR.cs プロジェクト: EnergonV/BestCS
        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();
        }
コード例 #7
0
        /// <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;
        }
コード例 #8
0
        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;
                }
            }
        }
コード例 #9
0
 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);
 }
コード例 #10
0
 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);
 }
コード例 #11
0
 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);
 }
コード例 #12
0
ファイル: RISR.cs プロジェクト: wangchengqun/ratel
        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();
        }
コード例 #13
0
        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);
                }
        }
コード例 #14
0
ファイル: StorageLayer.cs プロジェクト: hhblaze/DBreeze
        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;
                }
            }
        }
コード例 #15
0
        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");
        }
コード例 #16
0
        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;
            }
        }
コード例 #17
0
 public DbReezeModuleConfiguration()
 {
     Configuration = new DBreezeConfiguration();
 }
コード例 #18
0
ファイル: TcpRaftNode.cs プロジェクト: ww-it/Raft.Net
        //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();
            }
        }
コード例 #19
0
ファイル: RISR.cs プロジェクト: hhblaze/DBreeze
        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();
        }
コード例 #20
0
ファイル: Backup.cs プロジェクト: wondial/DBreeze
 public Backup(DBreezeConfiguration configuration)
 {
     this.configuration = configuration;
 }
コード例 #21
0
 /// <summary>
 /// RemoteTablesHandler
 /// </summary>
 /// <param name="configuration">configuration.DBreezeDataFolderName must be filled and for portable IFileSystemFactory instantiated</param>
 public RemoteTablesHandler(DBreezeConfiguration configuration)
 {
     this.configuration = configuration;
 }
コード例 #22
0
ファイル: Backup.cs プロジェクト: wondial/DBreeze
 /// <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();
 }
コード例 #23
0
 /// <summary>
 /// RemoteTablesHandler
 /// </summary>
 /// <param name="configuration">configuration.DBreezeDataFolderName must be filled and for portable IFileSystemFactory instantiated</param>
 public RemoteTablesHandler(DBreezeConfiguration configuration)
 {
     this.configuration = configuration;
 }
コード例 #24
0
ファイル: Backup.cs プロジェクト: hhblaze/DBreeze
 public Backup(DBreezeConfiguration configuration)
 {
     this.configuration = configuration;
 }
コード例 #25
0
ファイル: Backup.cs プロジェクト: hhblaze/DBreeze
 /// <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();
 }
コード例 #26
0
ファイル: FSR.cs プロジェクト: hhblaze/DBreeze
        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();
        }
コード例 #27
0
ファイル: MSR.cs プロジェクト: hhblaze/DBreeze
        public MSR(string fileName, TrieSettings trieSettings,DBreezeConfiguration configuration)
        {
            this._fileName = fileName;
            this._configuration = configuration;
            this._trieSettings = trieSettings;
            DefaultPointerLen = this._trieSettings.POINTER_LENGTH;

            InitFiles();
        }
コード例 #28
0
 /// <summary>
 /// FSFactory
 /// </summary>
 /// <param name="configuration">configuration.FSFactory must be instantiated for portable</param>
 public BackupRestorer(DBreezeConfiguration configuration)
 {
     this.configuration = configuration;
 }