public BaseResponseHandler(RequestManager rm, ResultAggregator <TResponse> ra)
 {
     this.requestManager = rm;
     this.requestManager.RegisterForCancellation(this.OnManagerCancellation);
     this.resultAggregator = ra;
     this.resultAggregator.RegisterResponseHandler += this.EmptyHandler;
 }
コード例 #2
0
        public void AggregateResults(int simulationId, PerformContext consoleContext)
        {
            _messageHub = new ProcessingHub(consoleContext);
            var aggregator = new ResultAggregator(_resultContext);

            aggregator.BuildResults(simulationId);
            _messageHub.SendToAllClients("AggretationFinished for " + simulationId);
        }
コード例 #3
0
        public void AggreteResults()
        {
            var _resultContext = ResultContext.GetContext(remoteResultCtxString);

            var aggregator = new ResultAggregator(_resultContext);

            aggregator.BuildResults(1);
        }
コード例 #4
0
        public CollectionWithNestingResponseHandler(TParentEntity parent, Type nestedCollectionHandlerType, RequestManager rm, ResultAggregator <TParentEntity> ra) : base(rm, ra)
        {
            this.parentItem    = parent;
            this.nestedResults = new ResultAggregator <UNestedEntity>(rm.GetCancellationToken());
            this.nestedCollectionRequestHandler = BaseResponseHandler <UNestedEntity> .GetHandler(nestedCollectionHandlerType, rm, this.nestedResults);

            this.nestedResults.NoMoreAdding();
            this.nestedResults.ResultsComplete += this.OnResultsComplete;
        }
 public SingleOperationResponseHandler(RequestManager rm, ResultAggregator <OperationResult <TEntity> > ra) : base(rm, ra)
 {
 }
コード例 #6
0
 public CollectionResponseHandler(RequestManager rm, ResultAggregator <TResponseObject> ra) : base(rm, ra)
 {
 }
