Exemplo n.º 1
0
        private void TraceScaleoutMessages(ulong id, ScaleoutMessage scaleoutMessage)
        {
            if (!_trace.Switch.ShouldTrace(TraceEventType.Verbose))
            {
                return;
            }

            foreach (var message in scaleoutMessage.Messages)
            {
                _trace.TraceVerbose("Received message {0}: '{1}' over ScaleoutMessageBus", id, message.GetString());
            }
        }
Exemplo n.º 2
0
        public ScaleoutMapping(ulong id, ScaleoutMessage message, IList <LocalEventKeyInfo> localKeyInfo)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            if (localKeyInfo == null)
            {
                throw new ArgumentNullException("localKeyInfo");
            }

            Id                 = id;
            LocalKeyInfo       = localKeyInfo;
            ServerCreationTime = message.ServerCreationTime;
        }
Exemplo n.º 3
0
        private void OnReceivedCore(int streamIndex, ulong id, ScaleoutMessage scaleoutMessage)
        {
            Counters.ScaleoutMessageBusMessagesReceivedPerSec.IncrementBy(scaleoutMessage.Messages.Count);

            _trace.TraceInformation("OnReceived({0}, {1}, {2})", streamIndex, id, scaleoutMessage.Messages.Count);
            TraceScaleoutMessages(id, scaleoutMessage);

            var localMapping = new LocalEventKeyInfo[scaleoutMessage.Messages.Count];
            var keys         = new HashSet <string>();

            for (var i = 0; i < scaleoutMessage.Messages.Count; ++i)
            {
                Message message = scaleoutMessage.Messages[i];

                // Remember where this message came from
                message.MappingId   = id;
                message.StreamIndex = streamIndex;

                keys.Add(message.Key);
                ulong localId = Save(message);

                _trace.TraceVerbose("Message id: {0}, stream : {1}, eventKey: '{2}' saved with local id: {3}",
                                    id, streamIndex, message.Key, localId);

                MessageStore <Message> messageStore = Topics[message.Key].Store;

                localMapping[i] = new LocalEventKeyInfo(message.Key, localId, messageStore);
            }

            // Get the stream for this payload
            ScaleoutMappingStore store = StreamManager.Streams[streamIndex];

            // Publish only after we've setup the mapping fully
            store.Add(id, scaleoutMessage, localMapping);

            if (_trace.Switch.ShouldTrace(TraceEventType.Verbose))
            {
                _trace.TraceVerbose("Scheduling eventkeys: {0}", string.Join(",", keys));
            }

            // Schedule after we're done
            foreach (var eventKey in keys)
            {
                ScheduleEvent(eventKey);
            }
        }
Exemplo n.º 4
0
        public static ScaleoutMessage FromBytes(byte[] data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            using (var stream = new MemoryStream(data))
            {
                var binaryReader = new BinaryReader(stream);
                var message      = new ScaleoutMessage();
                message.Messages = new List <Message>();
                int count = binaryReader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    message.Messages.Add(Message.ReadFrom(stream));
                }
                message.ServerCreationTime = new DateTime(binaryReader.ReadInt64());

                return(message);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Invoked when a payload is received from the backplane. There should only be one active call at any time.
 /// </summary>
 /// <param name="streamIndex">id of the stream.</param>
 /// <param name="id">id of the payload within that stream.</param>
 /// <param name="message">The scaleout message.</param>
 /// <returns></returns>
 protected virtual void OnReceived(int streamIndex, ulong id, ScaleoutMessage message)
 {
     StreamManager.OnReceived(streamIndex, id, message);
 }
Exemplo n.º 6
0
 public ScaleoutMapping(ulong id, ScaleoutMessage message)
     : this(id, message, ListHelper <LocalEventKeyInfo> .Empty)
 {
 }