コード例 #1
0
        public Task SmallBlobsInRedisAfterCopy()
        {
            ConfigureWithOneMasterAndSmallBlobs();

            return(RunTestAsync(
                       new Context(Logger),
                       2,
                       async context =>
            {
                var sessions = context.Sessions;

                var session0 = context.GetSession(0);
                var redisStore0 = context.GetRedisGlobalStore(0);

                var session1 = context.GetSession(1);
                var redisStore1 = context.GetRedisGlobalStore(1);

                var putResult = await session0.PutRandomAsync(context, HashType.Vso0, false, 10, CancellationToken.None).ShouldBeSuccess();
                Assert.Equal(1, redisStore0.Counters[GlobalStoreCounters.PutBlob].Value);

                // Simulate that the blob has expired.
                var blobKey = RedisBlobAdapter.GetBlobKey(putResult.ContentHash);
                var deleted = await PrimaryGlobalStoreDatabase.KeyDeleteAsync($"{redisStore0.Configuration.Keyspace}{blobKey}");
                Assert.True(deleted, $"Could not delete {blobKey} because it does not exist.");

                var openStreamResult = await session1.OpenStreamAsync(context, putResult.ContentHash, CancellationToken.None).ShouldBeSuccess();
                var counters = redisStore1.GetBlobAdapter(putResult.ContentHash).GetCounters().ToDictionaryIntegral();
                Assert.Equal(0, counters["DownloadedBlobs.Count"]);
                Assert.Equal(1, redisStore1.Counters[GlobalStoreCounters.PutBlob].Value);
            }));
        }
コード例 #2
0
        public Task SmallBlobsInRedisAfterCopy()
        {
            return(RunTestAsync(
                       new Context(Logger),
                       2,
                       async context =>
            {
                var sessions = context.Sessions;

                var session0 = context.GetDistributedSession(0);
                var redisStore0 = (RedisContentLocationStore)session0.ContentLocationStore;

                var session1 = context.GetDistributedSession(1);
                var redisStore1 = (RedisContentLocationStore)session1.ContentLocationStore;

                var putResult = await session0.PutRandomAsync(context, HashType.Vso0, false, 10, CancellationToken.None).ShouldBeSuccess();
                var counters0 = redisStore0.GetCounters(context).ToDictionaryIntegral();
                Assert.Equal(1, counters0["RedisContentLocationStore.BlobAdapter.PutBlob.Count"]);

                // Simulate that the blob has expired.
                var blobKey = RedisBlobAdapter.GetBlobKey(putResult.ContentHash);
                var deleted = await _localDatabases[context.Context.Id].KeyDeleteAsync($"{RedisContentLocationStoreFactory.DefaultKeySpace}{blobKey}");
                Assert.True(deleted, $"Could not delete {blobKey} because it does not exist.");

                var openStreamResult = await session1.OpenStreamAsync(context, putResult.ContentHash, CancellationToken.None).ShouldBeSuccess();
                var counters1 = redisStore1.GetCounters(context).ToDictionaryIntegral();
                Assert.Equal(0, counters1["RedisContentLocationStore.BlobAdapter.DownloadedBlobs.Count"]);
                Assert.Equal(1, counters1["RedisContentLocationStore.BlobAdapter.PutBlob.Count"]);
            }));
        }
コード例 #3
0
ファイル: RedisGlobalStore.cs プロジェクト: microsoft/BuildXL
        /// <nodoc />
        internal RedisGlobalStore(
            IClock clock,
            RedisContentLocationStoreConfiguration configuration,
            RedisDatabaseAdapter primaryRedisDb,
            RedisDatabaseAdapter secondaryRedisDb,
            RedisDatabaseAdapter primaryRedisBlobDb,
            RedisDatabaseAdapter secondaryRedisBlobDb,
            IMasterElectionMechanism masterElectionMechanism)
        {
            Contract.Requires(configuration.CentralStore != null);

            _clock = clock;
            Configuration = configuration;
            RaidedRedis = new RaidedRedisDatabase(Tracer, primaryRedisDb, secondaryRedisDb);

            var checkpointKeyBase = configuration.CentralStore.CentralStateKeyBase;
            _clusterStateKey = new ReplicatedRedisHashKey(checkpointKeyBase + ".ClusterState", this, _clock, RaidedRedis);

            MemoizationAdapter = new RedisMemoizationAdapter(RaidedRedis, configuration.Memoization);

            PrimaryBlobAdapter = new RedisBlobAdapter(primaryRedisBlobDb, _clock, Configuration);
            SecondaryBlobAdapter = new RedisBlobAdapter(secondaryRedisBlobDb, _clock, Configuration);

            _masterElectionMechanism = masterElectionMechanism;
        }
コード例 #4
0
        /// <nodoc />
        public RedisGlobalStore(IClock clock, RedisContentLocationStoreConfiguration configuration, MachineLocation localMachineLocation, RedisDatabaseAdapter primaryRedisDb, RedisDatabaseAdapter secondaryRedisDb)
        {
            Contract.Requires(configuration.CentralStore != null);

            _clock         = clock;
            _configuration = configuration;
            _raidedRedis   = new RaidedRedisDatabase(Tracer, primaryRedisDb, secondaryRedisDb);
            var checkpointKeyBase = configuration.CentralStore.CentralStateKeyBase;

            _checkpointsKey      = new ReplicatedRedisHashKey(configuration.GetCheckpointPrefix() + ".Checkpoints", this, _clock, _raidedRedis);
            _masterLeaseKey      = new ReplicatedRedisHashKey(checkpointKeyBase + ".MasterLease", this, _clock, _raidedRedis);
            _clusterStateKey     = new ReplicatedRedisHashKey(checkpointKeyBase + ".ClusterState", this, _clock, _raidedRedis);
            LocalMachineLocation = localMachineLocation;

            _blobAdapter = new RedisBlobAdapter(_raidedRedis.PrimaryRedisDb, TimeSpan.FromMinutes(_configuration.BlobExpiryTimeMinutes), _configuration.MaxBlobCapacity, _clock, Tracer);
        }
コード例 #5
0
        /// <nodoc />
        internal RedisGlobalStore(
            IClock clock,
            RedisContentLocationStoreConfiguration configuration,
            RedisDatabaseAdapter primaryRedisDb,
            RedisDatabaseAdapter secondaryRedisDb,
            RedisDatabaseAdapter primaryRedisBlobDb,
            RedisDatabaseAdapter secondaryRedisBlobDb)
        {
            Contract.Requires(configuration.CentralStore != null);

            _clock        = clock;
            Configuration = configuration;
            RaidedRedis   = new RaidedRedisDatabase(Tracer, primaryRedisDb, secondaryRedisDb);
            var checkpointKeyBase = configuration.CentralStore.CentralStateKeyBase;

            _checkpointsKey  = new ReplicatedRedisHashKey(configuration.GetCheckpointPrefix() + ".Checkpoints", this, _clock, RaidedRedis);
            _masterLeaseKey  = new ReplicatedRedisHashKey(checkpointKeyBase + ".MasterLease", this, _clock, RaidedRedis);
            _clusterStateKey = new ReplicatedRedisHashKey(checkpointKeyBase + ".ClusterState", this, _clock, RaidedRedis);

            PrimaryBlobAdapter   = new RedisBlobAdapter(primaryRedisBlobDb, _clock, Configuration);
            SecondaryBlobAdapter = new RedisBlobAdapter(secondaryRedisBlobDb, _clock, Configuration);
        }