コード例 #7
0
        public SearchMailboxesResults Search(ISearchPolicy policy, SearchMailboxesInputs input)
        {
            Guid databaseGuid = Guid.Empty;
            List <SearchSource>          list       = new List <SearchSource>(input.Sources);
            ResultAggregator             aggregator = new ResultAggregator();
            IEnumerable <List <string> > enumerable = null;

            Recorder.Record record = policy.Recorder.Start("SearchResultProvider", TraceType.InfoTrace, true);
            Recorder.Trace(5L, TraceType.InfoTrace, new object[]
            {
                "LocalSearchResultsProvider.Search Input:",
                input,
                "Type:",
                input.SearchType
            });
            try
            {
                if (input.SearchType == SearchType.Statistics)
                {
                    enumerable = this.GenerateKeywordStatsQueryBatches(policy, aggregator, input.Criteria);
                }
                SearchCompletedCallback searchCallback = delegate(ISearchMailboxTask task, ISearchTaskResult result)
                {
                    aggregator.MergeSearchResult(result);
                };
                record.Attributes["MBXCNT"] = list.Count;
                while (list.Count > 0)
                {
                    Recorder.Trace(5L, TraceType.InfoTrace, "LocalSearchResultsProvider.Search UnsearchedSources:", list.Count);
                    HashSet <Guid>  hashSet         = new HashSet <Guid>();
                    MailboxInfoList mailboxInfoList = new MailboxInfoList();
                    int             i = 0;
                    while (i < list.Count)
                    {
                        SearchSource searchSource = list[i];
                        Guid         item         = searchSource.MailboxInfo.IsArchive ? searchSource.MailboxInfo.ArchiveGuid : searchSource.MailboxInfo.MailboxGuid;
                        if (!hashSet.Contains(item))
                        {
                            mailboxInfoList.Add(searchSource.MailboxInfo);
                            list.RemoveAt(i);
                            hashSet.Add(item);
                            databaseGuid = (searchSource.MailboxInfo.IsArchive ? searchSource.MailboxInfo.ArchiveDatabase : searchSource.MailboxInfo.MdbGuid);
                        }
                        else
                        {
                            i++;
                        }
                    }
                    Recorder.Trace(5L, TraceType.InfoTrace, "LocalSearchResultsProvider.Search NonDuplicateSourcesToSearch:", mailboxInfoList.Count);
                    AggregatedMailboxSearchTask aggregatedMailboxSearchTask;
                    if (input.SearchType == SearchType.Statistics)
                    {
                        Recorder.Trace(5L, TraceType.InfoTrace, "LocalSearchResultsProvider.Search Statistics:", enumerable);
                        using (IEnumerator <List <string> > enumerator = enumerable.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                List <string> keywordList = enumerator.Current;
                                AggregatedMailboxSearchTask aggregatedMailboxSearchTask2;
                                aggregatedMailboxSearchTask = (aggregatedMailboxSearchTask2 = new AggregatedMailboxSearchTask(databaseGuid, mailboxInfoList, input.Criteria, input.PagingInfo, keywordList, input.CallerInfo));
                                try
                                {
                                    aggregatedMailboxSearchTask.Execute(searchCallback);
                                    this.UpdateSearchStatistics(policy, record, aggregatedMailboxSearchTask);
                                }
                                finally
                                {
                                    if (aggregatedMailboxSearchTask2 != null)
                                    {
                                        ((IDisposable)aggregatedMailboxSearchTask2).Dispose();
                                    }
                                }
                            }
                            continue;
                        }
                    }
                    Recorder.Trace(5L, TraceType.InfoTrace, "LocalSearchResultsProvider.Search Regular");
                    AggregatedMailboxSearchTask aggregatedMailboxSearchTask3;
                    aggregatedMailboxSearchTask = (aggregatedMailboxSearchTask3 = new AggregatedMailboxSearchTask(databaseGuid, mailboxInfoList, input.SearchType, input.Criteria, input.PagingInfo, input.CallerInfo));
                    try
                    {
                        aggregatedMailboxSearchTask.Execute(searchCallback);
                        this.UpdateSearchStatistics(policy, record, aggregatedMailboxSearchTask);
                    }
                    finally
                    {
                        if (aggregatedMailboxSearchTask3 != null)
                        {
                            ((IDisposable)aggregatedMailboxSearchTask3).Dispose();
                        }
                    }
                }
            }
            finally
            {
                policy.Recorder.End(record);
            }
            return(new SearchMailboxesResults(input.Sources)
            {
                SearchResult = aggregator
            });
        }
コード例 #8
0
        private IEnumerable <List <string> > GenerateKeywordStatsQueryBatches(ISearchPolicy policy, ResultAggregator aggregator, SearchCriteria criteria)
        {
            List <string> list = new List <string>
            {
                criteria.QueryString
            };

            aggregator.KeywordStatistics.Add(criteria.QueryString, new KeywordHit(criteria.QueryString, 0UL, ByteQuantifiedSize.Zero));
            if (criteria.SubFilters != null)
            {
                foreach (string text in criteria.SubFilters.Keys)
                {
                    aggregator.KeywordStatistics.Add(text, new KeywordHit(text, 0UL, ByteQuantifiedSize.Zero));
                }
                list.AddRange(criteria.SubFilters.Keys);
            }
            return(Util.PartitionInSetsOf <string>(list, 5));
        }
