public StorageEnvironment(StorageEnvironmentOptions options) { try { _log = LoggingSource.Instance.GetLogger <StorageEnvironment>(options.BasePath); _options = options; _dataPager = options.DataPager; _freeSpaceHandling = new FreeSpaceHandling(); _headerAccessor = new HeaderAccessor(this); _options.DeleteAllTempBuffers(); _decompressionBuffers = new DecompressionBuffersPool(options); var isNew = _headerAccessor.Initialize(); _scratchBufferPool = new ScratchBufferPool(this); if (PlatformDetails.RunningOnPosix && options.BasePath != null && IsStorageSupportingO_Direct(options.BasePath) == false) { options.SafePosixOpenFlags &= ~PerPlatformValues.OpenFlags.O_DIRECT; var message = "Path " + options.BasePath + " not supporting O_DIRECT writes. As a result - data durability is not guarenteed"; _options.InvokeNonDurabaleFileSystemError(this, message, null); } options.PosixOpenFlags = options.SafePosixOpenFlags; _journal = new WriteAheadJournal(this); if (isNew) { CreateNewDatabase(); } else // existing db, let us load it { LoadExistingDatabase(); } if (_options.ManualFlushing == false) { Task.Run(IdleFlushTimer); } } catch (Exception) { Dispose(); throw; } }
public StorageEnvironment(StorageEnvironmentOptions options) { try { _log = LoggingSource.Instance.GetLogger <StorageEnvironment>(options.BasePath.FullPath); _options = options; _dataPager = options.DataPager; _freeSpaceHandling = new FreeSpaceHandling(); _headerAccessor = new HeaderAccessor(this); NumOfConcurrentSyncsPerPhysDrive = options.NumOfConcurrentSyncsPerPhysDrive; TimeToSyncAfterFlashInSec = options.TimeToSyncAfterFlashInSec; Debug.Assert(_dataPager.NumberOfAllocatedPages != 0); var remainingBits = _dataPager.NumberOfAllocatedPages % (8 * sizeof(long)); _validPages = new long[_dataPager.NumberOfAllocatedPages / (8 * sizeof(long)) + (remainingBits == 0 ? 0 : 1)]; _validPages[_validPages.Length - 1] |= unchecked (((long)ulong.MaxValue << (int)remainingBits)); _decompressionBuffers = new DecompressionBuffersPool(options); var isNew = _headerAccessor.Initialize(); _scratchBufferPool = new ScratchBufferPool(this); options.SetPosixOptions(); _journal = new WriteAheadJournal(this); if (isNew) { CreateNewDatabase(); } else // existing db, let us load it { LoadExistingDatabase(); } if (_options.ManualFlushing == false) { Task.Run(IdleFlushTimer); } } catch (Exception) { Dispose(); throw; } }