示例#1
0
文件: Four21.cs 项目: c0d3m0nky/mty
        private void ProcessFirstBackOff(
            Pmta pmta,
            string queue,
            IUnitOfWork unitOfWork,
            IEventRepository eventRepository
            )
        {
            _logger.InfoFormat("First Back Off for {0} on {1}", queue, pmta.Host);

            Event dbLogEvent = eventRepository.Add(new Event()
                                                   {
                                                       EventName = Event.EventNames.FirstBackOff,
                                                       Monitor = Event.Monitors.Four21,
                                                       SeriesId = Guid.NewGuid()
                                                   });

            _mtaAgent.RemoveBackoff(pmta.ToMta(), queue);
            _logger.InfoFormat("Removed Back Off from {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
                                            {
                                                Action = EventAction.Actions.RemoveBackOff,
                                                Pmta = pmta,
                                                PmtaQueue = queue
                                            });

            lock (_locker)
            {
                unitOfWork.SaveChanges();
            }
        }
示例#2
0
文件: Four21.cs 项目: c0d3m0nky/mty
        private void ProcessSecondBackOff(
            Pmta pmta,
            string queue,
            Event lastEvent,
            IUnitOfWork unitOfWork,
            IEventRepository eventRepository
            )
        {
            _logger.InfoFormat("Second Back Off for {0} on {1}", queue, pmta.Host);

            Event dbLogEvent = eventRepository.Add(new Event()
                                                   {
                                                       EventName = Event.EventNames.SecondBackOff,
                                                       Monitor = Event.Monitors.Four21,
                                                       SeriesId = lastEvent.SeriesId
                                                   });

            _mtaAgent.Pause(pmta.ToMta(), queue);
            _logger.InfoFormat("Paused {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
                {
                    Action = EventAction.Actions.MTAPause,
                    Pmta = pmta,
                    PmtaQueue = queue
                });

            _mtaAgent.RemoveBackoff(pmta.ToMta(), queue);
            _logger.InfoFormat("Removed Back Off from {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
                {
                    Action = EventAction.Actions.RemoveBackOff,
                    Pmta = pmta,
                    PmtaQueue = queue
                });

            _mtaAgent.Purge(pmta.ToMta(), queue);
            _logger.InfoFormat("Purged {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
            {
                Action = EventAction.Actions.MTAPurge,
                Pmta = pmta,
                PmtaQueue = queue
            });

            lock (_locker)
            {
                unitOfWork.SaveChanges();
            }
        }
示例#3
0
文件: Four21.cs 项目: c0d3m0nky/mty
        private void ProcessPmta(
            Pmta pmta,
            DateTime nextReset,
            IUnitOfWork unitOfWork,
            IJobRepository jobRepository,
            IEventRepository eventRepository,
            IDeliveryGroupRepository deliveryGroupRepository
            )
        {

            foreach (var queue in _mtaAgent.GetVmtasIn421BackoffMode(pmta.ToMta()))
            {
                Event lastEvent = null;

                lock (_locker)
                {
                    lastEvent = Event.GetLastQueueEvent(eventRepository, Event.Monitors.Four21, pmta, queue);
                }

                if (lastEvent != null && lastEvent.DateCreated.AddHours(1) >= DateTime.Now)
                {
                    switch (lastEvent.EventName)
                    {
                        case Event.EventNames.FirstBackOff:
                            ProcessSecondBackOff(pmta, queue, lastEvent, unitOfWork, eventRepository);
                            break;
                        case Event.EventNames.SecondBackOff:
                        case Event.EventNames.SecondBackOffResume:
                            ProcessThirdBackOff(pmta, queue, lastEvent, unitOfWork, eventRepository);
                            break;
                        case Event.EventNames.ThirdBackOff:
                            ProcessFourthBackOff(pmta, queue, lastEvent, nextReset, unitOfWork, jobRepository, eventRepository, deliveryGroupRepository);
                            break;
                        default:
                            ProcessFirstBackOff(pmta, queue, unitOfWork, eventRepository);
                            break;
                    }
                }
                else
                {
                    ProcessFirstBackOff(pmta, queue, unitOfWork, eventRepository);
                }
            }

            IEnumerable<Event> events = null;

            lock (_locker)
            {
                events = Event.Get421QueueResumeEvents(eventRepository).ToArray();
            }

            events.ToList().ForEach(e => ResumeSecondBackOff(e, unitOfWork, jobRepository, eventRepository, deliveryGroupRepository));

            unitOfWork.SaveChanges();

        }