コード例 #9
0
 public GroupCollectionResponseHandler(RequestManager rm, ResultAggregator <Group> ra) : base(rm, ra)
 {
 }
        public static BaseResponseHandler <TResponse> GetHandler(Type handlerType, RequestManager rm, ResultAggregator <TResponse> ra)
        {
            object handler;

            switch (handlerType)
            {
            case Type t when t == typeof(GroupCollectionResponseHandler):
                handler = new GroupCollectionResponseHandler(rm, ra as ResultAggregator <Group>);
                break;

            case Type t when t == typeof(GroupMembersCollectionResponseHandler):
                handler = new GroupMembersCollectionResponseHandler(rm, ra as ResultAggregator <DirectoryObject>);
                break;

            case Type t when t == typeof(UserCollectionResponseHandler):
                handler = new UserCollectionResponseHandler(rm, ra as ResultAggregator <User>);
                break;

            case Type t when t == typeof(MessageCollectionResponseHandler):
                handler = new MessageCollectionResponseHandler(rm, ra as ResultAggregator <Message>);
                break;

            case Type t when t == typeof(MessageCollectionPartitioningResponseHandler):
                handler = new MessageCollectionPartitioningResponseHandler(rm, ra as ResultAggregator <Message>);
                break;

            case Type t when t == typeof(DeviceCollectionResponseHandler):
                handler = new DeviceCollectionResponseHandler(rm, ra as ResultAggregator <Device>);
                break;

            default:
                throw new NotImplementedException($"Type {handlerType.FullName} is not implemented by this factory. The factory needs to be updated.");
            }
            return((BaseResponseHandler <TResponse>)handler);
        }
 public GroupMembershipResponseHandler(Group group, RequestManager requestManager, ResultAggregator <Group> resultAggregator)
     : base(group, typeof(GroupMembersCollectionResponseHandler), requestManager, resultAggregator)
 {
 }
 public UserMailboxResponseHandler(User user, RequestManager requestManager, ResultAggregator <User> resultAggregator)
     : base(user, typeof(MessageCollectionResponseHandler), requestManager, resultAggregator)
 {
 }
コード例 #13
0
 public MessageCollectionPartitioningResponseHandler(RequestManager rm, ResultAggregator <Message> ra) : base(rm, ra)
 {
 }
コード例 #14
0
 public UserCollectionResponseHandler(RequestManager rm, ResultAggregator <User> ra) : base(rm, ra)
 {
 }
コード例 #15
0
 public GroupMembersCollectionResponseHandler(RequestManager rm, ResultAggregator <DirectoryObject> ra) : base(rm, ra)
 {
 }
