Example #1
0
        private static void PrintSimpleGrainStatistics(IEnumerable <string> args)
        {
            var silos = args.Select(ParseSilo).ToArray();
            var stats = systemManagement.GetSimpleGrainStatistics(silos).Result;

            Console.WriteLine("Silo                   Activations  Type");
            Console.WriteLine("---------------------  -----------  ------------");
            foreach (var s in stats.OrderBy(s => s.SiloAddress + s.GrainType))
            {
                Console.WriteLine("{0}  {1}  {2}", s.SiloAddress.ToString().PadRight(21), Pad(s.ActivationCount, 11), s.GrainType);
            }
        }
Example #2
0
        protected async Task <bool> CheckGrainCounts()
        {
#if USE_GENERICS
            string grainType = typeof(StreamReliabilityTestGrain <int>).FullName;
#else
            string grainType = typeof(StreamReliabilityTestGrain).FullName;
#endif
            IManagementGrain mgmtGrain = this.GrainFactory.GetGrain <IManagementGrain>(0);

            SimpleGrainStatistic[] grainStats = await mgmtGrain.GetSimpleGrainStatistics();

            output.WriteLine("Found grains " + Utils.EnumerableToString(grainStats));

            var grainLocs = grainStats.Where(gs => gs.GrainType == grainType).ToArray();

            Assert.True(grainLocs.Length > 0, "Found too few grains");
            Assert.True(grainLocs.Length <= 2, "Found too many grains " + grainLocs.Length);

            bool sameSilo = grainLocs.Length == 1;
            if (sameSilo)
            {
                StreamTestUtils.Assert_AreEqual(output, 2, grainLocs[0].ActivationCount, "Num grains on same Silo " + grainLocs[0].SiloAddress);
            }
            else
            {
                StreamTestUtils.Assert_AreEqual(output, 1, grainLocs[0].ActivationCount, "Num grains on Silo " + grainLocs[0].SiloAddress);
                StreamTestUtils.Assert_AreEqual(output, 1, grainLocs[1].ActivationCount, "Num grains on Silo " + grainLocs[1].SiloAddress);
            }
            return(sameSilo);
        }
Example #3
0
        private int ActiveGrainCount(string grainTypeName)
        {
            grainCounts = mgmtGrain.GetSimpleGrainStatistics().Result; // Blocking Wait
            int grainCount = grainCounts
                             .Where(g => g.GrainType == grainTypeName)
                             .Select(s => s.ActivationCount)
                             .Sum();

            return(grainCount);
        }
Example #4
0
        private int ActiveGrainCount(Type grainType)
        {
            var grainTypeName = RuntimeTypeNameFormatter.Format(grainType);

            grainCounts = mgmtGrain.GetSimpleGrainStatistics().Result; // Blocking Wait
            int grainCount = grainCounts
                             .Where(g => g.GrainType == grainTypeName)
                             .Select(s => s.ActivationCount)
                             .Sum();

            return(grainCount);
        }
Example #5
0
        private SimpleGrainStatistic[] GetSimpleGrainStatistics(string when)
        {
            SimpleGrainStatistic[] stats = mgmtGrain.GetSimpleGrainStatistics(null).Result;
            StringBuilder          sb    = new StringBuilder();

            foreach (var s in stats)
            {
                sb.Append(s).AppendLine();
            }
            Console.WriteLine("Grain statistics returned by Orleans Management Grain - " + when + " : " + sb);
            return(stats);
        }
Example #6
0
        private async Task <Dictionary <SiloHandle, int> > GetPerSiloActivationCounts()
        {
            string fullTypeName = "UnitTests.Grains.ActivationCountBasedPlacementTestGrain";

            IManagementGrain mgmtGrain = GrainClient.GrainFactory.GetGrain <IManagementGrain>(0);

            SimpleGrainStatistic[] stats = await mgmtGrain.GetSimpleGrainStatistics();

            return(this.HostedCluster.GetActiveSilos()
                   .ToDictionary(
                       s => s,
                       s => stats
                       .Where(stat => stat.SiloAddress.Equals(s.SiloAddress) && stat.GrainType == fullTypeName)
                       .Select(stat => stat.ActivationCount).SingleOrDefault()));
        }
Example #7
0
        public static async Task <int> GetActivationCount(IGrainFactory grainFactory, string fullTypeName)
        {
            int result = 0;

            IManagementGrain mgmtGrain = grainFactory.GetGrain <IManagementGrain>(0);

            SimpleGrainStatistic[] stats = await mgmtGrain.GetSimpleGrainStatistics();

            foreach (var stat in stats)
            {
                if (stat.GrainType == fullTypeName)
                {
                    result += stat.ActivationCount;
                }
            }
            return(result);
        }
Example #8
0
        public static async Task <int> GetActivationCount(string fullTypeName)
        {
            int result = 0;

            IManagementGrain mgmtGrain = GrainClient.GrainFactory.GetGrain <IManagementGrain>(RuntimeInterfaceConstants.SYSTEM_MANAGEMENT_ID);

            SimpleGrainStatistic[] stats = await mgmtGrain.GetSimpleGrainStatistics();

            foreach (var stat in stats)
            {
                if (stat.GrainType == fullTypeName)
                {
                    result += stat.ActivationCount;
                }
            }
            return(result);
        }