Beispiel #1
0
        private StartupShutdownBase CreateLocalServer(LocalServerConfiguration localServerConfiguration, DistributedContentSettings distributedSettings = null)
        {
            var resolvedCacheSettings = DistributedContentStoreFactory.ResolveCacheSettingsInPrecedenceOrder(_arguments);

            Func <AbsolutePath, IContentStore> contentStoreFactory = path => DistributedContentStoreFactory.CreateLocalContentStore(
                distributedSettings,
                _arguments,
                resolvedCacheSettings.Where(s => s.ResolvedCacheRootPath == path || s.ResolvedCacheRootPath.Path.StartsWith(path.Path, StringComparison.OrdinalIgnoreCase)).Single());

            if (distributedSettings?.EnableMetadataStore == true)
            {
                _logger.Always("Creating local server with content and metadata store");

                var factory = CreateDistributedContentStoreFactory();

                Func <AbsolutePath, ICache> cacheFactory = path =>
                {
                    var distributedCache = new OneLevelCache(
                        contentStoreFunc: () => contentStoreFactory(path),
                        memoizationStoreFunc: () => CreateServerSideLocalMemoizationStore(path, factory),
                        Guid.NewGuid(),
                        passContentToMemoization: true);

                    ICache cacheToReturn = distributedCache;
#if MICROSOFT_INTERNAL
                    if (distributedSettings.EnablePublishingCache)
                    {
                        cacheToReturn = new PublishingCache <OneLevelCache>(
                            local: distributedCache,
                            remote: new BuildCachePublishingStore(contentSource: distributedCache, _fileSystem, distributedSettings.PublishingConcurrencyLimit),
                            Guid.NewGuid());
                    }
#endif

                    return(cacheToReturn);
                };

                return(new LocalCacheServer(
                           _fileSystem,
                           _logger,
                           _arguments.Configuration.LocalCasSettings.ServiceSettings.ScenarioName,
                           cacheFactory,
                           localServerConfiguration,
                           capabilities: distributedSettings.EnablePublishingCache?Capabilities.All: Capabilities.AllNonPublishing));
            }
            else
            {
                _logger.Always("Creating local server with content store only");

                return(new LocalContentServer(
                           _fileSystem,
                           _logger,
                           _arguments.Configuration.LocalCasSettings.ServiceSettings.ScenarioName,
                           contentStoreFactory,
                           localServerConfiguration));
            }
        }
Beispiel #2
0
        private StartupShutdownBase CreateLocalServer(LocalServerConfiguration localServerConfiguration, DistributedContentSettings distributedSettings = null)
        {
            var resolvedCacheSettings = DistributedContentStoreFactory.ResolveCacheSettingsInPrecedenceOrder(_arguments);

            Func <AbsolutePath, IContentStore> contentStoreFactory = path => DistributedContentStoreFactory.CreateLocalContentStore(
                distributedSettings,
                _arguments,
                resolvedCacheSettings.Where(s => s.ResolvedCacheRootPath == path || s.ResolvedCacheRootPath.Path.StartsWith(path.Path, StringComparison.OrdinalIgnoreCase)).Single());

            if (distributedSettings?.EnableMetadataStore == true)
            {
                var factory = CreateDistributedContentStoreFactory();

                Func <AbsolutePath, ICache> cacheFactory = path =>
                {
                    return(new OneLevelCache(
                               contentStoreFunc: () => contentStoreFactory(path),
                               memoizationStoreFunc: () => CreateServerSideLocalMemoizationStore(path, factory),
                               Guid.NewGuid(),
                               passContentToMemoization: true));
                };

                return(new LocalCacheServer(
                           _fileSystem,
                           _logger,
                           _arguments.Configuration.LocalCasSettings.ServiceSettings.ScenarioName,
                           cacheFactory,
                           localServerConfiguration));
            }
            else
            {
                return(new LocalContentServer(
                           _fileSystem,
                           _logger,
                           _arguments.Configuration.LocalCasSettings.ServiceSettings.ScenarioName,
                           contentStoreFactory,
                           localServerConfiguration));
            }
        }
