Пример #1
0
        public async Task InitializeAsync()
        {
            if (_initialized != null)
            {
                throw new InvalidOperationException("InitializeAsync has already been called");
            }

            var doesExist = await _storageFacade.DoesExistAsync(_blobName);

            if (!doesExist)
            {
                await _storageFacade.CreateEmptyBlockBlobAsync(_blobName);
            }

            var leaseController = new LeaseController(_logger, _storageFacade);
            var lease           = await leaseController.AcquireLeaseAsync(
                _blobName,
                TimeSpan.FromMinutes(1));

            if (lease == null)
            {
                throw new CosbakException($"Can't lease '{_blobName}' blob");
            }
            else
            {
                var blocks = await _storageFacade.GetBlocksAsync(_blobName);

                var indexFat = blocks.Count == 0
                    ? new IndexFat()
                    : await LoadFatAsync((int)blocks[0].Length);

                _initialized = new Initialized(lease, indexFat);
            }
        }
Пример #2
0
        public async Task InitializeAsync()
        {
            if (_initialized != null)
            {
                throw new InvalidOperationException("InitializeAsync has already been called");
            }

            var snapshotTime = await _storageFacade.SnapshotAsync(_blobName);

            var blocks = await _storageFacade.GetBlocksAsync(_blobName, snapshotTime);

            var logFat = blocks.Count == 0
                ? new LogFat()
                : await LoadFatAsync((int)blocks[0].Length, snapshotTime);

            _initialized = new Initialized(snapshotTime, logFat, blocks);
        }