Example #1
0
 /// <nodoc />
 public DistributedContentStore(
     byte[] localMachineLocation,
     Func <NagleQueue <ContentHash>, DistributedEvictionSettings, ContentStoreSettings, TrimBulkAsync, IContentStore> innerContentStoreFunc,
     IContentLocationStoreFactory contentLocationStoreFactory,
     IFileExistenceChecker <T> fileExistenceChecker,
     IFileCopier <T> fileCopier,
     IPathTransformer <T> pathTransform,
     ICopyRequester copyRequester,
     ReadOnlyDistributedContentSession <T> .ContentAvailabilityGuarantee contentAvailabilityGuarantee,
     AbsolutePath tempFolderForCopies,
     IAbsFileSystem fileSystem,
     int locationStoreBatchSize,
     IReadOnlyList <TimeSpan> retryIntervalForCopies = null,
     PinConfiguration pinConfiguration = null,
     int?replicaCreditInMinutes        = null,
     IClock clock = null,
     bool enableRepairHandling                 = false,
     TimeSpan?contentHashBumpTime              = null,
     bool useTrustedHash                       = false,
     int trustedHashFileSizeBoundary           = -1,
     long parallelHashingFileSizeBoundary      = -1,
     int maxConcurrentCopyOperations           = 512,
     ContentStoreSettings contentStoreSettings = null,
     bool enableProactiveCopy                  = false)
     : this(
         localMachineLocation,
         innerContentStoreFunc,
         contentLocationStoreFactory,
         fileExistenceChecker,
         fileCopier,
         pathTransform,
         copyRequester,
         contentAvailabilityGuarantee,
         tempFolderForCopies,
         fileSystem,
         locationStoreBatchSize,
         new DistributedContentStoreSettings()
 {
     UseTrustedHash = useTrustedHash,
     TrustedHashFileSizeBoundary = trustedHashFileSizeBoundary,
     ParallelHashingFileSizeBoundary = parallelHashingFileSizeBoundary,
     MaxConcurrentCopyOperations = maxConcurrentCopyOperations,
     RetryIntervalForCopies = retryIntervalForCopies,
     PinConfiguration = pinConfiguration,
     EnableProactiveCopy = enableProactiveCopy
 },
         replicaCreditInMinutes,
         clock,
         enableRepairHandling,
         contentHashBumpTime,
         contentStoreSettings)
 {
     // This constructor is used from tests,
     // so we need to complete _postInitializationCompletion when startup is done.
     _setPostInitializationCompletionAfterStartup = true;
 }
Example #2
0
        /// <nodoc />
        public DistributedContentStore(
            MachineLocation localMachineLocation,
            AbsolutePath localCacheRoot,
            Func <NagleQueue <ContentHash>, DistributedEvictionSettings, ContentStoreSettings, TrimBulkAsync, IContentStore> innerContentStoreFunc,
            IContentLocationStoreFactory contentLocationStoreFactory,
            DistributedContentStoreSettings settings,
            DistributedContentCopier <T> distributedCopier,
            IClock clock = null,
            ContentStoreSettings contentStoreSettings = null)
        {
            Contract.Requires(settings != null);

            LocalMachineLocation         = localMachineLocation;
            _contentLocationStoreFactory = contentLocationStoreFactory;
            _clock                  = clock;
            _distributedCopier      = distributedCopier;
            _copierWorkingDirectory = new DisposableDirectory(distributedCopier.FileSystem, localCacheRoot / "Temp");

            contentStoreSettings = contentStoreSettings ?? ContentStoreSettings.DefaultSettings;
            _settings            = settings;

            // Queue is created in unstarted state because the eviction function
            // requires the context passed at startup.
            _evictionNagleQueue = NagleQueue <ContentHash> .CreateUnstarted(
                Redis.RedisContentLocationStoreConstants.BatchDegreeOfParallelism,
                Redis.RedisContentLocationStoreConstants.BatchInterval,
                _settings.LocationStoreBatchSize);

            _enableDistributedEviction = _settings.ReplicaCreditInMinutes != null;
            var distributedEvictionSettings = _enableDistributedEviction ? SetUpDistributedEviction(_settings.ReplicaCreditInMinutes, _settings.LocationStoreBatchSize) : null;

            var enableTouch = _settings.ContentHashBumpTime.HasValue;

            if (enableTouch)
            {
                _contentTrackerUpdater = new ContentTrackerUpdater(ScheduleBulkTouch, _settings.ContentHashBumpTime.Value, clock: _clock);
            }

            TrimBulkAsync trimBulkAsync = null;

            InnerContentStore = innerContentStoreFunc(_evictionNagleQueue, distributedEvictionSettings, contentStoreSettings, trimBulkAsync);

            if (settings.PinConfiguration?.IsPinCachingEnabled == true)
            {
                _pinCache = new PinCache(clock: _clock);
            }
        }
