Exemplo n.º 1
0
        public void CanRemoveItem()
        {
            using (var storageProxy = new DistributedHashTableStorageClient(storageHost.Endpoint))
            {
                var masterProxy = new DistributedHashTableMasterClient(masterUri);
                var topology = masterProxy.GetTopology();
                var results = storageProxy.Put(topology.Version, new ExtendedPutRequest
                {
                    Bytes = new byte[] { 1, 2, 3, 4 },
                    Key = "test",
                    Segment = 1,
                });
                Assert.False(results[0].ConflictExists);

                var removed = storageProxy.Remove(topology.Version, new ExtendedRemoveRequest
                {
                    Key = "test",
                    SpecificVersion = results[0].Version,
                    Segment = 1
                });
                Assert.True(removed[0]);

                var values = storageProxy.Get(topology.Version, new ExtendedGetRequest
                {
                    Key = "test",
                    Segment = 1
                });

                Assert.Equal(0, values[0].Length);
            }
        }
Exemplo n.º 2
0
        public void CanReplicateSegmentWithDataWhileRemovingItems()
        {
            using (var storageProxy = new DistributedHashTableStorageClient(storageHost.Endpoint))
            {
                var topology = new DistributedHashTableMasterClient(masterUri).GetTopology();
                storageProxy.Put(topology.Version, new ExtendedPutRequest
                {
                    Bytes = new byte[] { 1, 2, 3 },
                    Key = "test",
                    Segment = 1,
                });

                var result = storageProxy.ReplicateNextPage(NodeEndpoint.ForTest(13), ReplicationType.Ownership, 1);
                Assert.Equal("test", result.PutRequests[0].Key);

                storageProxy.Remove(topology.Version, new ExtendedRemoveRequest()
                {
                    Key = "test",
                    Segment = 1,
                    SpecificVersion = result.PutRequests[0].ReplicationVersion
                });

                result = storageProxy.ReplicateNextPage(NodeEndpoint.ForTest(13), ReplicationType.Ownership, 1);
                Assert.Equal("test", result.RemoveRequests[0].Key);
            }
        }