コード例 #1
0
 private LocalCache(
     ILogger logger,
     AbsolutePath rootPath,
     IAbsFileSystem fileSystem,
     IClock clock,
     ConfigurationModel configurationModel,
     MemoizationStoreConfiguration memoConfig,
     ContentStoreSettings contentStoreSettings,
     LocalCacheConfiguration localCacheConfiguration)
     : base(
         () => localCacheConfiguration.EnableContentServer
             ? (IContentStore) new ServiceClientContentStore(
             logger,
             fileSystem,
             localCacheConfiguration.CacheName,
             new ServiceClientRpcConfiguration(localCacheConfiguration.GrpcPort),
             (uint)localCacheConfiguration.RetryIntervalSeconds,
             (uint)localCacheConfiguration.RetryCount,
             scenario: localCacheConfiguration.ScenarioName)
             : new FileSystemContentStore(
             fileSystem,
             clock,
             rootPath,
             configurationModel: configurationModel,
             settings: contentStoreSettings),
         CreateMemoizationStoreFactory(logger, clock, memoConfig),
         PersistentId.Load(fileSystem, rootPath / IdFileName))
 {
     _fileSystem = fileSystem;
 }
コード例 #2
0
        /// <summary>
        ///     Content Stores:
        ///         - <see cref="ServiceClientContentStore"/>
        ///     Memoization Stores:
        ///         - <see cref="CreateInProcessLocalMemoizationStoreFactory(ILogger, IClock, MemoizationStoreConfiguration)"/>
        /// </summary>
        public static LocalCache CreateRpcContentStoreInProcMemoizationStoreCache(ILogger logger,
                                                                                  AbsolutePath rootPath,
                                                                                  ServiceClientContentStoreConfiguration serviceClientContentStoreConfiguration,
                                                                                  MemoizationStoreConfiguration memoizationStoreConfiguration,
                                                                                  IClock clock = null)
        {
            var fileSystem = new PassThroughFileSystem(logger);

            clock = clock ?? SystemClock.Instance;

            Func <IContentStore> remoteContentStoreFactory = () => new ServiceClientContentStore(logger, fileSystem, serviceClientContentStoreConfiguration);
            var localMemoizationStoreFactory = CreateInProcessLocalMemoizationStoreFactory(logger, clock, memoizationStoreConfiguration);

            return(new LocalCache(fileSystem, remoteContentStoreFactory, localMemoizationStoreFactory, LoadPersistentCacheGuid(rootPath, fileSystem)));
        }
コード例 #3
0
 private LocalCache(
     ILogger logger,
     AbsolutePath rootPath,
     IAbsFileSystem fileSystem,
     IClock clock,
     ServiceClientContentStoreConfiguration configuration,
     MemoizationStoreConfiguration memoConfig)
     : base(
         () => new ServiceClientContentStore(
             logger, fileSystem, configuration),
         CreateMemoizationStoreFactory(logger, clock, memoConfig),
         PersistentId.Load(fileSystem, rootPath / IdFileName))
 {
     _fileSystem = fileSystem;
 }
コード例 #4
0
        /// <summary>
        ///     Content Stores:
        ///         - <see cref="ServiceClientContentStore"/> if <see cref="LocalCacheConfiguration.EnableContentServer"/>
        ///         - <see cref="FileSystemContentStore"/> otherwise
        ///     Memoization Stores:
        ///         - <see cref="CreateInProcessLocalMemoizationStoreFactory(ILogger, IClock, MemoizationStoreConfiguration)"/>
        /// </summary>
        public static LocalCache CreateUnknownContentStoreInProcMemoizationStoreCache(
            ILogger logger,
            AbsolutePath rootPath,
            MemoizationStoreConfiguration memoizationStoreConfiguration,
            LocalCacheConfiguration localCacheConfiguration,
            ConfigurationModel configurationModel = null,
            IClock clock         = null,
            bool checkLocalFiles = true,
            bool emptyFileHashShortcutEnabled = false)
        {
            clock = clock ?? SystemClock.Instance;

            var fileSystem           = new PassThroughFileSystem(logger);
            var contentStoreSettings = new ContentStoreSettings()
            {
                CheckFiles = checkLocalFiles,
                UseEmptyFileHashShortcut = emptyFileHashShortcutEnabled
            };

            Func <IContentStore> contentStoreFactory = () =>
            {
                if (localCacheConfiguration.EnableContentServer)
                {
                    return(new ServiceClientContentStore(
                               logger,
                               fileSystem,
                               localCacheConfiguration.CacheName,
                               new ServiceClientRpcConfiguration(localCacheConfiguration.GrpcPort),
                               (uint)localCacheConfiguration.RetryIntervalSeconds,
                               (uint)localCacheConfiguration.RetryCount,
                               scenario: localCacheConfiguration.ScenarioName));
                }
                else
                {
                    return(new FileSystemContentStore(
                               fileSystem,
                               clock,
                               rootPath,
                               configurationModel: configurationModel,
                               settings: contentStoreSettings));
                }
            };

            var memoizationStoreFactory = CreateInProcessLocalMemoizationStoreFactory(logger, clock, memoizationStoreConfiguration);

            return(new LocalCache(fileSystem, contentStoreFactory, memoizationStoreFactory, LoadPersistentCacheGuid(rootPath, fileSystem)));
        }