コード例 #16
0
        public SearchMailboxesResults Search(ISearchPolicy policy, SearchMailboxesInputs input)
        {
            long                     num        = 0L;
            long                     num2       = 0L;
            long                     num3       = 0L;
            long                     num4       = 0L;
            long                     num5       = 0L;
            long                     num6       = 0L;
            ulong                    num7       = 0UL;
            SortedResultPage         resultPage = null;
            MultiMailboxSearchClient multiMailboxSearchClient = null;
            ResultAggregator         resultAggregator         = new ResultAggregator();
            ByteQuantifiedSize       byteQuantifiedSize       = new ByteQuantifiedSize(0UL);
            List <MailboxStatistics> list = new List <MailboxStatistics>();
            Dictionary <Guid, List <KeyValuePair <int, long> > > dictionary = new Dictionary <Guid, List <KeyValuePair <int, long> > >();
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Recorder.Record record = policy.Recorder.Start("SearchResultProvider", TraceType.InfoTrace, true);
            Recorder.Trace(5L, TraceType.InfoTrace, new object[]
            {
                "FastLocalSearchResultsProvider.Search Input:",
                input,
                "Type:",
                input.SearchType
            });
            SearchMailboxesResults result;

            try
            {
                Recorder.Trace(5L, TraceType.InfoTrace, "FastLocalSearchResultsProvider.Search Initializing");
                num3 = stopwatch.ElapsedMilliseconds;
                string str  = (input.PagingInfo != null && input.PagingInfo.SortBy != null && input.PagingInfo.SortBy.SortOrder == SortOrder.Ascending) ? "+" : "-";
                string str2 = (input.PagingInfo != null && input.PagingInfo.SortValue != null && input.PagingInfo.SortValue.SortColumn == ItemSchema.DocumentId) ? "[docid]" : FastIndexSystemSchema.Received.Name;
                AdditionalParameters additionalParameters = new AdditionalParameters
                {
                    Sort     = str + str2,
                    Refiners = new string[]
                    {
                        FastIndexSystemSchema.Size.Name
                    }
                };
                long referenceDocId = 0L;
                PaginationQueryFilter pagingFilter = null;
                QueryFilter           queryFilter  = input.Criteria.Query;
                if (input.PagingInfo != null && input.PagingInfo.SortValue != null)
                {
                    referenceDocId = input.PagingInfo.SortValue.SecondarySortValue;
                    if (input.PagingInfo.SortValue.SortColumnValue != null && input.PagingInfo.SortValue.SortColumn != ItemSchema.DocumentId)
                    {
                        pagingFilter = new PaginationQueryFilter(input.PagingInfo);
                    }
                }
                SearchSource searchSource = input.Sources.FirstOrDefault <SearchSource>();
                if (searchSource != null)
                {
                    Guid   guid        = searchSource.MailboxInfo.IsArchive ? searchSource.MailboxInfo.ArchiveDatabase : searchSource.MailboxInfo.MdbGuid;
                    string displayName = FlowDescriptor.GetImsFlowDescriptor(FastLocalSearchResultsProvider.SearchConfig, FastIndexVersion.GetIndexSystemName(guid)).DisplayName;
                    num4 += stopwatch.ElapsedMilliseconds - num3;
                    num3  = stopwatch.ElapsedMilliseconds;
                    Recorder.Trace(5L, TraceType.InfoTrace, new object[]
                    {
                        "FastLocalSearchResultsProvider.Search Initialized DB:",
                        guid,
                        "Flow:",
                        displayName
                    });
                    List <SearchSource> list2 = new List <SearchSource>(input.Sources);
                    while (list2.Count > 0)
                    {
                        HashSet <Guid>      hashSet = new HashSet <Guid>();
                        List <SearchSource> list3   = new List <SearchSource>();
                        int i = 0;
                        while (i < list2.Count)
                        {
                            SearchSource searchSource2 = list2[i];
                            Guid         item          = searchSource2.MailboxInfo.IsArchive ? searchSource2.MailboxInfo.ArchiveGuid : searchSource2.MailboxInfo.MailboxGuid;
                            if (!hashSet.Contains(item))
                            {
                                list3.Add(searchSource2);
                                list2.RemoveAt(i);
                                hashSet.Add(item);
                            }
                            else
                            {
                                i++;
                            }
                        }
                        multiMailboxSearchClient = new MultiMailboxSearchClient(guid, (from s in list3
                                                                                       select s.MailboxInfo).ToArray <MailboxInfo>(), input.Criteria, input.CallerInfo, input.PagingInfo);
                        foreach (SearchSource searchSource3 in list3)
                        {
                            Recorder.Trace(5L, TraceType.InfoTrace, "FastLocalSearchResultsProvider.Search Searching Source", searchSource3);
                            ulong              num8 = 0UL;
                            bool               flag = false;
                            MailboxStatistics  mailboxStatistics   = null;
                            ByteQuantifiedSize byteQuantifiedSize2 = new ByteQuantifiedSize(0UL);
                            List <KeyValuePair <int, long> > list4 = new List <KeyValuePair <int, long> >();
                            Guid guid2 = searchSource3.MailboxInfo.IsArchive ? searchSource3.MailboxInfo.ArchiveGuid : searchSource3.MailboxInfo.MailboxGuid;
                            queryFilter = this.ApplyFolderFilter(queryFilter, searchSource3.MailboxInfo, multiMailboxSearchClient);
                            string text = FqlQueryBuilder.ToFqlString(queryFilter, input.Criteria.QueryCulture);
                            text = this.ApplyPagingFilter(text, referenceDocId, pagingFilter, input.PagingInfo, input.Criteria.QueryCulture);
                            Recorder.Trace(5L, TraceType.InfoTrace, new object[]
                            {
                                "FastLocalSearchResultsProvider.Search Searching Source Guid:",
                                guid2,
                                "Filter:",
                                queryFilter,
                                "Query:",
                                text
                            });
                            num6 += stopwatch.ElapsedMilliseconds - num3;
                            num3  = stopwatch.ElapsedMilliseconds;
                            IEnumerable <KeyValuePair <PagingImsFlowExecutor.QueryExecutionContext, SearchResultItem[]> > enumerable = FastLocalSearchResultsProvider.FlowExecutor.Execute(displayName, guid2, policy.CallerInfo.QueryCorrelationId, text, 0L, input.Criteria.QueryCulture, additionalParameters, Math.Min(FastLocalSearchResultsProvider.SearchConfig.FastQueryResultTrimHits, input.PagingInfo.PageSize), null);
                            foreach (KeyValuePair <PagingImsFlowExecutor.QueryExecutionContext, SearchResultItem[]> keyValuePair in enumerable)
                            {
                                Recorder.Trace(5L, TraceType.InfoTrace, "FastLocalSearchResultsProvider.Search found pages");
                                PagingImsFlowExecutor.QueryExecutionContext key = keyValuePair.Key;
                                ISearchResultItem[] value = keyValuePair.Value;
                                if (!flag)
                                {
                                    Recorder.Trace(5L, TraceType.InfoTrace, "FastLocalSearchResultsProvider.Search found statistics");
                                    num8 += (ulong)FastLocalSearchResultsProvider.FlowExecutor.ReadHitCount(key);
                                    IEnumerable <RefinerResult> source = FastLocalSearchResultsProvider.FlowExecutor.ReadRefiners(key);
                                    RefinerResult refinerResult        = source.FirstOrDefault((RefinerResult t) => t.Name == FastIndexSystemSchema.Size.Name);
                                    if (refinerResult != null)
                                    {
                                        byteQuantifiedSize2 += new ByteQuantifiedSize((ulong)refinerResult.Sum);
                                    }
                                    mailboxStatistics = new MailboxStatistics(searchSource3.MailboxInfo, num8, byteQuantifiedSize2);
                                    flag = true;
                                }
                                foreach (ISearchResultItem searchResultItem in value)
                                {
                                    Recorder.Trace(5L, TraceType.InfoTrace, "FastLocalSearchResultsProvider.Search found items");
                                    IFieldHolder fieldHolder = searchResultItem.Fields.FirstOrDefault((IFieldHolder f) => string.Equals(f.Name, "DocId", StringComparison.InvariantCultureIgnoreCase));
                                    if (fieldHolder != null)
                                    {
                                        long num9       = (long)fieldHolder.Value;
                                        int  documentId = IndexId.GetDocumentId(num9);
                                        IndexId.GetMailboxNumber(num9);
                                        list4.Add(new KeyValuePair <int, long>(documentId, num9));
                                    }
                                }
                                if (list4.Count >= input.PagingInfo.PageSize)
                                {
                                    Recorder.Trace(5L, TraceType.InfoTrace, "FastLocalSearchResultsProvider.Search completed FAST");
                                    break;
                                }
                            }
                            num7 += num8;
                            byteQuantifiedSize += byteQuantifiedSize2;
                            if (list4.Count > 0)
                            {
                                dictionary[guid2] = list4;
                            }
                            if (mailboxStatistics != null)
                            {
                                list.Add(mailboxStatistics);
                            }
                            num += stopwatch.ElapsedMilliseconds - num3;
                            num3 = stopwatch.ElapsedMilliseconds;
                        }
                        if (dictionary.Count > 0)
                        {
                            Recorder.Trace(5L, TraceType.InfoTrace, "FastLocalSearchResultsProvider.Search loading preview items");
                            resultPage = multiMailboxSearchClient.FetchPreviewProperties(dictionary);
                            num2      += stopwatch.ElapsedMilliseconds - num3;
                            num3       = stopwatch.ElapsedMilliseconds;
                        }
                        Recorder.Trace(5L, TraceType.InfoTrace, "FastLocalSearchResultsProvider.Search aggregating");
                        ISearchResult aggregator = new AggregatedSearchTaskResult(new MailboxInfoList(multiMailboxSearchClient.Mailboxes), resultPage, null, num7, byteQuantifiedSize, null, list, null);
                        resultAggregator.MergeSearchResult(aggregator);
                        num5 += stopwatch.ElapsedMilliseconds - num3;
                        num3  = stopwatch.ElapsedMilliseconds;
                    }
                }
                result = new SearchMailboxesResults(input.Sources)
                {
                    SearchResult = resultAggregator
                };
            }
            finally
            {
                record.Attributes["FAST"]      = num;
                record.Attributes["STORE"]     = num2;
                record.Attributes["REST"]      = num6;
                record.Attributes["INIT"]      = num4;
                record.Attributes["AGGR"]      = num5;
                record.Attributes["TOTALSIZE"] = byteQuantifiedSize;
                record.Attributes["TOTALCNT"]  = num7;
                policy.Recorder.End(record);
            }
            return(result);
        }
