Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlobReadOnlyContentSession"/> class.
        /// </summary>
        /// <param name="fileSystem">Filesystem used to read/write files.</param>
        /// <param name="name">Session name.</param>
        /// <param name="implicitPin">Policy determining whether or not content should be automatically pinned on adds or gets.</param>
        /// <param name="dedupStoreHttpClient">Backing DedupStore http client.</param>
        /// <param name="timeToKeepContent">Minimum time-to-live for accessed 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="maxConnections">The maximum number of outbound connections to VSTS.</param>
        /// <param name="counterTracker">Parent counters to track the session.</param>
        public DedupReadOnlyContentSession(
            IAbsFileSystem fileSystem,
            string name,
            ImplicitPin implicitPin,
            IDedupStoreHttpClient dedupStoreHttpClient,
            TimeSpan timeToKeepContent,
            TimeSpan pinInlineThreshold,
            TimeSpan ignorePinThreshold,
            CounterTracker counterTracker = null,
            int maxConnections            = DefaultMaxConnections)
            : base(name, counterTracker)
        {
            Contract.Requires(fileSystem != null);
            Contract.Requires(name != null);
            Contract.Requires(dedupStoreHttpClient != null);

            ImplicitPin      = implicitPin;
            DedupStoreClient = new DedupStoreClient(dedupStoreHttpClient, DefaultMaxParallelism);
            FileSystem       = fileSystem;
            TempDirectory    = new DisposableDirectory(fileSystem);
            ConnectionGate   = new SemaphoreSlim(maxConnections);
            EndDateTime      = DateTime.UtcNow + timeToKeepContent;

            _pinInlineThreshold = pinInlineThreshold;
            _ignorePinThreshold = ignorePinThreshold;

            _counters      = CounterTracker.CreateCounterCollection <BackingContentStore.SessionCounters>(counterTracker);
            _dedupCounters = CounterTracker.CreateCounterCollection <Counters>(counterTracker);
        }
