Esempio n. 1
0
 // Token: 0x06000018 RID: 24 RVA: 0x00002A27 File Offset: 0x00000C27
 private void UpdateDeliveryThreadCounters(DateTime now)
 {
     if (now - this.lastDeliveryScan > TimeSpan.FromSeconds(5.0))
     {
         StoreDriverDeliveryDiagnostics.UpdateDeliveryThreadCounters();
     }
 }
Esempio n. 2
0
 public void LogEvent(ExEventLog.EventTuple eventTuple, Exception exception)
 {
     StoreDriverDeliveryDiagnostics.LogEvent(eventTuple, exception.Message, new object[]
     {
         exception
     });
 }
Esempio n. 3
0
 // Token: 0x06000017 RID: 23 RVA: 0x000029BC File Offset: 0x00000BBC
 private void DetectAndHandleDeliveryHang(DateTime now)
 {
     if (now - this.lastDeliveryScan > Components.Configuration.AppConfig.RemoteDelivery.StoreDriverDeliveryHangDetectionInterval)
     {
         string message;
         if (StoreDriverDeliveryDiagnostics.DetectDeliveryHang(out message) && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MailboxTransport.DeliveryHangRecovery.Enabled)
         {
             throw new BackgroundThreadDelivery.DeliveryHangDetectedException(message);
         }
         this.lastDeliveryScan = now;
     }
 }
Esempio n. 4
0
        private void CheckArbitrationMailboxCapacity(MailboxSession session, OrganizationId orgId)
        {
            if (!VariantConfiguration.InvariantNoFlightingSnapshot.MailboxTransport.CheckArbitrationMailboxCapacity.Enabled || session == null)
            {
                return;
            }
            object obj  = session.Mailbox.TryGetProperty(MailboxSchema.QuotaProhibitReceive);
            object obj2 = session.Mailbox.TryGetProperty(MailboxSchema.QuotaUsedExtended);

            if (obj is PropertyError || obj2 is PropertyError)
            {
                ApprovalProcessingAgent.diag.TraceDebug <Mailbox, object, object>(0L, "Property error getting quota/usage of {0}. quota={1}, used={2}", session.Mailbox, obj, obj2);
                return;
            }
            int num = (int)obj;

            if (num < 0)
            {
                return;
            }
            ulong num2 = (ulong)((long)num * 1024L);
            ulong num3 = (ulong)((long)obj2);

            if (0.7 * num2 < num3)
            {
                bool flag = false;
                lock (ApprovalProcessingAgent.organizationsAlertedForQuotaSyncLock)
                {
                    if (ApprovalProcessingAgent.organizationsAlertedForQuota == null || ApprovalProcessingAgent.organizationsAlertedForQuotLastRefreshed.Add(ApprovalProcessingAgent.organizationsAlertedForQuotaRefreshPeriod) < ExDateTime.UtcNow || ApprovalProcessingAgent.organizationsAlertedForQuota.Count > 500)
                    {
                        ApprovalProcessingAgent.organizationsAlertedForQuota             = new HashSet <OrganizationId>();
                        ApprovalProcessingAgent.organizationsAlertedForQuotLastRefreshed = ExDateTime.UtcNow;
                    }
                    flag = ApprovalProcessingAgent.organizationsAlertedForQuota.Add(orgId);
                }
                if (flag)
                {
                    StoreDriverDeliveryDiagnostics.LogEvent(orgId, MailboxTransportEventLogConstants.Tuple_ApprovalArbitrationMailboxQuota, null, new object[]
                    {
                        session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                        orgId,
                        num3,
                        num2
                    });
                    EventNotificationItem.Publish(ExchangeComponent.MailboxTransport.Name, "ApprovalArbitrationMailboxQuota", null, string.Format("The arbitration mailbox is approaching its quota. Org ID: {0}, Primary Smtp Address: {1}", orgId, session.MailboxOwner.MailboxInfo.PrimarySmtpAddress), ResultSeverityLevel.Warning, false);
                }
            }
        }
