Beispiel #1
0
        public Task TestUpdateRingAndGetLocations()
        {
            return(RunTestAsync(async(context, store, directory) =>
            {
                ClusterState clusterState = ClusterState.CreateForTest();
                for (int i = 0; i <= 10; i++)
                {
                    var machineId = new MachineId(i);
                    var machineLocation = new MachineLocation(i.ToString());
                    clusterState.AddMachine(machineId, machineLocation);
                }

                var contentHashes = new List <ContentHashWithPath>();

                var contentHash1 = new ContentHashWithPath(new ContentHash("MD5:72F6F256239CC69B6FE9AF1C7489CFD1"), directory.Path / "hash1");
                var contentHash2 = new ContentHashWithPath(new ContentHash("MD5:61C4F184221AD54A2FA4A92A6137AA42"), directory.Path / "hash2");
                contentHashes.Add(contentHash1);
                contentHashes.Add(contentHash2);

                var result = await store.UpdateRingAsync(context, clusterState).ShouldBeSuccess();
                var locations = store.GetBulkLocations(context, contentHashes).ShouldBeSuccess();

                locations.Count.Should().Be(2);

                locations.ContentHashesInfo[0].ContentHash.Serialize().Should().Be("MD5:72F6F256239CC69B6FE9AF1C7489CFD1");
                locations.ContentHashesInfo[0].Locations[0].ToString().Should().Be("6");
                locations.ContentHashesInfo[0].Locations[1].ToString().Should().Be("4");
                locations.ContentHashesInfo[0].Locations[2].ToString().Should().Be("5");

                locations.ContentHashesInfo[1].ContentHash.Serialize().Should().Be("MD5:61C4F184221AD54A2FA4A92A6137AA42");
                locations.ContentHashesInfo[1].Locations[0].ToString().Should().Be("10");
                locations.ContentHashesInfo[1].Locations[1].ToString().Should().Be("1");
                locations.ContentHashesInfo[1].Locations[2].ToString().Should().Be("3");
            }));
        }
Beispiel #2
0
        /// <nodoc />
        public RocksDbContentPlacementPredictionStore(string storeLocation, bool clean)
        {
            _storeLocation = new AbsolutePath(storeLocation);
            var dbLocation = _storeLocation / "db";
            var config     = new RocksDbContentLocationDatabaseConfiguration(dbLocation)
            {
                StoreClusterState         = true,
                CleanOnInitialize         = clean,
                GarbageCollectionInterval = Timeout.InfiniteTimeSpan,
                LogsKeepLongTerm          = false,
            };

            _clusterState = ClusterState.CreateForTest();

            _database = new RocksDbContentLocationDatabase(SystemClock.Instance, config, () => new List <MachineId>());
        }
Beispiel #3
0
        public Task TestPutToColdStorageWithRemoteLocations()
        {
            return(RunTestAsync(async(context, store, directory) =>
            {
                ClusterState clusterState = ClusterState.CreateForTest();
                for (int i = 0; i <= 10; i++)
                {
                    clusterState.AddMachine(new MachineId(i), new MachineLocation(i.ToString()));
                }
                var result = await store.UpdateRingAsync(context, clusterState).ShouldBeSuccess();

                // Create file to put
                var originalPath = directory.Path / "original.txt";
                var fileContents = GetRandomFileContents();

                FileSystem.WriteAllText(originalPath, fileContents);

                var contentHasher = HashInfoLookup.GetContentHasher(HashType.MD5);
                var contentHash = contentHasher.GetContentHash(Encoding.UTF8.GetBytes(fileContents));

                await store.PutFileAsync(context, contentHash, new DisposableFile(context, FileSystem, originalPath), context.Token).ShouldBeSuccess();
            }));
        }