コード例 #5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="LocalCache" /> class backed by <see cref="FileSystemContentStore"/>
 /// </summary>
 public LocalCache(
     ILogger logger,
     AbsolutePath rootPath,
     MemoizationStoreConfiguration memoConfig,
     LocalCacheConfiguration localCacheConfiguration,
     ConfigurationModel configurationModel = null,
     IClock clock         = null,
     bool checkLocalFiles = true,
     bool emptyFileHashShortcutEnabled = false)
     : this(
         logger,
         rootPath,
         new PassThroughFileSystem(logger),
         clock ?? SystemClock.Instance,
         configurationModel,
         memoConfig,
         new ContentStoreSettings() { CheckFiles = checkLocalFiles, UseEmptyFileHashShortcut = emptyFileHashShortcutEnabled },
         localCacheConfiguration)
 {
 }
コード例 #6
0
 private LocalCache(
     ILogger logger,
     AbsolutePath rootPathForStream,
     AbsolutePath rootPathForPath,
     IAbsFileSystem fileSystem,
     IClock clock,
     ConfigurationModel configurationModelForStream,
     ConfigurationModel configurationModelForPath,
     MemoizationStoreConfiguration memoConfig,
     bool checkLocalFiles,
     bool emptyFileHashShortcutEnabled)
     : base(
         () => new StreamPathContentStore(
             () => new FileSystemContentStore(fileSystem, clock ?? SystemClock.Instance, rootPathForStream, configurationModelForStream, settings: new ContentStoreSettings() { CheckFiles = checkLocalFiles, UseEmptyFileHashShortcut = emptyFileHashShortcutEnabled }),
             () => new FileSystemContentStore(fileSystem, clock ?? SystemClock.Instance, rootPathForPath, configurationModelForPath, settings: new ContentStoreSettings() { CheckFiles = checkLocalFiles, UseEmptyFileHashShortcut = emptyFileHashShortcutEnabled })),
         CreateMemoizationStoreFactory(logger, clock, memoConfig),
         PersistentId.Load(fileSystem, rootPathForPath / IdFileName))
 {
     _fileSystem = fileSystem;
 }
コード例 #7
0
ファイル: LocalCache.cs プロジェクト: icmoldovan/BuildXL
        /// <summary>
        ///     Content Stores:
        ///         - <see cref="ServiceClientContentStore"/> if <see cref="LocalCacheConfiguration.ServiceClientContentStoreConfiguration"/>
        ///         - <see cref="FileSystemContentStore"/> otherwise
        ///     Memoization Stores:
        ///         - <see cref="CreateInProcessLocalMemoizationStoreFactory(ILogger, IClock, MemoizationStoreConfiguration)"/>
        /// </summary>
        public static LocalCache CreateUnknownContentStoreInProcMemoizationStoreCache(
            ILogger logger,
            AbsolutePath rootPath,
            MemoizationStoreConfiguration memoizationStoreConfiguration,
            LocalCacheConfiguration localCacheConfiguration,
            ConfigurationModel configurationModel = null,
            IClock clock         = null,
            bool checkLocalFiles = true)
        {
            clock = clock ?? SystemClock.Instance;

            var fileSystem           = new PassThroughFileSystem(logger);
            var contentStoreSettings = new ContentStoreSettings()
            {
                CheckFiles = checkLocalFiles,
            };

            Func <IContentStore> contentStoreFactory = () =>
            {
                if (localCacheConfiguration.ServiceClientContentStoreConfiguration != null)
                {
                    return(new ServiceClientContentStore(logger, fileSystem, localCacheConfiguration.ServiceClientContentStoreConfiguration));
                }
                else
                {
                    return(new FileSystemContentStore(
                               fileSystem,
                               clock,
                               rootPath,
                               configurationModel: configurationModel,
                               settings: contentStoreSettings));
                }
            };

            var memoizationStoreFactory = CreateInProcessLocalMemoizationStoreFactory(logger, clock, memoizationStoreConfiguration);

            return(new LocalCache(fileSystem, contentStoreFactory, memoizationStoreFactory, LoadPersistentCacheGuid(rootPath, fileSystem)));
        }
