/// <inheritdoc /> public Task <BoolResult> StartupAsync(Context context) { StartupStarted = true; return(StartupCall <MemoizationStoreTracer> .RunAsync(Tracer.MemoizationStoreTracer, context, async() => { BoolResult result; var backingContentSessionTask = Task.Run(async() => await BackingContentSession.StartupAsync(context).ConfigureAwait(false)); var writeThroughContentSessionResult = WriteThroughContentSession != null ? await WriteThroughContentSession.StartupAsync(context).ConfigureAwait(false) : BoolResult.Success; var backingContentSessionResult = await backingContentSessionTask.ConfigureAwait(false); if (backingContentSessionResult.Succeeded && writeThroughContentSessionResult.Succeeded) { _taskTracker = new BackgroundTaskTracker(Component, new Context(context)); result = BoolResult.Success; } else { var sb = new StringBuilder(); if (backingContentSessionResult.Succeeded) { var r = await BackingContentSession.ShutdownAsync(context).ConfigureAwait(false); if (!r.Succeeded) { sb.Append($"Backing content session shutdown failed, error=[{r}]"); } } else { sb.Append($"Backing content session startup failed, error=[{backingContentSessionResult}]"); } if (writeThroughContentSessionResult.Succeeded) { var r = WriteThroughContentSession != null ? await WriteThroughContentSession.ShutdownAsync(context).ConfigureAwait(false) : BoolResult.Success; if (!r.Succeeded) { sb.Append(sb.Length > 0 ? ", " : string.Empty); sb.Append($"Write-through content session shutdown failed, error=[{r}]"); } } else { sb.Append(sb.Length > 0 ? ", " : string.Empty); sb.Append($"Write-through content session startup failed, error=[{writeThroughContentSessionResult}]"); } result = new BoolResult(sb.ToString()); } StartupCompleted = true; return result; })); }
protected override async Task <BoolResult> StartupCoreAsync(OperationContext context) { await _sourceContentSession.StartupAsync(context).ThrowIfFailure(); _publisher = CreatePublisher(_name, _config, _pat, context); await _publisher.StartupAsync(context).ThrowIfFailure(); return(BoolResult.Success); }
/// <inheritdoc /> public Task <BoolResult> StartupAsync(Context context) { StartupStarted = true; return(StartupCall <ContentSessionTracer> .RunAsync(_tracer, context, async() => { var startupResults = await Task.WhenAll(_sessionForStream.StartupAsync(context), _sessionForPath.StartupAsync(context)); Contract.Assert(startupResults.Length == 2); var startupResultForStream = startupResults[0]; var startupResultForPath = startupResults[1]; var result = startupResultForStream & startupResultForPath; if (!result.Succeeded) { var sb = new StringBuilder(); if (!startupResultForStream.Succeeded) { sb.Concat($"{SessionForStreamText} startup failed, error=[{startupResultForStream}]", "; "); } if (!startupResultForPath.Succeeded) { sb.Concat($"{SessionForPathText} startup failed, error=[{startupResultForPath}]", "; "); } if (startupResultForStream.Succeeded) { var shutdownResult = await _sessionForStream.ShutdownAsync(context); if (!shutdownResult.Succeeded) { sb.Concat($"{SessionForStreamText} shutdown failed, error=[{shutdownResult}]", "; "); } } if (startupResultForPath.Succeeded) { var shutdownResult = await _sessionForPath.ShutdownAsync(context); if (!shutdownResult.Succeeded) { sb.Concat($"{SessionForPathText} shutdown failed, error=[{shutdownResult}]", "; "); } } result = new BoolResult(sb.ToString()); } StartupCompleted = true; return result; })); }
/// <inheritdoc /> protected override async Task <BoolResult> StartupCoreAsync(OperationContext context) { await _innerStore.StartupAsync(context).ThrowIfFailure(); // Create long-lived session to be used with overlay (ImplicitPin=None (i.e false) to avoid cache full errors) _backingContentSession = _innerStore.CreateSession(context, "VFSInner", ImplicitPin.None).ThrowIfFailure().Session; await _backingContentSession.StartupAsync(context).ThrowIfFailure(); _contentManager = new VfsContentManager(_logger, Configuration, _backingContentSession); return(await _contentManager.StartupAsync(context)); }
public Task TestColdStorageWithBulkFunction() { return(RunTestAsync(async(context, store, directory) => { var originalPath = directory.Path / "original.txt"; var fileContents = GetRandomFileContents(); // Build destination IContentSession DisposableDirectory sessionDirectory = new DisposableDirectory(FileSystem); ConfigurationModel configurationModel = new ConfigurationModel(new ContentStoreConfiguration(new MaxSizeQuota("10MB"))); FileSystemContentStore destination = new FileSystemContentStore(FileSystem, SystemClock.Instance, sessionDirectory.Path, configurationModel); _ = await destination.StartupAsync(context); IContentSession contentSession = destination.CreateSession(context, "test_session", BuildXL.Cache.ContentStore.Interfaces.Stores.ImplicitPin.None).Session; _ = await contentSession.StartupAsync(context); // Create the file and hardlink it into the cache. FileSystem.WriteAllText(originalPath, fileContents); var contentHasher = HashInfoLookup.GetContentHasher(HashType.MD5); var contentHash = contentHasher.GetContentHash(Encoding.UTF8.GetBytes(fileContents)); await store.PutFileAsync(context, contentHash, new DisposableFile(context, FileSystem, originalPath), context.Token).ShouldBeSuccess(); FileSystem.DeleteFile(originalPath); FileSystem.FileExists(originalPath).Should().Be(false); ContentHashWithPath contentHashWithPath = new ContentHashWithPath(contentHash, originalPath); List <ContentHashWithPath> listFile = new List <ContentHashWithPath>(); listFile.Add(contentHashWithPath); // Hardlink back to original location trying to replace existing. var copyTask = await store.FetchThenPutBulkAsync( context, listFile, contentSession); await copyTask.ToLookupAwait(r => { return r.Item.Succeeded; }); FileSystem.FileExists(originalPath).Should().Be(false); // The file is in the destination. await contentSession.PlaceFileAsync(context, contentHash, originalPath, FileAccessMode.Write, FileReplacementMode.FailIfExists, FileRealizationMode.Copy, CancellationToken.None).ShouldBeSuccess(); FileSystem.FileExists(originalPath).Should().Be(true); FileSystem.ReadAllText(originalPath).Should().Be(fileContents); _ = await contentSession.ShutdownAsync(context); _ = await destination.ShutdownAsync(context); })); }
/// <inheritdoc /> protected override async Task <BoolResult> StartupCoreAsync(OperationContext context) { await _innerStore.StartupAsync(context).ThrowIfFailure(); // Create long-lived session to be used with overlay (ImplicitPin=None (i.e false) to avoid cache full errors) _vfsContentSession = _innerStore.CreateSession(context, "VFSInner", ImplicitPin.None).ThrowIfFailure().Session; await _vfsContentSession.StartupAsync(context).ThrowIfFailure(); _contentManager = new VfsContentManager(_logger, _configuration, Tree, _vfsContentSession); _provider = new VfsProvider(_logger, _configuration, _contentManager, Tree); if (!_provider.StartVirtualization()) { return(new BoolResult("Unable to start virtualizing")); } return(await base.StartupCoreAsync(context)); }
/// <inheritdoc /> protected override async Task <BoolResult> StartupCoreAsync(OperationContext context) { await _innerSession.StartupAsync(context).ThrowIfFailure(); return(await base.StartupCoreAsync(context)); }