public byte[] Serialize(IExtendedRequest[] requests) { using (var stream = new MemoryStream()) { new NetDataContractSerializer().Serialize(stream,requests); return stream.ToArray(); } }
private void HandleReplication( IExtendedRequest[] valuesToSend) { // if this is the replication request, this is a replicated value, // and we don't need to do anything with replication, we only need // to check the first value, because all requests have the same purpose if (valuesToSend[0].IsReplicationRequest || valuesToSend[0].IsLocal) return; if (distributedHashTableNode.IsSegmentOwned(valuesToSend[0].Segment) == false) { // if this got to us because of fail over, and we need to replicate to the real owner // and to any other backups distributedHashTableNode.SendToOwner(valuesToSend[0].Segment, valuesToSend); } distributedHashTableNode.SendToAllOtherBackups(valuesToSend[0].Segment, valuesToSend); }
public void SendToOwner(int segment, IExtendedRequest[] requests) { var ownerSegment = Topology.GetSegment(segment); if (ownerSegment.AssignedEndpoint == null) return; log.DebugFormat("Sending {0} requests to owner {1}", requests.Length, ownerSegment.AssignedEndpoint.Async); queueManager.Send(ownerSegment.AssignedEndpoint.Async, new MessagePayload { Data = messageSerializer.Serialize(requests), }); }
public void SendToAllOtherBackups(int segment, IExtendedRequest[] requests) { var ownerSegment = Topology.GetSegment(segment); foreach (var otherBackup in ownerSegment .PendingBackups .Concat(ownerSegment.Backups) .Append(ownerSegment.AssignedEndpoint) .Where(x => x != endpoint)) { if (otherBackup == null) continue; log.DebugFormat("Sending {0} requests to backup {1}", requests.Length, ownerSegment.AssignedEndpoint.Async); queueManager.Send(otherBackup.Async, new MessagePayload { Data = messageSerializer.Serialize(requests), }); } }