Esempio n. 5
0
        public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args)
        {
            WorkingSetAgent.tracer.TraceDebug((long)this.traceId, "WorkingSetAgent.OnPromotedMessageHandler: entering");
            StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = args as StoreDriverDeliveryEventArgsImpl;

            if (storeDriverDeliveryEventArgsImpl == null)
            {
                WorkingSetAgent.tracer.TraceError((long)this.traceId, "WorkingSetAgent.OnPromotedMessageHandler: args is null or not a StoreDriverDeliveryEventArgsImpl; exiting");
                return;
            }
            if (!this.Validate(storeDriverDeliveryEventArgsImpl))
            {
                return;
            }
            string arg = storeDriverDeliveryEventArgsImpl.MailboxSession.MdbGuid.ToString();

            WorkingSetAgent.tracer.TraceDebug <string>((long)this.traceId, "WorkingSetAgent.OnPromotedMessageHandler: mdbGuid is {0}", arg);
            WorkingSetAgentPerfLogging logger = new WorkingSetAgentPerfLogging();
            DateTime utcNow = DateTime.UtcNow;
            bool     workingSetSignalMailProcessed = false;

            try
            {
                WorkingSet.ProcessingAccepted.Increment();
                using (new StopwatchPerformanceTracker("OnPromotedMessageHandler", logger))
                {
                    using (new CpuPerformanceTracker("OnPromotedMessageHandler", logger))
                    {
                        using (new StorePerformanceTracker("OnPromotedMessageHandler", logger))
                        {
                            this.Process(storeDriverDeliveryEventArgsImpl);
                            workingSetSignalMailProcessed = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is OutOfMemoryException || ex is StackOverflowException || ex is ThreadAbortException)
                {
                    throw;
                }
                if (ex is SmtpResponseException)
                {
                    workingSetSignalMailProcessed = true;
                    throw;
                }
                WorkingSetAgent.tracer.TraceError <Exception>((long)this.traceId, "WorkingSetAgent.OnPromotedMessageHandler encountered an exception: {0}", ex);
                StoreDriverDeliveryDiagnostics.LogEvent(MailboxTransportEventLogConstants.Tuple_WorkingSetAgentException, ex.Message, new object[]
                {
                    ex
                });
                storeDriverDeliveryEventArgsImpl.MailRecipient.DsnRequested = DsnRequestedFlags.Never;
                throw new SmtpResponseException(WorkingSetAgent.UnprocessedSignalMailResponse, base.Name);
            }
            finally
            {
                this.UpdatePerfCounters(utcNow, workingSetSignalMailProcessed, logger);
                WorkingSetAgent.tracer.TraceDebug((long)this.traceId, "WorkingSetAgent.OnPromotedMessageHandler: exiting");
            }
        }
Esempio n. 6
0
        private void StampModeratedTransportExpiry()
        {
            byte[]            policyTag         = null;
            string            text              = string.Empty;
            int               retentionPeriod   = 2;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.mbxTransportMailItem.OrganizationId), 361, "StampModeratedTransportExpiry", "f:\\15.00.1497\\sources\\dev\\MailboxTransport\\src\\MailboxTransportDelivery\\StoreDriver\\agents\\approval\\ApprovalEngine.cs");
                ADObjectId descendantId = tenantOrTopologyConfigurationSession.GetOrgContainerId().GetDescendantId(ApprovalApplication.ParentPathInternal);
                ADObjectId childId      = descendantId.GetChildId("ModeratedRecipients");
                ApprovalEngine.diag.TraceDebug <ADObjectId>((long)this.GetHashCode(), "Reading ModeratedRecipient app from {0}", childId);
                if (childId != null)
                {
                    ApprovalApplication approvalApplication = tenantOrTopologyConfigurationSession.Read <ApprovalApplication>(childId);
                    if (approvalApplication != null)
                    {
                        ADObjectId elcretentionPolicyTag = approvalApplication.ELCRetentionPolicyTag;
                        ApprovalEngine.diag.TraceDebug <ADObjectId>((long)this.GetHashCode(), "Read ModeratedRecipient, now reading Recipient Policy Tag {0}", elcretentionPolicyTag);
                        RetentionPolicyTag retentionPolicyTag = null;
                        if (elcretentionPolicyTag != null)
                        {
                            retentionPolicyTag = tenantOrTopologyConfigurationSession.Read <RetentionPolicyTag>(elcretentionPolicyTag);
                        }
                        else
                        {
                            IConfigurationSession configurationSession = SharedConfiguration.CreateScopedToSharedConfigADSession(this.mbxTransportMailItem.OrganizationId);
                            if (configurationSession != null)
                            {
                                IList <RetentionPolicyTag> defaultRetentionPolicyTag = ApprovalUtils.GetDefaultRetentionPolicyTag(configurationSession, ApprovalApplicationId.ModeratedRecipient, 1);
                                if (defaultRetentionPolicyTag != null && defaultRetentionPolicyTag.Count > 0)
                                {
                                    retentionPolicyTag = defaultRetentionPolicyTag[0];
                                }
                            }
                        }
                        if (retentionPolicyTag != null)
                        {
                            ADPagedReader <ElcContentSettings> elccontentSettings = retentionPolicyTag.GetELCContentSettings();
                            using (IEnumerator <ElcContentSettings> enumerator = elccontentSettings.GetEnumerator())
                            {
                                if (enumerator.MoveNext())
                                {
                                    ElcContentSettings elcContentSettings = enumerator.Current;
                                    retentionPeriod = (int)elcContentSettings.AgeLimitForRetention.Value.TotalDays;
                                }
                            }
                            policyTag = retentionPolicyTag.RetentionId.ToByteArray();
                        }
                    }
                }
            });

            if (!adoperationResult.Succeeded)
            {
                if (adoperationResult.Exception is TransientException)
                {
                    throw adoperationResult.Exception;
                }
                text = adoperationResult.Exception.ToString();
                ApprovalEngine.diag.TraceError <string>((long)this.GetHashCode(), "Can't get PolicyTag guid {0}, NDRing.", text);
            }
            if (policyTag == null)
            {
                ApprovalEngine.diag.TraceError((long)this.GetHashCode(), "PolicyTag not read. NDRing");
                string text2 = this.mbxTransportMailItem.OrganizationId.ToString();
                StoreDriverDeliveryDiagnostics.LogEvent(MailboxTransportEventLogConstants.Tuple_ApprovalCannotStampExpiry, text2, new object[]
                {
                    text2,
                    text
                });
                throw new SmtpResponseException(AckReason.ApprovalCannotReadExpiryPolicy);
            }
            if (retentionPeriod < 2)
            {
                retentionPeriod = 2;
            }
            else if (retentionPeriod > 30)
            {
                retentionPeriod = 30;
            }
            this.messageItem[ItemSchema.RetentionDate]          = ExDateTime.UtcNow.AddDays((double)retentionPeriod);
            this.messageItem[StoreObjectSchema.RetentionPeriod] = retentionPeriod;
            this.messageItem[StoreObjectSchema.PolicyTag]       = policyTag;
        }
