protected void CreateNextFile(ITransaction metadataTransaction) { StorageConfiguration cloneConfig = (StorageConfiguration)_userConfig.Clone(); cloneConfig.StorageProvider.DatabasePath = cloneConfig.StorageProvider.DatabasePath + _userConfig.StorageProvider.DatabaseId + "\\"; bool createFile = false; if (!_fileMetadataDictionary.ContainsKey(GetFullDbId(_dbIndex))) { createFile = true; } else { //if provider does exist i.e. already loaded probably due to regenration of metadata // then check for if it is full or expansion possible if (_fileMetadataDictionary[GetFullDbId(_dbIndex)].Provider.IsDatabaseFull()) { createFile = true; } } if (createFile) { _dbIndex++; cloneConfig.StorageProvider.DatabaseId = GetFullDbId(_dbIndex); if (LoggerManager.Instance.StorageLogger != null && LoggerManager.Instance.StorageLogger.IsInfoEnabled) { LoggerManager.Instance.StorageLogger.Info("StorageProvider.CreateNextFile", "Creating File " + cloneConfig.StorageProvider.DatabasePath + cloneConfig.StorageProvider.DatabaseId); } FileMetadata <long, byte[]> fMetadata = new FileMetadata <long, byte[]>(ProviderFactory.CreateProvider(cloneConfig.StorageProvider.StorageProviderType), cloneConfig); PersistFileMetadata(cloneConfig.StorageProvider.DatabaseId, fMetadata, metadataTransaction); } }
public virtual bool Initialize(StorageConfiguration configuration, StatsIdentity statsIdentity) { _userConfig = (StorageConfiguration)configuration.Clone(); if (configuration == null || configuration.StorageProvider == null) { throw new ConfigurationException("PersistenceProvider configuration not found."); } _statsCollector = StatsManager.Instance.GetStatsCollector(statsIdentity); RegenerateMetaData(); ITransaction transaction = _metadataPersister.BeginTransaction(null, false); CreateNextFile(transaction); _metadataPersister.Commit(transaction); DisplaySize(); return(true); }