コード例 #1
0
        private void ExecuteInternal(BaseQuery query)
        {
            IStandardBudget standardBudget = null;

            if (Interlocked.Exchange(ref this.firstThreadEntryTimeCaptured, 1) == 0)
            {
                base.RequestLogger.Add(RequestStatistics.Create(RequestStatisticsType.LocalFirstThreadExecute, this.localRequestStopwatch.ElapsedMilliseconds));
            }
            if (base.Aborted)
            {
                return;
            }
            RequestStatisticsForMapi requestStatisticsForMapi = RequestStatisticsForMapi.Begin();
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                if (base.ClientContext.Budget != null)
                {
                    standardBudget = StandardBudget.Acquire(base.ClientContext.Budget.Owner);
                    if (standardBudget != null)
                    {
                        standardBudget.StartLocal("LocalRequest.ExecuteInternal", default(TimeSpan));
                    }
                }
                LocalRequest.RequestRoutingTracer.TraceDebug <object, int>((long)this.GetHashCode(), "{0}: Entered LocalRequest.Execute() using thread {1}", TraceContext.Get(), Environment.CurrentManagedThreadId);
                if (query.SetResultOnFirstCall(this.localQuery.GetData(query)))
                {
                    LocalRequest.RequestRoutingTracer.TraceDebug <object, EmailAddress, int>((long)this.GetHashCode(), "{0}: Request for mailbox {1} complete and result set in time. Thread {2}", TraceContext.Get(), query.Email, Environment.CurrentManagedThreadId);
                }
            }
            finally
            {
                stopwatch.Stop();
                if (standardBudget != null)
                {
                    standardBudget.EndLocal();
                    standardBudget.Dispose();
                }
                base.RequestLogger.Add(RequestStatistics.Create(RequestStatisticsType.LocalElapsedTimeLongPole, stopwatch.ElapsedMilliseconds, query.ExchangePrincipal.MailboxInfo.Location.ServerFqdn));
                base.RequestLogger.Add(requestStatisticsForMapi.End(RequestStatisticsType.Local, query.ExchangePrincipal.MailboxInfo.Location.ServerFqdn));
                if (Interlocked.Decrement(ref this.pendingItems) == 0)
                {
                    this.ComputeStatistics();
                    this.DisposeIfInternalContext();
                    base.Complete();
                }
                LocalRequest.RequestRoutingTracer.TraceDebug <object, int>((long)this.GetHashCode(), "{0}: Exited LocalRequest.Execute() using thread {1}", TraceContext.Get(), Environment.CurrentManagedThreadId);
            }
        }
コード例 #2
0
ファイル: Query.cs プロジェクト: YHZX2013/exchange_diff
        private ReturnType ExecuteWithPerformanceMeasurement()
        {
            Query <ReturnType> .Tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: {1}.Execute: enter", TraceContext.Get(), base.GetType().Name);

            RequestStatisticsForThread requestStatisticsForThread = RequestStatisticsForThread.Begin();
            RequestStatisticsForMapi   requestStatisticsForMapi   = RequestStatisticsForMapi.Begin();
            RequestStatisticsForAD     requestStatisticsForAD     = RequestStatisticsForAD.Begin();
            Stopwatch stopwatch       = Stopwatch.StartNew();
            Guid      serverRequestId = Microsoft.Exchange.Diagnostics.Trace.TraceCasStart(this.casTraceEventType);

            this.currentRequestsCounter.Increment();
            ReturnType result;

            try
            {
                result = this.ExecuteInternal();
            }
            finally
            {
                stopwatch.Stop();
                this.TraceExecuteInternalStop(serverRequestId);
                this.UpdateCountersAtExecuteEnd(stopwatch);
                this.currentRequestsCounter.Decrement();
                Query <ReturnType> .Tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: {1}.Execute: exit", TraceContext.Get(), base.GetType().Name);

                RequestStatistics requestStatistics = requestStatisticsForMapi.End(RequestStatisticsType.MailboxRPC);
                requestStatistics.Log(this.RequestLogger);
                RequestStatistics requestStatistics2 = requestStatisticsForAD.End(RequestStatisticsType.AD);
                requestStatistics2.Log(this.RequestLogger);
                RequestStatistics requestStatistics3 = requestStatisticsForThread.End(RequestStatisticsType.RequestCPUMain);
                if (requestStatistics3 != null)
                {
                    requestStatistics3.Log(this.RequestLogger);
                }
                this.RequestLogger.Log();
                this.LogExpensiveRequests(requestStatistics3, requestStatistics, requestStatistics2);
            }
            return(result);
        }