protected override IContentStore CreateStore(DisposableDirectory testDirectory, ContentStoreConfiguration configuration)
        {
            var rootPath           = testDirectory.Path / "Root";
            var tempPath           = testDirectory.Path / "Temp";
            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 storeFactory = new MockRedisContentLocationStoreFactory(localDatabase, localMachineDatabase, rootPath);

            return(new DistributedContentStore <AbsolutePath>(
                       storeFactory.LocalMachineData,
                       (nagleBlock, distributedEvictionSettings, contentStoreSettings, trimBulkAsync) =>
                       new FileSystemContentStore(
                           FileSystem,
                           SystemClock.Instance, rootPath,
                           configurationModel,
                           nagleQueue: nagleBlock,
                           distributedEvictionSettings: distributedEvictionSettings,
                           settings: contentStoreSettings,
                           trimBulkAsync: trimBulkAsync),
                       storeFactory,
                       fileCopier,
                       fileCopier,
                       storeFactory.PathTransformer,
                       ReadOnlyDistributedContentSession <AbsolutePath> .ContentAvailabilityGuarantee.FileRecordsExist,
                       tempPath,
                       FileSystem,
                       RedisContentLocationStoreConstants.DefaultBatchSize,
                       retryIntervalForCopies: DefaultRetryIntervalsForTest,
                       pinConfiguration: new PinConfiguration()));
        }
Exemple #2
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));
        }
        protected override IContentStore CreateStore(DisposableDirectory testDirectory, ContentStoreConfiguration configuration)
        {
            var rootPath           = testDirectory.Path / "Root";
            var tempPath           = testDirectory.Path / "Temp";
            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);

            return(new DistributedContentStore <AbsolutePath>(
                       localMachineLocation.Data,
                       (nagleBlock, distributedEvictionSettings, contentStoreSettings, trimBulkAsync) =>
                       new FileSystemContentStore(
                           FileSystem,
                           SystemClock.Instance,
                           rootPath,
                           configurationModel,
                           nagleQueue: nagleBlock,
                           distributedEvictionSettings: distributedEvictionSettings,
                           settings: contentStoreSettings,
                           trimBulkAsync: trimBulkAsync),
                       storeFactory,
                       fileCopier,
                       fileCopier,
                       storeFactory.PathTransformer,
                       copyRequester: null,
                       tempPath,
                       FileSystem,
                       settings: new DistributedContentStoreSettings
            {
                ContentAvailabilityGuarantee = ContentAvailabilityGuarantee.FileRecordsExist,
                LocationStoreBatchSize = RedisContentLocationStoreConstants.DefaultBatchSize,
                RetryIntervalForCopies = DefaultRetryIntervalsForTest,
                SetPostInitializationCompletionAfterStartup = true
            }));
        }
Exemple #4
0
        protected override IContentStore CreateStore(
            Context context,
            TestFileCopier fileCopier,
            DisposableDirectory testDirectory,
            int index,
            bool enableDistributedEviction,
            int?replicaCreditInMinutes,
            bool enableRepairHandling,
            object additionalArgs)
        {
            var rootPath           = testDirectory.Path / "Root";
            var tempPath           = testDirectory.Path / "Temp";
            var configurationModel = new ConfigurationModel(Config);
            var pathTransformer    = new TestPathTransformer();
            var localMachineData   = pathTransformer.GetLocalMachineLocation(rootPath);

            if (!_localDatabases.TryGetValue(context.Id, out var localDatabase))
            {
                localDatabase = LocalRedisProcessDatabase.CreateAndStartEmpty(_redis, TestGlobal.Logger, SystemClock.Instance);
                _localDatabases.TryAdd(context.Id, localDatabase);
            }

            if (!_localMachineDatabases.TryGetValue(context.Id, out var localMachineDatabase))
            {
                localMachineDatabase = LocalRedisProcessDatabase.CreateAndStartEmpty(_redis, TestGlobal.Logger, SystemClock.Instance);
                _localMachineDatabases.TryAdd(context.Id, localMachineDatabase);
            }

            if (enableDistributedEviction && replicaCreditInMinutes == null)
            {
                // Apparently, replicaCreditInMinutes != null enables distributed eviction,
                // so make sure replicaCreditInMinutes is set when enableDistributedEviction is
                // true
                replicaCreditInMinutes = 0;
            }

            _configuration = CreateContentLocationStoreConfiguration?.Invoke(rootPath, index) ?? new RedisContentLocationStoreConfiguration();
            _configuration.BlobExpiryTimeMinutes = 10;
            PostProcessConfiguration(_configuration, index);

            var storeFactory = new MockRedisContentLocationStoreFactory(
                localDatabase,
                localMachineDatabase,
                rootPath,
                mockClock: TestClock,
                _configuration);

            var distributedContentStore = new DistributedContentStore <AbsolutePath>(
                localMachineData,
                (nagleBlock, distributedEvictionSettings, contentStoreSettings, trimBulkAsync) =>
                new FileSystemContentStore(
                    FileSystem,
                    TestClock,
                    rootPath,
                    configurationModel,
                    nagleQueue: nagleBlock,
                    distributedEvictionSettings: distributedEvictionSettings,
                    settings: contentStoreSettings,
                    trimBulkAsync: trimBulkAsync),
                storeFactory,
                fileCopier,
                fileCopier,
                pathTransformer,
                fileCopier,
                ContentAvailabilityGuarantee,
                tempPath,
                FileSystem,
                RedisContentLocationStoreConstants.DefaultBatchSize,
                settings: new DistributedContentStoreSettings
            {
                RetryIntervalForCopies = DistributedContentSessionTests.DefaultRetryIntervalsForTest,
                PinConfiguration       = PinConfiguration,
                ShouldInlinePutBlob    = true,
            },
                replicaCreditInMinutes: replicaCreditInMinutes,
                clock: TestClock,
                enableRepairHandling: enableRepairHandling,
                contentStoreSettings: new ContentStoreSettings()
            {
                CheckFiles = true,
            },
                setPostInitializationCompletionAfterStartup: true);

            distributedContentStore.DisposeContentStoreFactory = false;
            return(distributedContentStore);
        }