Ejemplo n.º 1
0
        private void UpdateDequeue(ReferralQueue.ReferralData item)
        {
            string key = item.Authority.ToString();
            int    num = this.uniqueAuthoritiesInQueue[key];

            if (num == 1)
            {
                this.uniqueAuthoritiesInQueue.Remove(key);
                return;
            }
            this.uniqueAuthoritiesInQueue[key] = num - 1;
        }
Ejemplo n.º 2
0
 private ReferralQueue.ReferralData?GetNextReferralThatIsNotPending()
 {
     for (int i = 0; i < this.referralQueue.Count; i++)
     {
         ReferralQueue.ReferralData referralData = this.referralQueue.Dequeue();
         string item = referralData.Authority.ToString();
         if (!this.pendingAuthorities.Contains(item))
         {
             return(new ReferralQueue.ReferralData?(referralData));
         }
         this.referralQueue.Enqueue(referralData);
     }
     return(null);
 }
Ejemplo n.º 3
0
        internal bool DeQueue(out ReferralQueue.ReferralData referralData)
        {
            this.WaitForEvent(this.moreReferralsOrDoneEvent);
            if (!this.IsMoreReferralsReadyToProcess)
            {
                referralData = default(ReferralQueue.ReferralData);
                return(false);
            }
            referralData = this.GetNextReferralThatIsNotPending().Value;
            string item = referralData.Authority.ToString();

            this.pendingAuthorities.Add(item);
            this.UpdateDequeue(referralData);
            this.UpdateOnQueueChange();
            return(true);
        }
Ejemplo n.º 4
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);
         }
     }
 }
Ejemplo n.º 5
0
        internal void Enqueue(ReferralQueue.ReferralData referralData)
        {
            this.referralQueue.Enqueue(referralData);
            string key = referralData.Authority.ToString();
            int    num;

            if (this.uniqueAuthoritiesInQueue.TryGetValue(key, out num))
            {
                num++;
            }
            else
            {
                num = 1;
            }
            this.uniqueAuthoritiesInQueue[key] = num;
            this.UpdateOnQueueChange();
        }