コード例 #1
0
        public DistributedCentralStorage(
            DistributedCentralStoreConfiguration configuration,
            ILocationStore locationStore,
            DistributedContentCopier copier,
            CentralStorage fallbackStorage)
        {
            _configuration   = configuration;
            _copier          = copier;
            _fallbackStorage = fallbackStorage;
            _locationStore   = locationStore;

            var maxRetentionMb  = (int)Math.Ceiling(configuration.MaxRetentionGb * 1024);
            var softRetentionMb = (int)(maxRetentionMb * 0.8);

            var cacheFolder = configuration.CacheRoot / CacheSubFolderName;

            _copierWorkingDirectory = new DisposableDirectory(copier.FileSystem, cacheFolder / "Temp");

            // Create a private CAS for storing checkpoint data
            // Avoid introducing churn into primary CAS
            _privateCas = new FileSystemContentStoreInternal(
                copier.FileSystem,
                SystemClock.Instance,
                cacheFolder,
                new ConfigurationModel(
                    new ContentStoreConfiguration(new MaxSizeQuota(hardExpression: maxRetentionMb + "MB", softExpression: softRetentionMb + "MB")),
                    ConfigurationSelection.RequireAndUseInProcessConfiguration),
                settings: new ContentStoreSettings()
            {
                TraceFileSystemContentStoreDiagnosticMessages = _configuration.TraceFileSystemContentStoreDiagnosticMessages,
                SelfCheckSettings = _configuration.SelfCheckSettings,
            });
        }
コード例 #2
0
        public DistributedContentStoreFactory(DistributedCacheServiceArguments arguments)
        {
            _logger              = arguments.Logger;
            _arguments           = arguments;
            _distributedSettings = arguments.Configuration.DistributedContentSettings;
            _keySpace            = string.IsNullOrWhiteSpace(_arguments.Keyspace) ? ContentLocationStoreFactory.DefaultKeySpace : _arguments.Keyspace;
            _fileSystem          = new PassThroughFileSystem(_logger);
            _secretRetriever     = new DistributedCacheSecretRetriever(arguments);
            var bandwidthCheckedCopier = new BandwidthCheckedCopier(_arguments.Copier, BandwidthChecker.Configuration.FromDistributedContentSettings(_distributedSettings));

            _orderedResolvedCacheSettings = ResolveCacheSettingsInPrecedenceOrder(arguments);
            Contract.Assert(_orderedResolvedCacheSettings.Count != 0);

            RedisContentLocationStoreConfiguration = CreateRedisConfiguration();
            _distributedContentStoreSettings       = CreateDistributedStoreSettings(_arguments, RedisContentLocationStoreConfiguration);

            _copier = new DistributedContentCopier <AbsolutePath>(
                _distributedContentStoreSettings,
                _fileSystem,
                fileCopier: bandwidthCheckedCopier,
                fileExistenceChecker: _arguments.Copier,
                _arguments.CopyRequester,
                _arguments.PathTransformer,
                _arguments.Overrides.Clock
                );

            _redisMemoizationStoreFactory = new Lazy <RedisMemoizationStoreFactory>(() => CreateRedisCacheFactory());
        }
コード例 #3
0
 /// <nodoc />
 public RedisMemoizationStoreFactory(
     IClock clock,
     RedisMemoizationStoreConfiguration configuration,
     DistributedContentCopier copier)
     : base(clock, configuration, copier)
 {
 }
コード例 #4
0
        public DistributedContentStoreFactory(DistributedCacheServiceArguments arguments)
        {
            _logger              = arguments.Logger;
            _arguments           = arguments;
            _distributedSettings = arguments.Configuration.DistributedContentSettings;
            _keySpace            = string.IsNullOrWhiteSpace(_arguments.Keyspace) ? ContentLocationStoreFactory.DefaultKeySpace : _arguments.Keyspace;
            _fileSystem          = arguments.FileSystem;
            _secretRetriever     = new DistributedCacheSecretRetriever(arguments);

            _orderedResolvedCacheSettings = ResolveCacheSettingsInPrecedenceOrder(arguments);
            Contract.Assert(_orderedResolvedCacheSettings.Count != 0);

            RedisContentLocationStoreConfiguration = CreateRedisConfiguration();
            _distributedContentStoreSettings       = CreateDistributedStoreSettings(_arguments, RedisContentLocationStoreConfiguration);

            _copier = new DistributedContentCopier(
                _distributedContentStoreSettings,
                _fileSystem,
                fileCopier: _arguments.Copier,
                copyRequester: _arguments.CopyRequester,
                _arguments.Overrides.Clock,
                _logger
                );

            _redisMemoizationStoreFactory = new Lazy <RedisMemoizationStoreFactory>(() => CreateRedisCacheFactory());
        }
