Beispiel #1
0
        /// <inheritdoc />
        public void NotifyMasterModeChanged(Guid taskProcessorId, bool isMaster, MasterModeChangeReason reason)
        {
            Trace.WriteLine("ENTER: Notifying task processor '{0}' master mode changed to {1} with reason {2} ...".FormatInvariant(taskProcessorId, isMaster, reason));

            MasterModeChangeEventArgs.ValidateArguments(isMaster, reason);

            this.provider.PublishMessage(RedisTaskProcessorChannels.MasterModeChangedChannel, RedisConverter.ToString(taskProcessorId, isMaster, reason));

            Trace.WriteLine("EXIT: Task processor '{0}' master mode changed to {1} with reason {2} notified.".FormatInvariant(taskProcessorId, isMaster, reason));
        }
        public void NotifyMasterModeChanged(Guid taskProcessorId, bool isMaster, MasterModeChangeReason reason)
        {
            this.RecordMethodCall(taskProcessorId, isMaster, reason);

            MasterModeChangeEventArgs.ValidateArguments(isMaster, reason);

            if ((this.MasterModeChanged != null) && this.SubscribedChannels.Contains(MessageBusChannel.MasterModeChanged))
            {
                this.MasterModeChanged(this, new MasterModeChangeEventArgs(taskProcessorId, isMaster, reason));
            }
        }
Beispiel #3
0
        private void OnMasterModeChanged(object sender, MasterModeChangeEventArgs e)
        {
            TaskProcessorViewModel taskProcessorViewModel = this.taskProcessors.FirstOrDefault(p => p.TaskProcessorId == e.TaskProcessorId);

            if (taskProcessorViewModel != null)
            {
                App.Current.Dispatcher.InvokeAsync(() =>
                {
                    taskProcessorViewModel.IsMaster = e.IsMaster;
                });
            }
        }
        public virtual void RaiseMasterModeChanged()
        {
            Guid taskProcessorId = Guid.NewGuid();

            this.Receiver.SubscribeForChannels(MessageBusChannel.MasterModeChanged);

            MasterModeChangeEventArgs args = Helpers.WaitForEvent <MasterModeChangeEventArgs>(
                this.Timeout,
                handler => this.Receiver.MasterModeChanged += handler,
                () => this.Sender.NotifyMasterModeChanged(taskProcessorId, true, MasterModeChangeReason.Start));

            Assert.AreEqual(taskProcessorId, args.TaskProcessorId);
            Assert.IsTrue(args.IsMaster);
            Assert.AreEqual(MasterModeChangeReason.Start, args.Reason);
        }
        public virtual void RaiseMasterModeChangeRequestedAfterUnsubscribeFromAllChannelsExcept()
        {
            Guid taskProcessorId = Guid.NewGuid();

            this.Receiver.SubscribeForChannels(MessageBusChannel.MasterModeChangeRequest);
            this.Receiver.UnsubscribeFromAllChannelsExcept(MessageBusChannel.MasterModeChangeRequest);

            MasterModeChangeEventArgs args = Helpers.WaitForEvent <MasterModeChangeEventArgs>(
                this.Timeout,
                handler => this.Receiver.MasterModeChangeRequested += handler,
                () => this.Sender.NotifyMasterModeChangeRequest(taskProcessorId, true));

            Assert.AreEqual(taskProcessorId, args.TaskProcessorId);
            Assert.IsTrue(args.IsMaster);
            Assert.AreEqual(MasterModeChangeReason.Explicit, args.Reason);
        }