private PutResult[] GetPutsResults(NodeEndpoint endpoint, ExtendedPutRequest[] putRequests, int backupIndex) { try { using (var client = pool.Create(endpoint)) { return client.Put(topology.Version, putRequests); } } catch (SeeOtherException soe) { return GetPutsResults(soe.Endpoint, putRequests, backupIndex); } catch (TopologyVersionDoesNotMatchException) { RefreshTopology(); return PutInternal(putRequests, backupIndex); } catch (Exception) { try { return PutInternal(putRequests, backupIndex + 1); } catch (NoMoreBackupsException) { } throw; } }
public void WillReplicateToOwnerWhenFailedOverToAnotherNode() { node.Stub(x => x.IsSegmentOwned(0)).Return(false); var request = new ExtendedPutRequest { Key = "test", Bytes = new byte[] { 1, 2, 4 }, Segment = 0, }; distributedHashTableStorage.Put(topologyVersion, request); node.AssertWasCalled(x => x.SendToOwner(0, request)); }
public void WillRepeatReplicationUntilGetDone() { replication.Stub(x => x.AssignAllEmptySegments(Arg<NodeEndpoint>.Is.Anything, Arg.Is(ReplicationType.Ownership), Arg<int[]>.Is.Anything)) .Return(new[] { 0 }); var request = new ExtendedPutRequest { Bytes = new byte[] { 1 }, Key = "a", }; for (int i = 0; i < 5; i++) { replication.Stub(x => x.ReplicateNextPage(Arg<NodeEndpoint>.Is.Anything, Arg.Is(ReplicationType.Ownership), Arg<int>.Is.Anything)) .Repeat.Once() .Return(new ReplicationResult { PutRequests = new[] {request,}, RemoveRequests = new ExtendedRemoveRequest[0], Done = false }); } replication.Stub(x => x.ReplicateNextPage(Arg<NodeEndpoint>.Is.Anything, Arg.Is(ReplicationType.Ownership), Arg<int>.Is.Anything)) .Repeat.Once() .Return(new ReplicationResult { PutRequests = new[] { request, }, RemoveRequests = new ExtendedRemoveRequest[0], Done = true }); var success = command.Execute(); Assert.True(success); storage.AssertWasCalled(x => x.Put(topologyVersion, request), o => o.Repeat.Times(6)); }
public void WillReplicateToOtherSystems() { node.Stub(x => x.IsSegmentOwned(0)).Return(true); var request = new ExtendedPutRequest { Key = "test", Bytes = new byte[] { 1, 2, 4 }, Segment = 0, }; distributedHashTableStorage.Put(topologyVersion, request); node.AssertWasCalled(x=>x.SendToAllOtherBackups(0, request)); }
public void WillPutReturnedItemsIntoStorage() { replication.Stub(x => x.AssignAllEmptySegments(Arg<NodeEndpoint>.Is.Anything, Arg.Is(ReplicationType.Ownership), Arg<int[]>.Is.Anything)) .Return(new[] { 0 }); var request = new ExtendedPutRequest { Bytes = new byte[]{1}, Key = "a", }; replication.Stub(x => x.ReplicateNextPage(Arg<NodeEndpoint>.Is.Anything, Arg.Is(ReplicationType.Ownership), Arg<int>.Is.Anything)) .Return(new ReplicationResult { PutRequests = new[]{ request, }, RemoveRequests = new ExtendedRemoveRequest[0], Done = true }); var success = command.Execute(); Assert.True(success); storage.AssertWasCalled(x => x.Put(topologyVersion, request)); }