Exemplo n.º 1
0
        internal void BeginWorker(ReferralQueue.State stateParam)
        {
            this.WaitForEvent(this.workerAvailableEvent);
            if (!this.ShouldCreateWorkerThread())
            {
                try
                {
                    stateParam.WorkerMethod(stateParam.WorkerState);
                    return;
                }
                finally
                {
                    this.pendingAuthorities.Remove(stateParam.AuthorityKey);
                    this.UpdateOnQueueChange();
                }
            }
            this.currentWorkerCount++;
            ReferralQueue.UpdateEvent(this.workerAvailableEvent, this.IsWorkerAvailable);
            bool flag = true;

            try
            {
                TrackingEventBudget.AcquireThread();
                flag = false;
            }
            finally
            {
                if (flag)
                {
                    TrackingEventBudget.ReleaseThread();
                }
            }
            ThreadPool.QueueUserWorkItem(new WaitCallback(this.WorkerMethodWrapper), stateParam);
        }
Exemplo n.º 2
0
 public void Evaluate(IEnumerable <List <RecipientTrackingEvent> > initialEvents, TrackingAuthorityKind authorityKind)
 {
     this.InsertPaths(null, initialEvents, authorityKind);
     ReferralQueue.ReferralData referralData;
     while (this.referralQueue.DeQueue(out referralData))
     {
         if (!this.directoryContext.TrackingBudget.IsUnderBudget())
         {
             TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Over budget following referrals, stopping", new object[0]);
             return;
         }
         Node node = referralData.Node;
         if (node.HasChildren)
         {
             TraceWrapper.SearchLibraryTracer.TraceDebug(this.GetHashCode(), "Skipping referral, node already has child.", new object[0]);
         }
         else
         {
             this.referralsFollowed++;
             if (this.referralsFollowed > 5000)
             {
                 TraceWrapper.SearchLibraryTracer.TraceError <int>(this.GetHashCode(), "Processed {0} referrals.  Giving up.", this.referralsFollowed);
                 return;
             }
             ReferralQueue       referralQueue = this.referralQueue;
             ReferralQueue.State state2        = new ReferralQueue.State();
             state2.AuthorityKey = referralData.Authority.ToString();
             state2.WorkerState  = referralData;
             state2.WorkerMethod = delegate(object state)
             {
                 ReferralQueue.ReferralData referralData2 = (ReferralQueue.ReferralData)state;
                 Node node2 = referralData2.Node;
                 TrackingAuthority      authority = referralData2.Authority;
                 RecipientTrackingEvent recipientTrackingEvent = (RecipientTrackingEvent)referralData2.Node.Value;
                 IEnumerable <List <RecipientTrackingEvent> > paths;
                 if (this.tryProcessReferral(recipientTrackingEvent, authority, out paths))
                 {
                     TraceWrapper.SearchLibraryTracer.TraceDebug <SmtpAddress, string>(this.GetHashCode(), "Inserting paths after following referral for recipient {0} from {1}.", recipientTrackingEvent.RecipientAddress, Names <TrackingAuthorityKind> .Map[(int)authority.TrackingAuthorityKind]);
                     this.InsertPaths(node2, paths, authority.TrackingAuthorityKind);
                     return;
                 }
                 TraceWrapper.SearchLibraryTracer.TraceError <SmtpAddress>(this.GetHashCode(), "Did not get any results for referral to recipient {0}.", recipientTrackingEvent.RecipientAddress);
             };
             referralQueue.BeginWorker(state2);
         }
     }
 }
Exemplo n.º 3
0
 private void UpdateOnQueueChange()
 {
     this.uniqueAuthoritiesInQueueNotPending = this.GetUniqueAuthoritiesInQueueThatAreNotPending();
     ReferralQueue.UpdateEvent(this.moreReferralsOrDoneEvent, this.IsMoreReferralsReadyToProcessOrDone);
 }
Exemplo n.º 4
0
        private void WorkerMethodWrapper(object stateObject)
        {
            ReferralQueue.State state   = (ReferralQueue.State)stateObject;
            bool          flag          = false;
            bool          flag2         = false;
            TrackingError trackingError = null;

            try
            {
                this.directoryContext.Acquire();
                flag = true;
                if (this.directoryContext.DiagnosticsContext.DiagnosticsLevel == DiagnosticsLevel.Etw)
                {
                    CommonDiagnosticsLogTracer traceWriter = new CommonDiagnosticsLogTracer();
                    TraceWrapper.SearchLibraryTracer.Register(traceWriter);
                    flag2 = true;
                }
                state.WorkerMethod(state.WorkerState);
            }
            catch (TrackingTransientException ex)
            {
                if (!ex.IsAlreadyLogged)
                {
                    trackingError = ex.TrackingError;
                }
            }
            catch (TrackingFatalException ex2)
            {
                if (ex2.IsAlreadyLogged)
                {
                    trackingError = ex2.TrackingError;
                }
            }
            catch (TransientException ex3)
            {
                trackingError = new TrackingError(ErrorCode.UnexpectedErrorTransient, string.Empty, ex3.Message, ex3.ToString());
            }
            catch (DataSourceOperationException ex4)
            {
                trackingError = new TrackingError(ErrorCode.UnexpectedErrorPermanent, string.Empty, "Error from Active Directory provider", ex4.ToString());
            }
            catch (DataValidationException ex5)
            {
                trackingError = new TrackingError(ErrorCode.UnexpectedErrorPermanent, string.Empty, "Validation Error from Active Directory provider", ex5.ToString());
            }
            finally
            {
                if (flag)
                {
                    if (trackingError != null)
                    {
                        TraceWrapper.SearchLibraryTracer.TraceError <TrackingError>(this.GetHashCode(), "Error in woker thread while processing referral, {0}", trackingError);
                        this.directoryContext.Errors.Errors.Add(trackingError);
                    }
                    this.pendingAuthorities.Remove(state.AuthorityKey);
                    this.currentWorkerCount--;
                    ReferralQueue.UpdateEvent(this.workerAvailableEvent, this.IsWorkerAvailable);
                    this.UpdateOnQueueChange();
                    if (flag2)
                    {
                        TraceWrapper.SearchLibraryTracer.Unregister();
                    }
                    this.directoryContext.Yield();
                    TrackingEventBudget.ReleaseThread();
                }
            }
        }