コード例 #5
0
 public ContentLocationStoreFactory(
     IClock clock,
     RedisContentLocationStoreConfiguration configuration,
     DistributedContentCopier copier)
     : this(
         new ContentLocationStoreFactoryArguments()
 {
     Clock = clock,
     Copier = copier
 },
         configuration)
 {
 }
コード例 #6
0
        public ContentLocationStoreFactory(
            IClock clock,
            RedisContentLocationStoreConfiguration configuration,
            DistributedContentCopier copier)
        {
            Contract.Requires(configuration != null);
            Contract.Requires(!string.IsNullOrEmpty(configuration.RedisGlobalStoreConnectionString));
            Contract.Requires(!string.IsNullOrWhiteSpace(configuration.Keyspace));
            Contract.Requires(copier != null);

            Clock  = clock;
            Copier = copier;
            _lazyLocalLocationStore = new Lazy <LocalLocationStore>(() => CreateLocalLocationStore());
            Configuration           = configuration;
        }
コード例 #7
0
        public DistributedCentralStorage(
            DistributedCentralStoreConfiguration configuration,
            ILocationStore locationStore,
            DistributedContentCopier copier,
            CentralStorage fallbackStorage,
            IClock clock)
            : base(configuration, fallbackStorage, copier.FileSystem)
        {
            _copier           = copier;
            _locationStore    = locationStore;
            _checkpointCopies = new VolatileMap <ShortHash, CopyOperation>(clock);
            _checkpointStore  = configuration.IsCheckpointAware ? _locationStore as ICheckpointStore : null;

            _copierWorkingDirectory = new DisposableDirectory(copier.FileSystem, PrivateCas !.RootPath / "Temp");
        }
コード例 #8
0
 /// <nodoc />
 public DistributedContentSession(
     string name,
     IContentSession inner,
     IContentLocationStore contentLocationStore,
     DistributedContentCopier contentCopier,
     IDistributedContentCopierHost copierHost,
     MachineLocation localMachineLocation,
     DistributedContentStoreSettings settings = default)
     : base(
         name,
         inner,
         contentLocationStore,
         contentCopier,
         copierHost,
         localMachineLocation,
         settings)
 {
 }
コード例 #9
0
        private async Task <(DistributedContentCopier <AbsolutePath>, MockFileCopier)> CreateAsync(Context context, AbsolutePath rootDirectory, int retries = 1)
        {
            var mockFileCopier   = new MockFileCopier();
            var existenceChecker = new TestFileCopier();
            var contentCopier    = new DistributedContentCopier <AbsolutePath>(
                rootDirectory,
                // Need to use exactly one retry.
                new DistributedContentStoreSettings()
            {
                RetryIntervalForCopies = Enumerable.Range(0, retries).Select(r => TimeSpan.Zero).ToArray()
            },
                FileSystem,
                mockFileCopier,
                existenceChecker,
                new NoOpPathTransformer(rootDirectory),
                new MockContentLocationStore());
            await contentCopier.StartupAsync(context).ThrowIfFailure();

            return(contentCopier, mockFileCopier);
        }
