async Task IndexInterface.Lookup(IOrleansQueryResultStream <IIndexableGrain> result, object key)
        {
            if (logger.IsVerbose)
            {
                logger.Verbose("Streamed index lookup called for key = {0}", key);
            }

            //get all silos
            Dictionary <SiloAddress, SiloStatus> hosts = await SiloUtils.GetHosts(true);

            ISet <Task <IOrleansQueryResult <IIndexableGrain> > > queriesToSilos = GetResultQueries(hosts, key);

            //TODO: After fixing the problem with OrleansStream, this part is not needed anymore
            while (queriesToSilos.Count > 0)
            {
                // Identify the first task that completes.
                Task <IOrleansQueryResult <IIndexableGrain> > firstFinishedTask = await Task.WhenAny(queriesToSilos);

                // ***Remove the selected task from the list so that you don't
                // process it more than once.
                queriesToSilos.Remove(firstFinishedTask);

                // Await the completed task.
                IOrleansQueryResult <IIndexableGrain> partialResult = await firstFinishedTask;

                await result.OnNextBatchAsync(partialResult);
            }
            await result.OnCompletedAsync();
        }
예제 #2
0
        private static async Task <int> CountPlayersBlockingIn <TIGrain, TProperties>(IOrleansQueryable <TIGrain, TProperties> q) where TIGrain : IPlayerGrain, IIndexableGrain where TProperties : PlayerProperties
        {
            IOrleansQueryResult <TIGrain> result = await q.GetResults();

            return(result.Count());
        }