Exemplo n.º 1
0
 /// <inheritdoc />
 public void NotifyMasterModeChanged(Guid taskProcessorId, bool isMaster, MasterModeChangeReason reason)
 {
     foreach (ITaskProcessorMessageBusSender mb in this)
     {
         mb.NotifyMasterModeChanged(taskProcessorId, isMaster, reason);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MasterModeChangeEventArgs"/> class.
        /// </summary>
        /// <param name="taskProcessorId">The ID of the task processor who has become master or a slave.</param>
        /// <param name="isMaster">Whether the task processor has become master, or slave.</param>
        /// <param name="reason">The reason for the change.</param>
        public MasterModeChangeEventArgs(Guid taskProcessorId, bool isMaster, MasterModeChangeReason reason)
            : base(taskProcessorId)
        {
            MasterModeChangeEventArgs.ValidateArguments(isMaster, reason);

            this.isMaster = isMaster;
            this.reason   = reason;
        }
Exemplo n.º 3
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));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Validates arguments for the constructor.
        /// </summary>
        /// <param name="isMaster">Whether the task processor has become master, or slave.</param>
        /// <param name="reason">The reason for the change.</param>
        public static void ValidateArguments(bool isMaster, MasterModeChangeReason reason)
        {
            switch (reason)
            {
            case MasterModeChangeReason.None:
                throw new ArgumentOutOfRangeException("reason", reason, "Value must not be {0}.".FormatInvariant(reason));

            case MasterModeChangeReason.Start:
                if (!isMaster)
                {
                    throw new ArgumentOutOfRangeException("reason", reason, "Value must not be {0} when is master is {1}.".FormatInvariant(reason, isMaster));
                }

                break;
            }
        }
Exemplo n.º 6
0
 void ITaskProcessorMessageBusSender.NotifyMasterModeChanged(Guid taskProcessorId, bool isMaster, MasterModeChangeReason reason)
 {
     /* Do nothing. */
 }