Пример #1
0
        public BinaryStorage(StorageConfiguration configuration)
        {
            var storageFilePath = Path.Combine(configuration.WorkingFolder, configuration.StorageFileName);
            var indexFilePath   = Path.Combine(configuration.WorkingFolder, configuration.IndexFileName);

            _index   = new ThreadSafeIndex(new PersistentIndex(indexFilePath), configuration.IndexTimeout);
            _storage = new FileStorage(storageFilePath);
        }
Пример #2
0
        /// <summary>
        /// Initializes new instance of <see cref="BinaryStorage"/> class.
        /// </summary>
        /// <param name="configuration">The configuration parameters for binary storage</param>
        public BinaryStorage(StorageConfiguration configuration)
        {
            binaryStorageFactory = new BinaryStorageFactory(configuration);

            cancellationOnDispose = new CancellationTokenSource();

            var blockProvider = binaryStorageFactory.CreateIndexFileBlockProvider();
            binaryStorageIndex = binaryStorageFactory.CreateBinaryStorageIndex(blockProvider);
            storageFileAppender = binaryStorageFactory.CreateStorageFileAppender(binaryStorageIndex);
            storageFileReader = binaryStorageFactory.CreateStorageFileReader();
        }
Пример #3
0
        public BinaryStorage(StorageConfiguration configuration)
        {
            /// Theses values must be set in TestApp project,
            /// but I didn't want to change it because it was mentioned not to change the test
            configuration.MaxIndexFile   = int.Parse(Utility.GetAppSetting(Constant.AppSetting_IndexSizeLimitInKB)) * 1024;
            configuration.MaxStorageFile = int.Parse(Utility.GetAppSetting(Constant.AppSetting_StorageFileSizeLimitInKB)) * 1024;

            _configuration   = configuration;
            _storageFilePath = GetStorageFileName(_configuration.WorkingFolder);
            if (!StorageIndex.IsInit) // it is the first execution
            {
                Init();
            }
        }
Пример #4
0
        public BinaryStorage(StorageConfiguration configuration)
        {
            this.storageConfiguration  = configuration;
            this.indexTable            = new ConcurrentDictionary <string, BinaryIndex>();
            this.indexFilePath         = Path.Combine(configuration.WorkingFolder, IndexFileName);
            this.storageFilePath       = Path.Combine(configuration.WorkingFolder, StorageFileName);
            this.backupStorageFilePath = Path.Combine(configuration.WorkingFolder, this.backupStorageFileName);

            this.indexTableBuffer = new ConcurrentDictionary <string, BinaryIndex>();
            this.storageBuffer    = new ConcurrentQueue <byte[]>();

            ConfigureStorageCache();
            if (File.Exists(this.indexFilePath) && File.Exists(this.storageFilePath))
            {
                LoadIndex();
            }
            else
            {
                SaveIndex();
                CreateStorage();
            }
        }
Пример #5
0
 /// <summary>
 /// Initializes new instance of <see cref="BinaryStorageFactory"/> class.
 /// </summary>
 /// <param name="configuration">The configuration parameters for binary storage components</param>
 /// <exception cref="System.ArgumentNullException">configuration is null</exception>
 public BinaryStorageFactory(StorageConfiguration configuration)
 {
     this.configuration = configuration.ThrowIfNull(nameof(configuration));
     streamFactory      = new StreamFactory(configuration);
 }