示例#4
0
文件: Four21.cs 项目: c0d3m0nky/mty
        private void ProcessFourthBackOff(
            Pmta pmta,
            string queue,
            Event lastEvent,
            DateTime nextReset,
            IUnitOfWork unitOfWork,
            IJobRepository jobRepository,
            IEventRepository eventRepository,
            IDeliveryGroupRepository deliveryGroupRepository
            )
        {
            _logger.InfoFormat("Fourth Back Off for {0} on {1}", queue, pmta.Host);

            var dbLogEvent = eventRepository.Add(new Event()
            {
                EventName = Event.EventNames.FourthBackOff,
                Monitor = Event.Monitors.Four21,
                SeriesId = lastEvent.SeriesId
            });

            _mtaAgent.Pause(pmta.ToMta(), queue);
            _logger.InfoFormat("Paused {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
                {
                    Action = EventAction.Actions.MTAPause,
                    Pmta = pmta,
                    PmtaQueue = queue
                });

            _mtaAgent.RemoveBackoff(pmta.ToMta(), queue);
            _logger.InfoFormat("Removed Back Off from {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
                {
                    Action = EventAction.Actions.RemoveBackOff,
                    Pmta = pmta,
                    PmtaQueue = queue
                });

            _mtaAgent.Purge(pmta.ToMta(), queue);
            _logger.InfoFormat("Purged {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
            {
                Action = EventAction.Actions.MTAPurge,
                Pmta = pmta,
                PmtaQueue = queue
            });

            lock (_locker)
            {
                var deliveryGroup = DeliveryGroup.GetByVmta(pmta, queue, deliveryGroupRepository);

                if (deliveryGroup != null)
                {
                    DeliveryGroup.CancelHotmailJobsByDeliveryGroup(jobRepository, _logger, deliveryGroup, nextReset, dbLogEvent);
                }

                unitOfWork.SaveChanges();
            }

            _emailNotification.SendEvent(dbLogEvent);

        }
示例#5
0
文件: Four21.cs 项目: c0d3m0nky/mty
        private void ResetFourthBackoff(
            Pmta pmta,
            Event currentEvent,
            Event resetEvent,
            DateTime resetTime,
            IDeliveryGroupRepository deliveryGroupRepository,
            IJobRepository jobRepository
            )
        {
            IEnumerable<string> queues;

            lock (_locker)
            {
                queues = resetEvent.EventActions.Where(ed => ed.PmtaId == pmta.PmtaId && ed.PmtaQueue != null).Select(ed => ed.PmtaQueue).Distinct().ToArray();
            }

            foreach (var queue in queues)
            {
                if (!_mtaAgent.IsQueueActive(pmta.ToMta(), queue))
                {
                    _mtaAgent.Purge(pmta.ToMta(), queue);
                    _logger.InfoFormat("Purged {0} on {1}", queue, pmta.Host);

                    lock (_locker)
                    {
                        currentEvent.EventActions.Add(new EventAction()
                                                    {
                                                        Action = EventAction.Actions.MTAPurge,
                                                        Pmta = pmta,
                                                        PmtaQueue = queue
                                                    });

                        var deliveryGroup = DeliveryGroup.GetByVmta(pmta, queue, deliveryGroupRepository);

                        if (deliveryGroup != null)
                        {
                            DeliveryGroup.CancelHotmailJobsByDeliveryGroup(jobRepository, _logger, deliveryGroup, resetTime, currentEvent);
                        }
                    }

                    _mtaAgent.UnPause(pmta.ToMta(), queue);
                    _logger.InfoFormat("Resumed {0} on {1}", queue, pmta.Host);

                    lock (_locker)
                    {
                        currentEvent.EventActions.Add(new EventAction()
                                                    {
                                                        Action = EventAction.Actions.ResumedQueue,
                                                        Pmta = pmta,
                                                        PmtaQueue = queue
                                                    });
                    }
                }
            }
        }