Exemplo n.º 1
0
 private bool[] GetRemovesResults(NodeEndpoint endpoint,
     ExtendedRemoveRequest[] removeRequests,
     int backupIndex)
 {
     try
     {
         using (var client = pool.Create(endpoint))
         {
             return client.Remove(topology.Version, removeRequests);
         }
     }
     catch (SeeOtherException soe)
     {
         return GetRemovesResults(soe.Endpoint, removeRequests, backupIndex);
     }
     catch (TopologyVersionDoesNotMatchException)
     {
         RefreshTopology();
         return RemoveInternal(removeRequests, backupIndex);
     }
     catch (Exception)
     {
         try
         {
             return RemoveInternal(removeRequests, backupIndex + 1);
         }
         catch (NoMoreBackupsException)
         {
         }
         throw;
     }
 }
 public void WillReplicateToOtherSystems()
 {
     node.Stub(x => x.IsSegmentOwned(0)).Return(true);
     var request = new ExtendedRemoveRequest()
     {
         Key = "test",
         SpecificVersion = version,
         Segment = 0,
     };
     distributedHashTableStorage.Remove(topologyVersion, request);
     node.AssertWasCalled(x => x.SendToAllOtherBackups(0, request));
 }
 public void WillReplicateToOwnerWhenFailedOverToAnotherNode()
 {
     node.Stub(x => x.IsSegmentOwned(0)).Return(false);
     var request = new ExtendedRemoveRequest()
     {
         Key = "test",
         SpecificVersion = version,
         Segment = 0,
     };
     distributedHashTableStorage.Remove(topologyVersion, request);
     node.AssertWasCalled(x => x.SendToOwner(0, request));
 }
        public void WillRemoveReturnedRemovalFromStorage()
        {
            replication.Stub(x => x.AssignAllEmptySegments(Arg<NodeEndpoint>.Is.Anything, Arg.Is(ReplicationType.Ownership), Arg<int[]>.Is.Anything))
                .Return(new[] { 0 });
            var request = new ExtendedRemoveRequest
            {
                Key = "a",
            };
            replication.Stub(x => x.ReplicateNextPage(Arg<NodeEndpoint>.Is.Anything, Arg.Is(ReplicationType.Ownership), Arg<int>.Is.Anything))
                .Return(new ReplicationResult
                {
                    PutRequests = new ExtendedPutRequest[0],
                    RemoveRequests = new[] { request },
                    Done = true
                });
            var success = command.Execute();
            Assert.True(success);

            storage.AssertWasCalled(x => x.Remove(topologyVersion, request));
        }