Beispiel #3
0
        private IMemoizationStore CreateServerSideLocalMemoizationStore(AbsolutePath path, DistributedContentStoreFactory factory)
        {
            var distributedSettings = _arguments.Configuration.DistributedContentSettings;

            if (distributedSettings.UseRedisMetadataStore)
            {
                return(factory.CreateMemoizationStoreAsync().GetAwaiter().GetResult());
            }
            else if (distributedSettings.UseRoxisMetadataStore)
            {
                var config = new RoxisMemoizationDatabaseConfiguration();
                ApplyIfNotNull(distributedSettings.RoxisMetadataStoreHost, v => config.MetadataClientConfiguration.GrpcHost = v);
                ApplyIfNotNull(distributedSettings.RoxisMetadataStorePort, v => config.MetadataClientConfiguration.GrpcPort = v);

                return(config.CreateStore(_logger, SystemClock.Instance));
            }
            else
            {
                var config = new RocksDbMemoizationStoreConfiguration()
                {
                    Database = RocksDbContentLocationDatabaseConfiguration.FromDistributedContentSettings(
                        distributedSettings,
                        databasePath: path / "RocksDbMemoizationStore",
                        logsBackupPath: null,
                        logsKeepLongTerm: true),
                };

                config.Database.CleanOnInitialize = false;
                config.Database.OnFailureDeleteExistingStoreAndRetry = true;
                config.Database.MetadataGarbageCollectionEnabled     = true;

                return(new RocksDbMemoizationStore(_logger, SystemClock.Instance, config));
            }
        }
        private IMemoizationStore CreateServerSideLocalMemoizationStore(AbsolutePath path, DistributedContentStoreFactory factory)
        {
            var distributedSettings = _arguments.Configuration.DistributedContentSettings;

            if (distributedSettings.UseRedisMetadataStore)
            {
                return(factory.CreateMemoizationStoreAsync().GetAwaiter().GetResult());
            }
            else if (distributedSettings.UseRoxisMetadataStore)
            {
                var config = new RoxisMemoizationDatabaseConfiguration();
                ApplyIfNotNull(distributedSettings.RoxisMetadataStoreHost, v => config.MetadataClientConfiguration.GrpcHost = v);
                ApplyIfNotNull(distributedSettings.RoxisMetadataStorePort, v => config.MetadataClientConfiguration.GrpcPort = v);

                return(config.CreateStore(_logger, SystemClock.Instance));
            }
            else
            {
                var config = new RocksDbMemoizationStoreConfiguration()
                {
                    Database = new RocksDbContentLocationDatabaseConfiguration(path / "RocksDbMemoizationStore")
                    {
                        CleanOnInitialize = false,
                        OnFailureDeleteExistingStoreAndRetry = true,
                        LogsKeepLongTerm = true,
                        MetadataGarbageCollectionEnabled = true,
                        MetadataGarbageCollectionMaximumNumberOfEntriesToKeep = distributedSettings.MaximumNumberOfMetadataEntriesToStore,
                    },
                };

                return(new RocksDbMemoizationStore(_logger, SystemClock.Instance, config));
            }
        }
Beispiel #5
0
        private IMemoizationStore CreateServerSideLocalMemoizationStore(AbsolutePath path, DistributedContentStoreFactory factory)
        {
            var distributedSettings = _arguments.Configuration.DistributedContentSettings;

            if (distributedSettings.UseRedisMetadataStore)
            {
                return(RedisMemoizationStoreFactory.CreateMemoizationStore(factory.Services.ContentLocationStoreServices.Instance));
            }
            else
            {
                var config = new RocksDbMemoizationStoreConfiguration()
                {
                    Database = RocksDbContentLocationDatabaseConfiguration.FromDistributedContentSettings(
                        distributedSettings,
                        databasePath: path / "RocksDbMemoizationStore",
                        logsBackupPath: null,
                        logsKeepLongTerm: true),
                };

                config.Database.CleanOnInitialize = false;
                config.Database.OnFailureDeleteExistingStoreAndRetry = true;
                config.Database.MetadataGarbageCollectionEnabled     = true;

                return(new RocksDbMemoizationStore(_logger, SystemClock.Instance, config));
            }
        }