Пример #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BuildCacheCache"/> class.
        /// </summary>
        /// <param name="fileSystem">Filesystem used to read/write files.</param>
        /// <param name="cacheNamespace">the namespace of the cache that is communicated with.</param>
        /// <param name="buildCacheHttpClientFactory">Factory for creatign a backing BuildCache http client.</param>
        /// <param name="backingContentStoreHttpClientFactory">Factory for creating a backing store http client.</param>
        /// <param name="maxFingerprintSelectorsToFetch">Maximum number of selectors to enumerate.</param>
        /// <param name="timeToKeepUnreferencedContent">Initial time-to-live for unreferenced content.</param>
        /// <param name="minimumTimeToKeepContentHashLists">Minimum time-to-live for created or referenced ContentHashLists.</param>
        /// <param name="rangeOfTimeToKeepContentHashLists">Range of time beyond the minimum for the time-to-live of created or referenced ContentHashLists.</param>
        /// <param name="logger">A logger for tracing.</param>
        /// <param name="fingerprintIncorporationEnabled">Feature flag to enable fingerprints incorporation on shutdown</param>
        /// <param name="maxDegreeOfParallelismForIncorporateRequests">Throttle the number of fingerprints chunks sent in parallel</param>
        /// <param name="maxFingerprintsPerIncorporateRequest">Max fingerprints allowed per chunk</param>
        /// <param name="writeThroughContentStoreFunc">Optional write-through store to allow writing-behind to BlobStore</param>
        /// <param name="sealUnbackedContentHashLists">If true, the client will attempt to seal any unbacked ContentHashLists that it sees.</param>
        /// <param name="useBlobContentHashLists">use blob based content hash lists.</param>
        /// <param name="downloadBlobsThroughBlobStore">If true, gets blobs through BlobStore. If false, gets blobs from the Azure Uri.</param>
        /// <param name="useDedupStore">If true, gets content through DedupStore. If false, gets content from BlobStore.</param>
        public BuildCacheCache(
            IAbsFileSystem fileSystem,
            string cacheNamespace,
            IBuildCacheHttpClientFactory buildCacheHttpClientFactory,
            IArtifactHttpClientFactory backingContentStoreHttpClientFactory,
            int maxFingerprintSelectorsToFetch,
            TimeSpan timeToKeepUnreferencedContent,
            TimeSpan minimumTimeToKeepContentHashLists,
            TimeSpan rangeOfTimeToKeepContentHashLists,
            ILogger logger,
            bool fingerprintIncorporationEnabled,
            int maxDegreeOfParallelismForIncorporateRequests,
            int maxFingerprintsPerIncorporateRequest,
            Func <IContentStore> writeThroughContentStoreFunc = null,
            bool sealUnbackedContentHashLists  = false,
            bool useBlobContentHashLists       = false,
            bool downloadBlobsThroughBlobStore = false,
            bool useDedupStore = false)
        {
            Contract.Requires(fileSystem != null);
            Contract.Requires(buildCacheHttpClientFactory != null);
            Contract.Requires(backingContentStoreHttpClientFactory != null);

            _fileSystem     = fileSystem;
            _cacheNamespace = cacheNamespace;
            _buildCacheHttpClientFactory = buildCacheHttpClientFactory;
            _tracer = new BuildCacheCacheTracer(logger, nameof(BuildCacheCache));

            _backingContentStore = new BackingContentStore(
                fileSystem, backingContentStoreHttpClientFactory, timeToKeepUnreferencedContent, _tracer.ContentSessionTracer, downloadBlobsThroughBlobStore, useDedupStore);

            if (useDedupStore)
            {
                // Guaranteed content is only available for BlobSessions. (bug 144396)
                _sealUnbackedContentHashLists = false;

                // BlobBuildCacheHttpClient is incompatible with Dedup hashes. (bug 1458510)
                _useBlobContentHashLists = false;
            }
            else
            {
                _sealUnbackedContentHashLists = sealUnbackedContentHashLists;
                _useBlobContentHashLists      = useBlobContentHashLists;
            }

            _maxFingerprintSelectorsToFetch    = maxFingerprintSelectorsToFetch;
            _minimumTimeToKeepContentHashLists = minimumTimeToKeepContentHashLists;
            _rangeOfTimeToKeepContentHashLists = rangeOfTimeToKeepContentHashLists;

            if (writeThroughContentStoreFunc != null)
            {
                _writeThroughContentStore = writeThroughContentStoreFunc();
                Contract.Assert(_writeThroughContentStore != null);
            }

            _fingerprintIncorporationEnabled = fingerprintIncorporationEnabled;
            _maxDegreeOfParallelismForIncorporateRequests = maxDegreeOfParallelismForIncorporateRequests;
            _maxFingerprintsPerIncorporateRequest         = maxFingerprintsPerIncorporateRequest;
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BackingContentStore"/> class.
 /// </summary>
 /// <param name="fileSystem">Filesystem used to read/write files.</param>
 /// <param name="artifactHttpClientFactory">Backing Store HTTP client factory.</param>
 /// <param name="timeToKeepContent">Minimum time-to-live for accessed content.</param>
 /// <param name="downloadBlobsThroughBlobStore">Flag for BlobStore: If enabled, gets blobs through BlobStore. If false, gets blobs from the Azure Uri.</param>
 /// <param name="useDedupStore">Determines whether or not DedupStore is used for content. Must be used in tandem with Dedup hashes.</param>
 public BackingContentStore(
     IAbsFileSystem fileSystem,
     IArtifactHttpClientFactory artifactHttpClientFactory,
     TimeSpan timeToKeepContent,
     bool downloadBlobsThroughBlobStore = false,
     bool useDedupStore = false)
 {
     Contract.Requires(fileSystem != null);
     Contract.Requires(artifactHttpClientFactory != null);
     _fileSystem = fileSystem;
     _artifactHttpClientFactory     = artifactHttpClientFactory;
     _timeToKeepContent             = timeToKeepContent;
     _downloadBlobsThroughBlobStore = downloadBlobsThroughBlobStore;
     _useDedupStore = useDedupStore;
 }
Пример #3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BuildCacheCache"/> class.
        /// </summary>
        /// <param name="fileSystem">Filesystem used to read/write files.</param>
        /// <param name="cacheNamespace">the namespace of the cache that is communicated with.</param>
        /// <param name="buildCacheHttpClientFactory">Factory for creatign a backing BuildCache http client.</param>
        /// <param name="backingContentStoreHttpClientFactory">Factory for creating a backing store http client.</param>
        /// <param name="maxFingerprintSelectorsToFetch">Maximum number of selectors to enumerate.</param>
        /// <param name="timeToKeepUnreferencedContent">Initial time-to-live for unreferenced content.</param>
        /// <param name="pinInlineThreshold">Maximum time-to-live to inline pin calls.</param>
        /// <param name="ignorePinThreshold">Minimum time-to-live to ignore pin calls.</param>
        /// <param name="minimumTimeToKeepContentHashLists">Minimum time-to-live for created or referenced ContentHashLists.</param>
        /// <param name="rangeOfTimeToKeepContentHashLists">Range of time beyond the minimum for the time-to-live of created or referenced ContentHashLists.</param>
        /// <param name="logger">A logger for tracing.</param>
        /// <param name="fingerprintIncorporationEnabled">Feature flag to enable fingerprints incorporation on shutdown</param>
        /// <param name="maxDegreeOfParallelismForIncorporateRequests">Throttle the number of fingerprints chunks sent in parallel</param>
        /// <param name="maxFingerprintsPerIncorporateRequest">Max fingerprints allowed per chunk</param>
        /// <param name="domain">Domain ID to use against BlobStore or DedupStore</param>
        /// <param name="writeThroughContentStoreFunc">Optional write-through store to allow writing-behind to BlobStore</param>
        /// <param name="sealUnbackedContentHashLists">If true, the client will attempt to seal any unbacked ContentHashLists that it sees.</param>
        /// <param name="useBlobContentHashLists">use blob based content hash lists.</param>
        /// <param name="useDedupStore">If true, gets content through DedupStore. If false, gets content from BlobStore.</param>
        /// <param name="overrideUnixFileAccessMode">If true, overrides default Unix file access modes.</param>
        /// <param name="enableEagerFingerprintIncorporation"><see cref="BuildCacheServiceConfiguration.EnableEagerFingerprintIncorporation"/></param>
        /// <param name="inlineFingerprintIncorporationExpiry"><see cref="BuildCacheServiceConfiguration.InlineFingerprintIncorporationExpiry"/></param>
        /// <param name="eagerFingerprintIncorporationNagleInterval"><see cref="BuildCacheServiceConfiguration.EagerFingerprintIncorporationNagleInterval"/></param>
        /// <param name="eagerFingerprintIncorporationNagleBatchSize"><see cref="BuildCacheServiceConfiguration.EagerFingerprintIncorporationNagleBatchSize"/></param>
        /// <param name="downloadBlobsUsingHttpClient"><see cref="BuildCacheServiceConfiguration.DownloadBlobsUsingHttpClient"/></param>
        public BuildCacheCache(
            IAbsFileSystem fileSystem,
            string cacheNamespace,
            IBuildCacheHttpClientFactory buildCacheHttpClientFactory,
            IArtifactHttpClientFactory backingContentStoreHttpClientFactory,
            int maxFingerprintSelectorsToFetch,
            TimeSpan timeToKeepUnreferencedContent,
            TimeSpan pinInlineThreshold,
            TimeSpan ignorePinThreshold,
            TimeSpan minimumTimeToKeepContentHashLists,
            TimeSpan rangeOfTimeToKeepContentHashLists,
            ILogger logger,
            bool fingerprintIncorporationEnabled,
            int maxDegreeOfParallelismForIncorporateRequests,
            int maxFingerprintsPerIncorporateRequest,
            IDomainId domain,
            Func <IContentStore> writeThroughContentStoreFunc = null,
            bool sealUnbackedContentHashLists = false,
            bool useBlobContentHashLists      = false,
            bool useDedupStore = false,
            bool overrideUnixFileAccessMode                     = false,
            bool enableEagerFingerprintIncorporation            = false,
            TimeSpan inlineFingerprintIncorporationExpiry       = default,
            TimeSpan eagerFingerprintIncorporationNagleInterval = default,
            int eagerFingerprintIncorporationNagleBatchSize     = 100,
            bool downloadBlobsUsingHttpClient                   = false)
        {
            Contract.Requires(fileSystem != null);
            Contract.Requires(buildCacheHttpClientFactory != null);
            Contract.Requires(backingContentStoreHttpClientFactory != null);

            _fileSystem     = fileSystem;
            _cacheNamespace = cacheNamespace;
            _buildCacheHttpClientFactory = buildCacheHttpClientFactory;
            _tracer = new BuildCacheCacheTracer(logger, nameof(BuildCacheCache));

            _backingContentStore = new BackingContentStore(
                new BackingContentStoreConfiguration()
            {
                FileSystem = fileSystem,
                ArtifactHttpClientFactory    = backingContentStoreHttpClientFactory,
                TimeToKeepContent            = timeToKeepUnreferencedContent,
                PinInlineThreshold           = pinInlineThreshold,
                IgnorePinThreshold           = ignorePinThreshold,
                UseDedupStore                = useDedupStore,
                DownloadBlobsUsingHttpClient = downloadBlobsUsingHttpClient
            });

            _manuallyExtendContentLifetime = false;

            if (useDedupStore)
            {
                // Guaranteed content is only available for BlobSessions. (bug 144396)
                _sealUnbackedContentHashLists = false;

                // BuildCache is incompatible with Dedup hashes.
                // This is because BuildCache would not know to look for the blob in DedupStore instead of BlobStore
                _useBlobContentHashLists       = false;
                _manuallyExtendContentLifetime = true;
            }
            else
            {
                _sealUnbackedContentHashLists = sealUnbackedContentHashLists;
                _useBlobContentHashLists      = useBlobContentHashLists;
            }

            if (!domain.Equals(WellKnownDomainIds.OriginalDomainId))
            {
                // BuildCache is incompatible with multi-domain
                _useBlobContentHashLists       = false;
                _manuallyExtendContentLifetime = true;
            }

            _maxFingerprintSelectorsToFetch    = maxFingerprintSelectorsToFetch;
            _minimumTimeToKeepContentHashLists = minimumTimeToKeepContentHashLists;
            _rangeOfTimeToKeepContentHashLists = rangeOfTimeToKeepContentHashLists;

            if (writeThroughContentStoreFunc != null)
            {
                _writeThroughContentStore = writeThroughContentStoreFunc();
                Contract.Assert(_writeThroughContentStore != null);
            }

            _fingerprintIncorporationEnabled = fingerprintIncorporationEnabled;
            _maxDegreeOfParallelismForIncorporateRequests = maxDegreeOfParallelismForIncorporateRequests;
            _maxFingerprintsPerIncorporateRequest         = maxFingerprintsPerIncorporateRequest;
            _overrideUnixFileAccessMode                  = overrideUnixFileAccessMode;
            _enableEagerFingerprintIncorporation         = enableEagerFingerprintIncorporation;
            _inlineFingerprintIncorporationExpiry        = inlineFingerprintIncorporationExpiry;
            _eagerFingerprintIncorporationNagleInterval  = eagerFingerprintIncorporationNagleInterval;
            _eagerFingerprintIncorporationNagleBatchSize = eagerFingerprintIncorporationNagleBatchSize;
        }