コード例 #10
0
 /// <nodoc />
 public DistributedContentSession(
     string name,
     IContentSession inner,
     IContentLocationStore contentLocationStore,
     DistributedContentCopier contentCopier,
     DistributedContentStore distributedStore,
     MachineLocation localMachineLocation,
     ColdStorage coldStorage,
     DistributedContentStoreSettings settings = default)
     : base(
         name,
         inner,
         contentLocationStore,
         contentCopier,
         distributedStore,
         localMachineLocation,
         coldStorage,
         settings)
 {
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DistributedContentSession{T}"/> class.
 /// </summary>
 public DistributedContentSession(
     string name,
     IContentSession inner,
     IContentLocationStore contentLocationStore,
     DistributedContentCopier <T> contentCopier,
     MachineLocation localMachineLocation,
     PinCache pinCache = null,
     ContentTrackerUpdater contentTrackerUpdater = null,
     DistributedContentStoreSettings settings    = default)
     : base(
         name,
         inner,
         contentLocationStore,
         contentCopier,
         localMachineLocation,
         pinCache: pinCache,
         contentTrackerUpdater: contentTrackerUpdater,
         settings)
 {
     _putFileGate = new SemaphoreSlim(settings.MaximumConcurrentPutFileOperations);
 }
コード例 #12
0
        protected override IContentStore CreateStore(DisposableDirectory testDirectory, ContentStoreConfiguration configuration)
        {
            var rootPath           = testDirectory.Path / "Root";
            var configurationModel = new ConfigurationModel(configuration);
            var fileCopier         = new TestFileCopier();

            var localDatabase        = LocalRedisProcessDatabase.CreateAndStartEmpty(_redis, TestGlobal.Logger, SystemClock.Instance);
            var localMachineDatabase = LocalRedisProcessDatabase.CreateAndStartEmpty(_redis, TestGlobal.Logger, SystemClock.Instance);

            var localMachineLocation = new MachineLocation(rootPath.Path);
            var storeFactory         = new MockRedisContentLocationStoreFactory(localDatabase, localMachineDatabase, rootPath);

            var settings = CreateSettings();

            var distributedCopier = new DistributedContentCopier <AbsolutePath>(
                settings,
                FileSystem,
                fileCopier,
                fileCopier,
                copyRequester: null,
                storeFactory.PathTransformer,
                SystemClock.Instance);

            return(new DistributedContentStore <AbsolutePath>(
                       localMachineLocation,
                       rootPath,
                       (nagleBlock, distributedEvictionSettings, contentStoreSettings, trimBulkAsync) =>
                       new FileSystemContentStore(
                           FileSystem,
                           SystemClock.Instance,
                           rootPath,
                           configurationModel,
                           nagleQueue: nagleBlock,
                           distributedEvictionSettings: distributedEvictionSettings,
                           settings: contentStoreSettings,
                           trimBulkAsync: trimBulkAsync),
                       storeFactory,
                       settings: settings,
                       distributedCopier: distributedCopier));
        }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DistributedContentSession{T}"/> class.
 /// </summary>
 public DistributedContentSession(
     string name,
     IContentSession inner,
     IContentLocationStore contentLocationStore,
     ContentAvailabilityGuarantee contentAvailabilityGuarantee,
     DistributedContentCopier <T> contentCopier,
     byte[] localMachineLocation,
     PinCache pinCache = null,
     ContentTrackerUpdater contentTrackerUpdater = null,
     DistributedContentStoreSettings settings    = default)
     : base(
         name,
         inner,
         contentLocationStore,
         contentAvailabilityGuarantee,
         contentCopier,
         localMachineLocation,
         pinCache: pinCache,
         contentTrackerUpdater: contentTrackerUpdater,
         settings)
 {
 }
コード例 #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DistributedContentSession{T}"/> class.
 /// </summary>
 public DistributedContentSession(
     string name,
     IContentSession inner,
     IContentLocationStore contentLocationStore,
     DistributedContentCopier <T> contentCopier,
     IDistributedContentCopierHost copierHost,
     MachineLocation localMachineLocation,
     PinCache pinCache = null,
     ContentTrackerUpdater contentTrackerUpdater = null,
     DistributedContentStoreSettings settings    = default)
     : base(
         name,
         inner,
         contentLocationStore,
         contentCopier,
         copierHost,
         localMachineLocation,
         pinCache: pinCache,
         contentTrackerUpdater: contentTrackerUpdater,
         settings)
 {
 }