private static LocalCache CreateLocalCacheWithSingleCas(Config config, DisposeLogger logger)
        {
            LocalCacheConfiguration localCacheConfiguration;

            if (config.EnableContentServer)
            {
                localCacheConfiguration = LocalCacheConfiguration.CreateServerEnabled(
                    config.GrpcPort,
                    config.CacheName,
                    config.ScenarioName,
                    config.RetryIntervalSeconds,
                    config.RetryCount);
            }
            else
            {
                localCacheConfiguration = LocalCacheConfiguration.CreateServerDisabled();
            }

            var configCore         = GetCasConfig(config);
            var configurationModel = CreateConfigurationModel(configCore);
            var cacheRoot          = new AbsolutePath(config.CacheRootPath);
            var memoConfig         = GetMemoizationStoreConfiguration(cacheRoot, config, configCore);

            return(new LocalCache(
                       logger,
                       cacheRoot,
                       memoConfig,
                       localCacheConfiguration,
                       configurationModel: configurationModel,
                       clock: null,
                       checkLocalFiles: config.CheckLocalFiles,
                       emptyFileHashShortcutEnabled: config.EmptyFileHashShortcutEnabled));
        }
        protected override ICache CreateCache(DisposableDirectory testDirectory)
        {
            var rootPath      = testDirectory.Path;
            var configuration = ContentStoreConfiguration.CreateWithMaxSizeQuotaMB(1);

            configuration.Write(FileSystem, rootPath).Wait();

            return(new LocalCache(Logger, rootPath, new SQLiteMemoizationStoreConfiguration(rootPath)
            {
                MaxRowCount = MaxContentHashListItems, JournalMode = ContentStore.SQLite.JournalMode.OFF
            }, LocalCacheConfiguration.CreateServerDisabled(), clock: Clock));
        }
Beispiel #3
0
        protected override IStartupShutdown CreateFirstInstance(DisposableDirectory testDirectory, int singleInstanceTimeoutSeconds)
        {
            var rootPath = testDirectory.Path;
            var config   = new ContentStoreConfiguration(new MaxSizeQuota("1MB"), singleInstanceTimeoutSeconds: singleInstanceTimeoutSeconds);

            return(new LocalCache(
                       Logger,
                       rootPath,
                       new SQLiteMemoizationStoreConfiguration(rootPath)
            {
                MaxRowCount = MaxStrongFingerprints, SingleInstanceTimeoutSeconds = singleInstanceTimeoutSeconds
            },
                       LocalCacheConfiguration.CreateServerDisabled(),
                       clock: Clock,
                       configurationModel: new ConfigurationModel(config)));
        }
Beispiel #4
0
        private static MemoizationStore.Interfaces.Caches.ICache CreateLocalCacheWithSingleCas(Config config, DisposeLogger logger)
        {
            if (config.EnableContentServer && config.EnableMetadataServer)
            {
                Contract.Assert(config.RetryIntervalSeconds >= 0);
                Contract.Assert(config.RetryCount >= 0);

                var rpcConfiguration           = new ServiceClientRpcConfiguration(config.GrpcPort);
                var serviceClientConfiguration = new ServiceClientContentStoreConfiguration(config.CacheName, rpcConfiguration, config.ScenarioName)
                {
                    RetryIntervalSeconds = (uint)config.RetryIntervalSeconds,
                    RetryCount           = (uint)config.RetryCount,
                };

                return(LocalCache.CreateRpcCache(logger, serviceClientConfiguration));
            }
            else
            {
                Contract.Assert(!config.EnableMetadataServer, "It is not supported to use a Metadata server without a Content server");

                LocalCacheConfiguration localCacheConfiguration;
                if (config.EnableContentServer)
                {
                    localCacheConfiguration = LocalCacheConfiguration.CreateServerEnabled(
                        config.GrpcPort,
                        config.CacheName,
                        config.ScenarioName,
                        config.RetryIntervalSeconds,
                        config.RetryCount);
                }
                else
                {
                    localCacheConfiguration = LocalCacheConfiguration.CreateServerDisabled();
                }

                return(LocalCache.CreateUnknownContentStoreInProcMemoizationStoreCache(logger,
                                                                                       new AbsolutePath(config.CacheRootPath),
                                                                                       GetInProcMemoizationStoreConfiguration(new AbsolutePath(config.CacheRootPath), config, GetCasConfig(config)),
                                                                                       localCacheConfiguration,
                                                                                       configurationModel: CreateConfigurationModel(GetCasConfig(config)),
                                                                                       clock: null,
                                                                                       checkLocalFiles: config.CheckLocalFiles,
                                                                                       emptyFileHashShortcutEnabled: config.EmptyFileHashShortcutEnabled));
            }
        }
        protected override IStartupShutdown CreateInstance(DisposableDirectory testDirectory, int singleInstanceTimeoutSeconds)
        {
            var rootPath = testDirectory.Path;
            var config   = new ContentStoreConfiguration(new MaxSizeQuota("1MB"), singleInstanceTimeoutSeconds: singleInstanceTimeoutSeconds);

            return(LocalCache.CreateUnknownContentStoreInProcMemoizationStoreCache(
                       Logger,
                       rootPath,
                       new RocksDbMemoizationStoreConfiguration()
            {
                Database = new RocksDbContentLocationDatabaseConfiguration(rootPath)
                {
                    CleanOnInitialize = false,
                    OnFailureDeleteExistingStoreAndRetry = true,
                    LogsKeepLongTerm = true,
                    MetadataGarbageCollectionEnabled = true,
                    MetadataGarbageCollectionMaximumNumberOfEntriesToKeep = MaxStrongFingerprints,
                },
            },
                       LocalCacheConfiguration.CreateServerDisabled(),
                       clock: Clock,
                       configurationModel: new ConfigurationModel(config)));
        }
Beispiel #6
0
        protected override ICache CreateCache(DisposableDirectory testDirectory)
        {
            var rootPath      = testDirectory.Path;
            var configuration = ContentStoreConfiguration.CreateWithMaxSizeQuotaMB(1);

            configuration.Write(FileSystem, rootPath);

            var memoConfig = new RocksDbMemoizationStoreConfiguration()
            {
                Database = new RocksDbContentLocationDatabaseConfiguration(rootPath)
                {
                    CleanOnInitialize = false,
                    OnFailureDeleteExistingStoreAndRetry = true,
                    LogsKeepLongTerm = true,
                    MetadataGarbageCollectionEnabled = true,
                    MetadataGarbageCollectionMaximumNumberOfEntriesToKeep = MaxContentHashListItems,
                },
            };

            return(LocalCache.CreateUnknownContentStoreInProcMemoizationStoreCache(Logger, rootPath, memoConfig, LocalCacheConfiguration.CreateServerDisabled(), clock: Clock));
        }