Example #3
0
        public DistributedContentStore(
            MachineLocation localMachineLocation,
            AbsolutePath localCacheRoot,
            Func <IDistributedLocationStore, IContentStore> innerContentStoreFunc,
            IContentLocationStoreFactory contentLocationStoreFactory,
            DistributedContentStoreSettings settings,
            DistributedContentCopier distributedCopier,
            IClock?clock = null)
        {
            Contract.Requires(settings != null);

            LocalMachineLocation         = localMachineLocation;
            _contentLocationStoreFactory = contentLocationStoreFactory;
            _clock                  = clock ?? SystemClock.Instance;
            _distributedCopier      = distributedCopier;
            _copierWorkingDirectory = new DisposableDirectory(distributedCopier.FileSystem, localCacheRoot / "Temp");

            _settings = settings;

            InnerContentStore = innerContentStoreFunc(this);
        }
        /// <nodoc />
        public DistributedContentStore(
            MachineLocation localMachineLocation,
            AbsolutePath localCacheRoot,
            Func <ContentStoreSettings, IDistributedLocationStore, IContentStore> innerContentStoreFunc,
            IContentLocationStoreFactory contentLocationStoreFactory,
            DistributedContentStoreSettings settings,
            DistributedContentCopier <T> distributedCopier,
            IClock clock = null,
            ContentStoreSettings contentStoreSettings = null)
        {
            Contract.Requires(settings != null);

            LocalMachineLocation         = localMachineLocation;
            _contentLocationStoreFactory = contentLocationStoreFactory;
            _clock                  = clock;
            _distributedCopier      = distributedCopier;
            _copierWorkingDirectory = new DisposableDirectory(distributedCopier.FileSystem, localCacheRoot / "Temp");

            contentStoreSettings ??= ContentStoreSettings.DefaultSettings;
            _settings = settings;

            InnerContentStore = innerContentStoreFunc(contentStoreSettings, this);
        }
Example #5
0
        /// <nodoc />
        public DistributedContentStore(
            byte[] localMachineLocation,
            Func <NagleQueue <ContentHash>, DistributedEvictionSettings, ContentStoreSettings, TrimBulkAsync, IContentStore> innerContentStoreFunc,
            IContentLocationStoreFactory contentLocationStoreFactory,
            IFileExistenceChecker <T> fileExistenceChecker,
            IFileCopier <T> fileCopier,
            IPathTransformer <T> pathTransform,
            ICopyRequester copyRequester,
            ReadOnlyDistributedContentSession <T> .ContentAvailabilityGuarantee contentAvailabilityGuarantee,
            AbsolutePath tempFolderForCopies,
            IAbsFileSystem fileSystem,
            int locationStoreBatchSize,
            DistributedContentStoreSettings settings,
            int?replicaCreditInMinutes = null,
            IClock clock = null,
            bool enableRepairHandling    = false,
            TimeSpan?contentHashBumpTime = null,
            ContentStoreSettings contentStoreSettings = null)
        {
            Contract.Requires(settings != null);

            LocalMachineLocation          = new MachineLocation(localMachineLocation);
            _enableRepairHandling         = enableRepairHandling;
            _contentLocationStoreFactory  = contentLocationStoreFactory;
            _contentAvailabilityGuarantee = contentAvailabilityGuarantee;
            _locationStoreBatchSize       = locationStoreBatchSize;

            contentStoreSettings = contentStoreSettings ?? ContentStoreSettings.DefaultSettings;
            _settings            = settings;

            // Queue is created in unstarted state because the eviction function
            // requires the context passed at startup.
            _evictionNagleQueue = NagleQueue <ContentHash> .CreateUnstarted(
                Redis.RedisContentLocationStoreConstants.BatchDegreeOfParallelism,
                Redis.RedisContentLocationStoreConstants.BatchInterval,
                _locationStoreBatchSize);

            _distributedCopierFactory = (contentLocationStore) =>
            {
                return(new DistributedContentCopier <T>(
                           tempFolderForCopies,
                           _settings,
                           fileSystem,
                           fileCopier,
                           fileExistenceChecker,
                           copyRequester,
                           pathTransform,
                           contentLocationStore));
            };

            _enableDistributedEviction = replicaCreditInMinutes != null;
            var distributedEvictionSettings = _enableDistributedEviction ? SetUpDistributedEviction(replicaCreditInMinutes, locationStoreBatchSize) : null;

            var enableTouch = contentHashBumpTime.HasValue;

            if (enableTouch)
            {
                _contentTrackerUpdater = new ContentTrackerUpdater(ScheduleBulkTouch, contentHashBumpTime.Value, clock: clock);
            }

            TrimBulkAsync trimBulkAsync = null;

            InnerContentStore = innerContentStoreFunc(_evictionNagleQueue, distributedEvictionSettings, contentStoreSettings, trimBulkAsync);

            if (settings.PinConfiguration?.UsePinCache == true)
            {
                _pinCache = new PinCache(clock: clock);
            }
        }