Esempio n. 7
0
        public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args)
        {
            int hashCode = this.GetHashCode();

            PeopleIKnowAgent.tracer.TraceDebug((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: entering");
            if (args == null || !(args is StoreDriverDeliveryEventArgsImpl))
            {
                PeopleIKnowAgent.tracer.TraceError((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: args is null or not a StoreDriverDeliveryEventArgsImpl; exiting");
                return;
            }
            StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args;
            MailboxSession mailboxSession = storeDriverDeliveryEventArgsImpl.MailboxSession;

            if (mailboxSession == null)
            {
                PeopleIKnowAgent.tracer.TraceError((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: MailboxSession is null; exiting");
                return;
            }
            string      text        = null;
            MessageItem messageItem = null;

            if (storeDriverDeliveryEventArgsImpl.MailItem != null && storeDriverDeliveryEventArgsImpl.MailItem.Message != null && storeDriverDeliveryEventArgsImpl.MailItem.Message.Sender != null && !string.IsNullOrEmpty(storeDriverDeliveryEventArgsImpl.MailItem.Message.Sender.SmtpAddress) && storeDriverDeliveryEventArgsImpl.ReplayItem != null)
            {
                text        = storeDriverDeliveryEventArgsImpl.MailItem.Message.Sender.SmtpAddress;
                messageItem = storeDriverDeliveryEventArgsImpl.ReplayItem;
                PeopleIKnowAgent.tracer.TraceDebug <string>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: senderSmtpAddress is {0}", text);
                string text2 = mailboxSession.MdbGuid.ToString();
                PeopleIKnowAgent.tracer.TraceDebug <string>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: mdbGuid is {0}", text2);
                PeopleIKnowAgent.PeopleIKnowAgentPerfLogging peopleIKnowAgentPerfLogging = new PeopleIKnowAgent.PeopleIKnowAgentPerfLogging();
                try
                {
                    using (new StopwatchPerformanceTracker("OnPromotedMessageHandler", peopleIKnowAgentPerfLogging))
                    {
                        using (new CpuPerformanceTracker("OnPromotedMessageHandler", peopleIKnowAgentPerfLogging))
                        {
                            using (new StorePerformanceTracker("OnPromotedMessageHandler", peopleIKnowAgentPerfLogging))
                            {
                                using (Folder folder = Folder.Bind(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox), new PropertyDefinition[]
                                {
                                    FolderSchema.PeopleIKnowEmailAddressCollection,
                                    FolderSchema.PeopleIKnowEmailAddressRelevanceScoreCollection
                                }))
                                {
                                    if (folder == null)
                                    {
                                        PeopleIKnowAgent.tracer.TraceDebug((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: inbox  folder could not be found");
                                    }
                                    else
                                    {
                                        byte[] array = (folder.TryGetProperty(FolderSchema.PeopleIKnowEmailAddressRelevanceScoreCollection) as byte[]) ?? (folder.TryGetProperty(FolderSchema.PeopleIKnowEmailAddressCollection) as byte[]);
                                        if (array == null || array.Length == 0)
                                        {
                                            PeopleIKnowAgent.tracer.TraceDebug((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: The property PeopleIKnowAddressList did not exist on the folder");
                                        }
                                        else
                                        {
                                            bool flag = false;
                                            PeopleIKnowEmailAddressCollection peopleIKnowEmailAddressCollection = PeopleIKnowEmailAddressCollection.CreateFromByteArray(array, PeopleIKnowAgent.tracer, hashCode);
                                            if (peopleIKnowEmailAddressCollection != null)
                                            {
                                                PeopleIKnowMetadata peopleIKnowMetadata;
                                                flag = peopleIKnowEmailAddressCollection.Contains(text, out peopleIKnowMetadata);
                                                if (flag && peopleIKnowMetadata != null)
                                                {
                                                    messageItem[MessageItemSchema.SenderRelevanceScore] = peopleIKnowMetadata.RelevanceScore;
                                                }
                                            }
                                            PeopleIKnowAgent.tracer.TraceDebug <string, string>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: The senderSmtpAddress {0} {1} contained in the list of people I know", text, flag ? "is" : "is not");
                                            messageItem.IsFromFavoriteSender = flag;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (ex is OutOfMemoryException || ex is StackOverflowException || ex is ThreadAbortException)
                    {
                        throw;
                    }
                    PeopleIKnowAgent.tracer.TraceError <Exception>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler encountered an exception: {0}", ex);
                    StoreDriverDeliveryDiagnostics.LogEvent(MailboxTransportEventLogConstants.Tuple_PeopleIKnowAgentException, ex.Message, new object[]
                    {
                        ex
                    });
                }
                finally
                {
                    PeopleIKnowAgent.tracer.TraceDebug <TimeSpan>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: StopwatchTime = {0}", peopleIKnowAgentPerfLogging.StopwatchTime);
                    PeopleIKnowAgent.tracer.TraceDebug <TimeSpan>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: CpuTime = {0}", peopleIKnowAgentPerfLogging.CpuTime);
                    PeopleIKnowAgent.tracer.TraceDebug <uint>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: StoreRPCs = {0}", peopleIKnowAgentPerfLogging.StoreRPCs);
                    PeopleIKnow.GetInstance(text2).AverageStopWatchTime.IncrementBy(peopleIKnowAgentPerfLogging.StopwatchTime.Ticks);
                    PeopleIKnow.GetInstance(text2).AverageStopWatchTimeBase.Increment();
                    PeopleIKnow.GetInstance(text2).AverageCpuTime.IncrementBy(peopleIKnowAgentPerfLogging.CpuTime.Ticks);
                    PeopleIKnow.GetInstance(text2).AverageCpuTimeBase.Increment();
                    PeopleIKnow.GetInstance(text2).AverageStoreRPCs.IncrementBy((long)((ulong)peopleIKnowAgentPerfLogging.StoreRPCs));
                    PeopleIKnow.GetInstance(text2).AverageStoreRPCsBase.Increment();
                    PeopleIKnowAgent.tracer.TraceDebug((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: exiting");
                }
                return;
            }
            PeopleIKnowAgent.tracer.TraceError <string, string>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: senderSmtpAddress {0} null, replayItem {1} null; exiting", string.IsNullOrEmpty(text) ? "is" : "is not", (messageItem == null) ? "is" : "is not");
        }
Esempio n. 8
0
 public void DeliveredMessageEventHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args)
 {
     try
     {
         StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = args as StoreDriverDeliveryEventArgsImpl;
         if (storeDriverDeliveryEventArgsImpl != null && this.IsInputValid(storeDriverDeliveryEventArgsImpl))
         {
             VariantConfigurationSnapshot snapshot = VariantConfiguration.GetSnapshot(storeDriverDeliveryEventArgsImpl.MailboxOwner.GetContext(null), null, null);
             if (snapshot.OfficeGraph.OfficeGraphAgent.Enabled)
             {
                 OfficeGraph.ItemsSeen.Increment();
                 bool flag = false;
                 OfficeGraphSignalType signalType = OfficeGraphSignalType.Attachment;
                 string   signal  = string.Empty;
                 bool     enabled = snapshot.OfficeGraph.OfficeGraphGenerateSignals.Enabled;
                 DateTime utcNow  = DateTime.UtcNow;
                 storeDriverDeliveryEventArgsImpl.MessageItem.Load();
                 string sharePointUrl;
                 List <Dictionary <string, string> > attachmentsProperties;
                 if (this.IsInterestingMailWithAttachments(storeDriverDeliveryEventArgsImpl.MessageItem, storeDriverDeliveryEventArgsImpl.MailboxSession, out sharePointUrl, out attachmentsProperties))
                 {
                     OfficeGraph.ItemsFilteredTotal.Increment();
                     if (enabled)
                     {
                         signal     = OfficeGraphAgentUtils.CreateAttachmentsSignal(storeDriverDeliveryEventArgsImpl.MessageItem, attachmentsProperties, storeDriverDeliveryEventArgsImpl.MailboxOwner.PrimarySmtpAddress.ToString(), storeDriverDeliveryEventArgsImpl.MailItem.TenantId);
                         signalType = OfficeGraphSignalType.Attachment;
                         flag       = true;
                     }
                     else
                     {
                         OfficeGraphAgent.tracer.TraceDebug((long)this.traceId, "Skipped generating signal since feature disabled.");
                     }
                 }
                 else
                 {
                     OfficeGraphAgent.tracer.TraceDebug((long)this.traceId, "Skipped item since it did not pass filter criteria.");
                 }
                 if (flag)
                 {
                     TimeSpan timeSpan = DateTime.UtcNow - utcNow;
                     OfficeGraph.LastSignalCreationTime.RawValue = (long)timeSpan.TotalMilliseconds;
                     OfficeGraph.AverageSignalCreationTime.IncrementBy((long)timeSpan.TotalMilliseconds);
                     OfficeGraph.AverageSignalCreationTimeBase.Increment();
                     utcNow = DateTime.UtcNow;
                     byte[] bytes          = storeDriverDeliveryEventArgsImpl.MailboxSession.OrganizationId.GetBytes(Encoding.ASCII);
                     string organizationId = Convert.ToBase64String(bytes);
                     OfficeGraphLog.LogSignal(signalType, signal, organizationId, sharePointUrl);
                     timeSpan = DateTime.UtcNow - utcNow;
                     OfficeGraph.LastSignalPersistingTime.RawValue = (long)timeSpan.TotalMilliseconds;
                     OfficeGraph.AverageSignalPersistingTime.IncrementBy((long)timeSpan.TotalMilliseconds);
                     OfficeGraph.AverageSignalPersistingTimeBase.Increment();
                     OfficeGraph.SignalPersisted.Increment();
                 }
             }
             else
             {
                 OfficeGraphAgent.tracer.TraceDebug((long)this.traceId, "Skipped item since agent is disabled.");
             }
         }
     }
     catch (Exception ex)
     {
         OfficeGraph.TotalExceptions.Increment();
         OfficeGraphAgent.tracer.TraceError <Exception>((long)this.traceId, "OfficeGraphAgent.DeliveredMessageEventHandler encountered an exception: {0}", ex);
         StoreDriverDeliveryDiagnostics.LogEvent(MailboxTransportEventLogConstants.Tuple_OfficeGraphAgentException, ex.Message, new object[]
         {
             ex
         });
     }
 }
Esempio n. 9
0
 public override void LogEvent(ExEventLog.EventTuple tuple, string periodicKey, params object[] messageArgs)
 {
     StoreDriverDeliveryDiagnostics.LogEvent(tuple, periodicKey, messageArgs);
 }