コード例 #8
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="LocalCache" /> class backed by <see cref="ServiceClientContentStore"/>
 /// </summary>
 public LocalCache(
     ILogger logger,
     string cacheName,
     AbsolutePath rootPath,
     ServiceClientRpcConfiguration rpcConfiguration,
     uint retryIntervalSeconds,
     uint retryCount,
     MemoizationStoreConfiguration memoConfig,
     IClock clock        = null,
     string scenarioName = null)
     : this(
         logger,
         rootPath,
         new PassThroughFileSystem(logger),
         clock ?? SystemClock.Instance,
         new ServiceClientContentStoreConfiguration(cacheName, rpcConfiguration, scenarioName)
 {
     RetryCount = retryCount,
     RetryIntervalSeconds = retryIntervalSeconds,
 },
         memoConfig)
 {
 }
コード例 #9
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="LocalCache" /> class backed by <see cref="TwoContentStore"/> implemented as <see cref="StreamPathContentStore"/>
 /// </summary>
 public LocalCache(
     ILogger logger,
     AbsolutePath rootPathForStream,
     AbsolutePath rootPathForPath,
     MemoizationStoreConfiguration memoConfig,
     ConfigurationModel configurationModelForStream = null,
     ConfigurationModel configurationModelForPath   = null,
     IClock clock         = null,
     bool checkLocalFiles = true,
     bool emptyFileHashShortcutEnabled = false)
     : this(
         logger,
         rootPathForStream,
         rootPathForPath,
         new PassThroughFileSystem(logger),
         clock ?? SystemClock.Instance,
         configurationModelForStream,
         configurationModelForPath,
         memoConfig,
         checkLocalFiles,
         emptyFileHashShortcutEnabled)
 {
 }
コード例 #10
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="LocalCache" /> class backed by <see cref="TwoContentStore"/> implemented as <see cref="StreamPathContentStore"/>
        /// </summary>
        public static LocalCache CreateStreamPathContentStoreInProcMemoizationStoreCache(ILogger logger,
                                                                                         AbsolutePath rootPathForStream,
                                                                                         AbsolutePath rootPathForPath,
                                                                                         MemoizationStoreConfiguration memoConfig,
                                                                                         ConfigurationModel configurationModelForStream = null,
                                                                                         ConfigurationModel configurationModelForPath   = null,
                                                                                         IClock clock         = null,
                                                                                         bool checkLocalFiles = true,
                                                                                         bool emptyFileHashShortcutEnabled = false)
        {
            var fileSystem = new PassThroughFileSystem(logger);

            clock = clock ?? SystemClock.Instance;

            var contentStoreSettings = new ContentStoreSettings()
            {
                CheckFiles = checkLocalFiles, UseEmptyFileHashShortcut = emptyFileHashShortcutEnabled
            };

            Func <IContentStore> contentStoreFactory = () => new StreamPathContentStore(
                () => new FileSystemContentStore(fileSystem, clock, rootPathForStream, configurationModelForStream, settings: contentStoreSettings),
                () => new FileSystemContentStore(fileSystem, clock, rootPathForPath, configurationModelForPath, settings: contentStoreSettings));
            var memoizationStoreFactory = CreateInProcessLocalMemoizationStoreFactory(logger, clock, memoConfig);

            return(new LocalCache(fileSystem, contentStoreFactory, memoizationStoreFactory, LoadPersistentCacheGuid(rootPathForStream, fileSystem)));
        }
コード例 #11
0
        private static Func <IMemoizationStore> CreateInProcessLocalMemoizationStoreFactory(ILogger logger, IClock clock, MemoizationStoreConfiguration config)
        {
            Contract.Requires(config != null);

            if (config is SQLiteMemoizationStoreConfiguration sqliteConfig)
            {
                return(() => new SQLiteMemoizationStore(
                           logger,
                           clock ?? SystemClock.Instance,
                           sqliteConfig));
            }
            else if (config is RocksDbMemoizationStoreConfiguration rocksDbConfig)
            {
                return(() => new RocksDbMemoizationStore(
                           logger,
                           clock ?? SystemClock.Instance,
                           rocksDbConfig));
            }
            else
            {
                throw new NotSupportedException($"Configuration type '{config.GetType()}' for memoization store is unhandled.");
            }
        }
コード例 #12
0
ファイル: LocalCache.cs プロジェクト: icmoldovan/BuildXL
        private static Func <IMemoizationStore> CreateInProcessLocalMemoizationStoreFactory(ILogger logger, IClock clock, MemoizationStoreConfiguration config)
        {
            Contract.Requires(config != null);

            return(() => config.CreateStore(logger, clock ?? SystemClock.Instance));
        }