Esempio n. 1
0
        protected override async Task <Result <string> > UploadFileCoreAsync(OperationContext context, AbsolutePath file, string blobName, bool garbageCollect = false)
        {
            // Add the file to CAS and register with global content location store.
            var putResult = await PutAndRegisterFileAsync(context, file, hash : null);

            if (putResult.Succeeded && _configuration.ProactiveCopyCheckpointFiles)
            {
                var hashWithSize = new ContentHashWithSize(putResult.ContentHash, putResult.ContentSize);
                var pushResult   = await PushCheckpointFileAsync(context, hashWithSize)
                                   .FireAndForgetOrInlineAsync(context, _configuration.InlineCheckpointProactiveCopies);

                if (!pushResult.Succeeded)
                {
                    return(new Result <string>(pushResult));
                }
            }

            string fallbackStorageId = await _fallbackStorage.UploadFileAsync(
                context,
                file,
                name : $"{blobName}.{putResult.ContentHash.Serialize(delimiter: '.')}",
                garbageCollect).ThrowIfFailureAsync();

            return(CreateCompositeStorageId(putResult.ContentHash, fallbackStorageId));
        }
Esempio n. 2
0
        private async Task CreateFullCheckpointAsync(OperationContext context, EventSequencePoint sequencePoint)
        {
            // Zipping the checkpoint
            var targetZipFile = _checkpointStagingDirectory + ".zip";

            File.Delete(targetZipFile);
            ZipFile.CreateFromDirectory(_checkpointStagingDirectory.ToString(), targetZipFile);

            // Track checkpoint size
            var fileInfo = new System.IO.FileInfo(targetZipFile);

            _tracer.TrackMetric(context, CheckpointSizeMetricName, fileInfo.Length);

            var checkpointBlobName = $"checkpoints/{sequencePoint.SequenceNumber}.{Guid.NewGuid()}.zip";
            var checkpointId       = await _storage.UploadFileAsync(context, new AbsolutePath(targetZipFile), checkpointBlobName, garbageCollect : true).ThrowIfFailureAsync();

            // Uploading the checkpoint
            await _checkpointRegistry.RegisterCheckpointAsync(context, checkpointId, sequencePoint).ThrowIfFailure();
        }
Esempio n. 3
0
        protected override async Task <Result <string> > UploadFileCoreAsync(OperationContext context, AbsolutePath file, string blobName, bool garbageCollect = false)
        {
            // Add the file to CAS and register with global content location store.
            var putResult = await PutFileAsync(context, file, hash : null, isUpload : true);

            string fallbackStorageId = await _fallbackStorage.UploadFileAsync(
                context,
                file,
                name : $"{blobName}.{putResult.ContentHash.Serialize(delimiter: '.')}",
                garbageCollect).ThrowIfFailureAsync();

            return(CreateCompositeStorageId(putResult.ContentHash, fallbackStorageId));
        }