예제 #1
0
        internal DistributedCacheServiceArguments CreateDistributedCacheServiceArguments(
            IAbsolutePathFileCopier copier,
            IAbsolutePathTransformer pathTransformer,
            IProactiveCopier copyRequester,
            DistributedContentSettings dcs,
            HostInfo host,
            string cacheName,
            string cacheRootPath,
            uint grpcPort,
            int maxSizeQuotaMB,
            string dataRootPath,
            CancellationToken ct,
            int?bufferSizeForGrpcCopies,
            int?gzipBarrierSizeForGrpcCopies)
        {
            var distributedCacheServiceHost = new EnvironmentVariableHost();

            var localCasSettings = LocalCasSettings.Default(
                maxSizeQuotaMB: maxSizeQuotaMB,
                cacheRootPath: cacheRootPath,
                cacheName: cacheName,
                grpcPort: grpcPort,
                grpcPortFileName: _scenario);

            localCasSettings.PreferredCacheDrive = Path.GetPathRoot(cacheRootPath);
            localCasSettings.ServiceSettings     = new LocalCasServiceSettings(60, scenarioName: _scenario, grpcPort: grpcPort, grpcPortFileName: _scenario, bufferSizeForGrpcCopies: bufferSizeForGrpcCopies, gzipBarrierSizeForGrpcCopies: gzipBarrierSizeForGrpcCopies,
                                                                               grpcThreadPoolSize: null);

            var config = new DistributedCacheServiceConfiguration(localCasSettings, dcs);

            return(new DistributedCacheServiceArguments(_logger, copier, pathTransformer, copyRequester, distributedCacheServiceHost, host, ct, dataRootPath, config, null));
        }
예제 #2
0
        /// <nodoc />
        public DistributedContentCopier(
            AbsolutePath workingDirectory,
            DistributedContentStoreSettings settings,
            IAbsFileSystem fileSystem,
            IFileCopier <T> fileCopier,
            IFileExistenceChecker <T> fileExistenceChecker,
            IProactiveCopier copyRequester,
            IPathTransformer <T> pathTransformer,
            IContentLocationStore contentLocationStore)
        {
            Contract.Requires(settings != null);
            Contract.Requires(settings.ParallelHashingFileSizeBoundary >= -1);

            _settings                   = settings;
            _tempFolderForCopies        = new DisposableDirectory(fileSystem, workingDirectory / "Temp");
            _remoteFileCopier           = fileCopier;
            _remoteFileExistenceChecker = fileExistenceChecker;
            _copyRequester              = copyRequester;
            _contentLocationStore       = contentLocationStore;
            _pathTransformer            = pathTransformer;
            _fileSystem                 = fileSystem;

            _workingDirectory = _tempFolderForCopies.Path;

            _ioGate = new SemaphoreSlim(_settings.MaxConcurrentCopyOperations);
            _proactiveCopyIoGate       = new SemaphoreSlim(_settings.MaxConcurrentProactiveCopyOperations);
            _retryIntervals            = settings.RetryIntervalForCopies;
            _maxRetryCount             = settings.MaxRetryCount;
            _timeoutForProactiveCopies = settings.TimeoutForProactiveCopies;
        }
예제 #3
0
 public TestDistributedContentCopier(
     AbsolutePath workingDirectory,
     DistributedContentStoreSettings settings,
     IAbsFileSystem fileSystem,
     IFileCopier <AbsolutePath> fileCopier,
     IFileExistenceChecker <AbsolutePath> fileExistenceChecker,
     IProactiveCopier copyRequester,
     IPathTransformer <AbsolutePath> pathTransformer,
     IContentLocationStore contentLocationStore)
     : base(workingDirectory, settings, fileSystem, fileCopier, fileExistenceChecker, copyRequester, pathTransformer, TestSystemClock.Instance, contentLocationStore)
 {
 }
        /// <inheritdoc />
        public DistributedCacheServiceArguments(
            ILogger logger,
            IAbsolutePathFileCopier copier,
            IAbsolutePathTransformer pathTransformer,
            IProactiveCopier copyRequester,
            IDistributedCacheServiceHost host,
            HostInfo hostInfo,
            CancellationToken cancellation,
            string dataRootPath,
            DistributedCacheServiceConfiguration configuration,
            string keyspace)
        {
            Logger          = logger;
            Copier          = copier;
            CopyRequester   = copyRequester;
            PathTransformer = pathTransformer;
            Host            = host;
            HostInfo        = hostInfo;
            Cancellation    = cancellation;
            DataRootPath    = dataRootPath;
            Configuration   = configuration;

            Keyspace = ComputeKeySpace(hostInfo, configuration, keyspace);
        }
예제 #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,
            IProactiveCopier 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,
            bool setPostInitializationCompletionAfterStartup = false)
        {
            Contract.Requires(settings != null);

            _setPostInitializationCompletionAfterStartup = setPostInitializationCompletionAfterStartup;
            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);
            }
        }