Esempio n. 1
0
 public BuildCachePublishingSession(BuildCacheServiceConfiguration config, string name, string pat, BuildCachePublishingStore store)
 {
     _name   = name;
     _config = config;
     _store  = store;
     _pat    = pat;
 }
Esempio n. 2
0
 /// <summary>
 /// Creates an ICache that can communicate with a VSTS Build Cache Service.
 /// </summary>
 public static ICache Create(
     IAbsFileSystem fileSystem,
     ILogger logger,
     VssCredentialsFactory vssCredentialsFactory,
     BuildCacheServiceConfiguration cacheConfig,
     Func <IContentStore> writeThroughContentStoreFunc)
 {
     Contract.Requires(fileSystem != null);
     Contract.Requires(cacheConfig != null);
     return(new BuildCacheCache(
                fileSystem,
                cacheConfig.CacheNamespace,
                new BuildCacheHttpClientFactory(new Uri(cacheConfig.CacheServiceFingerprintEndpoint), vssCredentialsFactory, TimeSpan.FromMinutes(cacheConfig.HttpSendTimeoutMinutes), cacheConfig.UseAad),
                new BackingContentStoreHttpClientFactory(new Uri(cacheConfig.CacheServiceContentEndpoint), vssCredentialsFactory, TimeSpan.FromMinutes(cacheConfig.HttpSendTimeoutMinutes), cacheConfig.UseAad),
                cacheConfig.MaxFingerprintSelectorsToFetch,
                TimeSpan.FromDays(cacheConfig.DaysToKeepUnreferencedContent),
                TimeSpan.FromDays(cacheConfig.DaysToKeepContentBags),
                TimeSpan.FromDays(cacheConfig.RangeOfDaysToKeepContentBags),
                logger,
                cacheConfig.FingerprintIncorporationEnabled,
                cacheConfig.MaxDegreeOfParallelismForIncorporateRequests,
                cacheConfig.MaxFingerprintsPerIncorporateRequest,
                writeThroughContentStoreFunc,
                cacheConfig.SealUnbackedContentHashLists,
                cacheConfig.UseBlobContentHashLists,
                cacheConfig.DownloadBlobsThroughBlobStore,
                cacheConfig.UseDedupStore,
                cacheConfig.OverrideUnixFileAccessMode));
 }
Esempio n. 3
0
 public BuildCachePublishingSession(BuildCacheServiceConfiguration config, string name, string pat, IContentSession sourceContentSession, IAbsFileSystem fileSystem, SemaphoreSlim publishGate)
 {
     _name                 = name;
     _config               = config;
     _publishingGate       = publishGate;
     _pat                  = pat;
     _fileSystem           = fileSystem;
     _sourceContentSession = sourceContentSession;
 }
Esempio n. 4
0
        protected virtual ICachePublisher CreatePublisher(string sessionName, BuildCacheServiceConfiguration config, string pat, Context context)
        {
            var credFactory = new VssCredentialsFactory(pat, helper: null, logger: m => Tracer.Info(context, m));

            var cache = BuildCacheCacheFactory.Create(
                _fileSystem,
                context.Logger,
                credFactory,
                config,
                writeThroughContentStoreFunc: null);

            cache.StartupAsync(context).GetAwaiter().GetResult().ThrowIfFailure();

            var sessionResult = cache.CreateSession(context, sessionName, ImplicitPin.None).ThrowIfFailure();
            var session       = sessionResult.Session;

            Contract.Check(session is BuildCacheSession)?.Assert($"Session should be an instance of {nameof(BuildCacheSession)}. Actual type: {session.GetType()}");

            return((BuildCacheSession)session);
        }
        /// <summary>
        /// Creates an ICache that can communicate with a VSTS Build Cache Service.
        /// </summary>
        public static ICache Create(
            IAbsFileSystem fileSystem,
            ILogger logger,
            VssCredentialsFactory vssCredentialsFactory,
            BuildCacheServiceConfiguration cacheConfig,
            Func <IContentStore> writeThroughContentStoreFunc)
        {
            Contract.Requires(fileSystem != null);
            Contract.Requires(cacheConfig != null);

            var domain = new ByteDomainId(cacheConfig.DomainId);

            return(new BuildCacheCache(
                       fileSystem,
                       cacheConfig.CacheNamespace,
                       new BuildCacheHttpClientFactory(new Uri(cacheConfig.CacheServiceFingerprintEndpoint), vssCredentialsFactory, TimeSpan.FromMinutes(cacheConfig.HttpSendTimeoutMinutes), cacheConfig.UseAad),
                       new BackingContentStoreHttpClientFactory(new Uri(cacheConfig.CacheServiceContentEndpoint), vssCredentialsFactory, TimeSpan.FromMinutes(cacheConfig.HttpSendTimeoutMinutes), domain, cacheConfig.UseAad),
                       cacheConfig.MaxFingerprintSelectorsToFetch,
                       TimeSpan.FromDays(cacheConfig.DaysToKeepUnreferencedContent),
                       TimeSpan.FromMinutes(cacheConfig.PinInlineThresholdMinutes),
                       TimeSpan.FromHours(cacheConfig.IgnorePinThresholdHours),
                       TimeSpan.FromDays(cacheConfig.DaysToKeepContentBags),
                       TimeSpan.FromDays(cacheConfig.RangeOfDaysToKeepContentBags),
                       logger,
                       cacheConfig.FingerprintIncorporationEnabled,
                       cacheConfig.MaxDegreeOfParallelismForIncorporateRequests,
                       cacheConfig.MaxFingerprintsPerIncorporateRequest,
                       domain,
                       cacheConfig.ForceUpdateOnAddContentHashList,
                       writeThroughContentStoreFunc,
                       cacheConfig.SealUnbackedContentHashLists,
                       cacheConfig.UseBlobContentHashLists,
                       cacheConfig.UseDedupStore,
                       cacheConfig.OverrideUnixFileAccessMode,
                       cacheConfig.EnableEagerFingerprintIncorporation,
                       TimeSpan.FromHours(cacheConfig.InlineFingerprintIncorporationExpiryHours),
                       TimeSpan.FromMinutes(cacheConfig.EagerFingerprintIncorporationNagleIntervalMinutes),
                       cacheConfig.EagerFingerprintIncorporationNagleBatchSize,
                       downloadBlobsUsingHttpClient: cacheConfig.DownloadBlobsUsingHttpClient));
        }