Ejemplo n.º 1
0
        public static async Task <int> GetNumActivations(IEnumerable <IGrain> targets)
        {
            var grainIds = targets.Distinct().Where(t => t is GrainReference).Select(t => ((GrainReference)t).GrainId).ToArray();
            IManagementGrain systemManagement = GrainClient.GrainFactory.GetGrain <IManagementGrain>(RuntimeInterfaceConstants.SYSTEM_MANAGEMENT_ID);
            var tasks = grainIds.Select(g => systemManagement.GetGrainActivationCount(GrainReference.FromGrainId(g))).ToArray();
            await Task.WhenAll(tasks);

            return(tasks.Sum(t => t.Result));
        }
Ejemplo n.º 2
0
        public static async Task <int> GetNumActivations(IEnumerable <IGrain> targets, IInternalGrainFactory grainFactory)
        {
            var grainIds = targets.Distinct().Where(t => t is GrainReference).Select(t => ((GrainReference)t).GrainId).ToArray();
            IManagementGrain systemManagement = grainFactory.GetGrain <IManagementGrain>(0);
            var tasks = grainIds.Select(g => systemManagement.GetGrainActivationCount((GrainReference)grainFactory.GetGrain(g))).ToArray();
            await Task.WhenAll(tasks);

            return(tasks.Sum(t => t.Result));
        }