Exemple #2
0
        public BlobReadOnlyContentSession(
            IAbsFileSystem fileSystem,
            string name,
            ImplicitPin implicitPin,
            IBlobStoreHttpClient blobStoreHttpClient,
            TimeSpan timeToKeepContent,
            bool downloadBlobsThroughBlobStore,
            CounterTracker?counterTracker = null)
            : base(name, counterTracker)
        {
            Contract.Requires(fileSystem != null);
            Contract.Requires(name != null);
            Contract.Requires(blobStoreHttpClient != null);

            ImplicitPin                    = implicitPin;
            BlobStoreHttpClient            = blobStoreHttpClient;
            TimeToKeepContent              = timeToKeepContent;
            _downloadBlobsThroughBlobStore = downloadBlobsThroughBlobStore;
            _parallelSegmentDownloadConfig = ParallelHttpDownload.Configuration.GetParallelSegmentDownloadConfig(EnvironmentVariablePrefix);

            TempDirectory = new DisposableDirectory(fileSystem);

            _counters     = CounterTracker.CreateCounterCollection <BackingContentStore.SessionCounters>(counterTracker);
            _blobCounters = CounterTracker.CreateCounterCollection <Counters>(counterTracker);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="BlobContentSession" /> class.
 /// </summary>
 /// <param name="configuration">Configuration.</param>
 /// <param name="name">Session name.</param>
 /// <param name="implicitPin">Policy determining whether or not content should be automatically pinned on adds or gets.</param>
 /// <param name="blobStoreHttpClient">Backing BlobStore http client.</param>
 /// <param name="counterTracker">Parent counters to track the session.</param>
 public BlobContentSession(
     BackingContentStoreConfiguration configuration,
     string name,
     ImplicitPin implicitPin,
     IBlobStoreHttpClient blobStoreHttpClient,
     CounterTracker counterTracker)
     : base(configuration, name, implicitPin, blobStoreHttpClient, counterTracker)
 {
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlobContentSession" /> class.
 /// </summary>
 /// <param name="fileSystem">Filesystem used to read/write files.</param>
 /// <param name="name">Session name.</param>
 /// <param name="implicitPin">Policy determining whether or not content should be automatically pinned on adds or gets.</param>
 /// <param name="blobStoreHttpClient">Backing BlobStore http client.</param>
 /// <param name="timeToKeepContent">Minimum time-to-live for accessed content.</param>
 /// <param name="downloadBlobsThroughBlobStore">
 /// If true, gets blobs through BlobStore. If false, gets blobs from the Azure
 /// Uri.
 /// </param>
 /// <param name="counterTracker">Parent counters to track the session.</param>
 public BlobContentSession(
     IAbsFileSystem fileSystem,
     string name,
     ImplicitPin implicitPin,
     IBlobStoreHttpClient blobStoreHttpClient,
     TimeSpan timeToKeepContent,
     bool downloadBlobsThroughBlobStore,
     CounterTracker counterTracker)
     : base(fileSystem, name, implicitPin, blobStoreHttpClient, timeToKeepContent, downloadBlobsThroughBlobStore, counterTracker)
 {
 }
Exemple #5
0
        /// <nodoc />
        public static CounterSet ToCounterSet(this CounterTracker counterTracker)
        {
            var result = new CounterSet();

            foreach (var counterCollection in counterTracker.CounterCollections)
            {
                result.Merge(counterCollection.ToCounterSet());
            }

            foreach ((var name, var tracker) in counterTracker.ChildCounterTrackers)
            {
                result.Merge(tracker.ToCounterSet(), name);
            }

            return(result);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DedupContentSession"/> class.
 /// </summary>
 public DedupContentSession(
     Context context,
     IAbsFileSystem fileSystem,
     string name,
     ImplicitPin implicitPin,
     IDedupStoreHttpClient dedupStoreHttpClient,
     TimeSpan timeToKeepContent,
     TimeSpan pinInlineThreshold,
     TimeSpan ignorePinThreshold,
     CounterTracker counterTracker,
     int maxConnections = DefaultMaxConnections)
     : base(fileSystem, name, implicitPin, dedupStoreHttpClient, timeToKeepContent, pinInlineThreshold, ignorePinThreshold, counterTracker, maxConnections)
 {
     _artifactFileSystem = VstsFileSystem.Instance;
     _uploadSession      = DedupStoreClient.CreateUploadSession(
         new KeepUntilBlobReference(EndDateTime),
         new AppTraceSourceContextAdapter(context, "CreateUploadSession", SourceLevels.All),
         _artifactFileSystem);
 }
Exemple #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlobReadOnlyContentSession"/> class.
        /// </summary>
        /// <param name="fileSystem">Filesystem used to read/write files.</param>
        /// <param name="name">Session name.</param>
        /// <param name="implicitPin">Policy determining whether or not content should be automatically pinned on adds or gets.</param>
        /// <param name="blobStoreHttpClient">Backing BlobStore http client.</param>
        /// <param name="timeToKeepContent">Minimum time-to-live for accessed content.</param>
        /// <param name="downloadBlobsThroughBlobStore">If true, gets blobs through BlobStore. If false, gets blobs from the Azure Uri.</param>
        /// <param name="counterTracker">Parent counters to track the session.</param>
        public BlobReadOnlyContentSession(
            IAbsFileSystem fileSystem,
            string name,
            ImplicitPin implicitPin,
            IBlobStoreHttpClient blobStoreHttpClient,
            TimeSpan timeToKeepContent,
            bool downloadBlobsThroughBlobStore,
            CounterTracker counterTracker = null)
            : base(name, counterTracker)
        {
            Contract.Requires(fileSystem != null);
            Contract.Requires(name != null);
            Contract.Requires(blobStoreHttpClient != null);

            ImplicitPin                    = implicitPin;
            BlobStoreHttpClient            = blobStoreHttpClient;
            TimeToKeepContent              = timeToKeepContent;
            _downloadBlobsThroughBlobStore = downloadBlobsThroughBlobStore;
            _parallelSegmentDownloadConfig = new ParallelHttpDownload
                                             .Configuration(
                segmentDownloadTimeout: TimeSpan.FromMinutes(int.Parse(
                                                                 Environment.GetEnvironmentVariable(EnvironmentVariablePrefix + "SegmentDownloadTimeoutInMinutes") ??
                                                                 DefaultSegmentDownloadTimeoutInMinutes.ToString())),
                segmentSizeInBytes: int.Parse(
                    Environment.GetEnvironmentVariable(EnvironmentVariablePrefix + "ParallelDownloadSegmentSizeInBytes") ??
                    DefaultParallelDownloadSegmentSizeInBytes.ToString()),
                maxParallelSegmentDownloadsPerFile: int.Parse(
                    Environment.GetEnvironmentVariable(EnvironmentVariablePrefix + "MaxParallelSegmentDownloadsPerFile") ??
                    DefaultMaxParallelSegmentDownloadsPerFile.ToString()),
                maxSegmentDownloadRetries:
                int.Parse(
                    Environment.GetEnvironmentVariable(EnvironmentVariablePrefix + "MaxSegmentDownloadRetries") ??
                    DefaultMaxSegmentDownloadRetries.ToString()));

            TempDirectory = new DisposableDirectory(fileSystem);
            Native.IO.FileUtilities.CreateDirectory(TempDirectory.Path.Path);

            _counters     = CounterTracker.CreateCounterCollection <BackingContentStore.SessionCounters>(counterTracker);
            _blobCounters = CounterTracker.CreateCounterCollection <Counters>(counterTracker);
        }
Exemple #8
0
        public BlobReadOnlyContentSession(
            BackingContentStoreConfiguration configuration,
            string name,
            ImplicitPin implicitPin,
            IBlobStoreHttpClient blobStoreHttpClient,
            CounterTracker?counterTracker = null)
            : base(name, counterTracker)
        {
            Contract.Requires(configuration != null);
            Contract.Requires(configuration.FileSystem != null);
            Contract.Requires(name != null);
            Contract.Requires(blobStoreHttpClient != null);

            Configuration = configuration;

            ImplicitPin                    = implicitPin;
            BlobStoreHttpClient            = blobStoreHttpClient;
            _parallelSegmentDownloadConfig = ParallelHttpDownload.DownloadConfiguration.ReadFromEnvironment(EnvironmentVariablePrefix);

            TempDirectory = new DisposableDirectory(configuration.FileSystem);

            _counters     = CounterTracker.CreateCounterCollection <BackingContentStore.SessionCounters>(counterTracker);
            _blobCounters = CounterTracker.CreateCounterCollection <Counters>(counterTracker);
        }
Exemple #9
0
 /// <nodoc />
 protected ContentSessionBase(string name, CounterTracker?counterTracker = null)
 {
     Name         = name;
     BaseCounters = CounterTracker.CreateCounterCollection <ContentSessionBaseCounters>(counterTracker);
 }