コード例 #17
0
        public override void Process(IList <SearchSource> item)
        {
            Recorder.Trace(4L, TraceType.InfoTrace, "CompleteSourceLookup.Process Item:", item);
            Guid guid = new Guid("aca47e7e-5bb8-43ed-976a-f3158f6d4df7");
            List <PreviewItem>       list  = new List <PreviewItem>();
            List <MailboxStatistics> list2 = new List <MailboxStatistics>();
            SearchMailboxesInputs    searchMailboxesInputs = base.Context.TaskContext as SearchMailboxesInputs;
            Uri     baseUri = new Uri("http://local/");
            StoreId value   = new VersionedId(new byte[]
            {
                3,
                1,
                2,
                3,
                3,
                1,
                2,
                3,
                byte.MaxValue
            });
            UniqueItemHash itemHash   = new UniqueItemHash(string.Empty, string.Empty, null, false);
            PagingInfo     pagingInfo = ((SearchMailboxesInputs)base.Executor.Context.Input).PagingInfo;
            ReferenceItem  sortValue  = new ReferenceItem(pagingInfo.SortBy, ExDateTime.Now, 0L);
            Dictionary <PropertyDefinition, object> properties = new Dictionary <PropertyDefinition, object>
            {
                {
                    ItemSchema.Id,
                    value
                }
            };

            foreach (SearchSource searchSource in item)
            {
                if (searchSource.MailboxInfo != null && (searchSource.MailboxInfo.MailboxGuid != Guid.Empty || searchSource.MailboxInfo.IsRemoteMailbox))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    if (searchSource.MailboxInfo != null && searchSource.MailboxInfo.MailboxGuid != Guid.Empty)
                    {
                        Dictionary <string, string> dictionary2 = dictionary;
                        string key = "Name";
                        string value2;
                        if ((value2 = searchSource.OriginalReferenceId) == null)
                        {
                            value2 = (searchSource.MailboxInfo.DisplayName ?? string.Empty);
                        }
                        dictionary2[key]   = value2;
                        dictionary["Smtp"] = (searchSource.MailboxInfo.PrimarySmtpAddress.ToString() ?? string.Empty);
                        dictionary["DN"]   = (searchSource.MailboxInfo.LegacyExchangeDN ?? string.Empty);
                    }
                    if (searchMailboxesInputs != null)
                    {
                        dictionary["Lang"]   = (searchMailboxesInputs.Language ?? string.Empty);
                        dictionary["Config"] = (searchMailboxesInputs.SearchConfigurationId ?? string.Empty);
                    }
                    Uri owaLink = LinkUtils.AppendQueryString(baseUri, dictionary);
                    Recorder.Trace(4L, TraceType.InfoTrace, new object[]
                    {
                        "CompleteSourceLookup.Process Found:",
                        searchSource.ReferenceId,
                        "MailboxInfo:",
                        searchSource.MailboxInfo
                    });
                    list.Add(new PreviewItem(properties, (searchSource.MailboxInfo.MailboxGuid != Guid.Empty) ? searchSource.MailboxInfo.MailboxGuid : guid, owaLink, sortValue, itemHash)
                    {
                        MailboxInfo = searchSource.MailboxInfo
                    });
                    list2.Add(new MailboxStatistics(searchSource.MailboxInfo, 0UL, new ByteQuantifiedSize(0UL)));
                }
            }
            SortedResultPage resultPage   = new SortedResultPage(list.ToArray(), pagingInfo);
            ISearchResult    searchResult = new ResultAggregator(resultPage, null, 0UL, new ByteQuantifiedSize(0UL), null, null, list2);

            base.Executor.EnqueueNext(new SearchMailboxesResults(item)
            {
                SearchResult = searchResult
            });
        }
コード例 #18
0
 public DeviceCollectionResponseHandler(RequestManager rm, ResultAggregator <Device> ra) : base(rm, ra)
 {
 }