示例#1
0
        private void ProcessStats(object state)
        {
            var currentTrace = Interlocked.Exchange(ref grainTrace, new ConcurrentDictionary <string, SiloGrainTraceEntry>());

            if (currentTrace.Count > 0)
            {
                if (siloAddress == null)
                {
                    siloAddress = localSiloDetails.SiloAddress.ToParsableString();
                }

                var items = currentTrace.Values.ToArray();

                foreach (var item in items)
                {
                    item.Grain = TypeFormatter.Parse(item.Grain);
                }

                try
                {
                    dashboardGrain = dashboardGrain ?? grainFactory.GetGrain <IDashboardGrain>(0);

                    dashboardGrain.SubmitTracing(siloAddress, items.AsImmutable()).Ignore();
                }
                catch (Exception ex)
                {
                    logger.LogWarning(100001, ex, "Exception thrown sending tracing to dashboard grain");
                }
            }
        }
示例#2
0
        public void TestGenericGrainWithMultipleTs()
        {
            var example = typeof(ITestGenericGrain <string, int>).FullName;

            var name = TypeFormatter.Parse(example);

            Assert.Equal("TestGrains.ITestGenericGrain<String, Int32>", name);
        }
示例#3
0
        public void TestFriendlyNameForStrings()
        {
            var example = "TestGrains.GenericGrain`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]";

            var name = TypeFormatter.Parse(example);

            Assert.Equal("TestGrains.GenericGrain<String>", name);
        }
示例#4
0
        public void TestSimpleType()
        {
            var example = "System.String";

            var name = TypeFormatter.Parse(example);

            Assert.Equal("System.String", name);
        }
        public void TestCustomType()
        {
            var example = "ExecuteAsync(CreateApp)";

            var name = TypeFormatter.Parse(example);

            Assert.Equal("ExecuteAsync(CreateApp)", name);
        }
示例#6
0
        public void TestGenericGrainWithFsType()
        {
            var example = ".Program.Progress";

            var name = TypeFormatter.Parse(example);

            Assert.Equal(".Program.Progress", name);
        }
示例#7
0
        public void TestGenericWithMultipleTs()
        {
            var example = typeof(IGenericGrain <Tuple <string, int> >).FullName;

            Console.WriteLine(example);

            var name = TypeFormatter.Parse(example);

            Assert.Equal("TestGrains.IGenericGrain<Tuple<String, Int32>>", name);
        }
        internal void RecalculateCounters(int activationCount, SiloDetails[] hosts,
                                          IList <SimpleGrainStatistic> simpleGrainStatistics)
        {
            counters.TotalActivationCount = activationCount;

            counters.TotalActiveHostCount        = hosts.Count(x => x.SiloStatus == SiloStatus.Active);
            counters.TotalActivationCountHistory = counters.TotalActivationCountHistory.Enqueue(activationCount).Dequeue();
            counters.TotalActiveHostCountHistory = counters.TotalActiveHostCountHistory.Enqueue(counters.TotalActiveHostCount).Dequeue();

            // TODO - whatever max elapsed time
            var elapsedTime = Math.Min((DateTime.UtcNow - startTime).TotalSeconds, 100);

            counters.Hosts = hosts;

            var aggregatedTotals = history.GroupByGrainAndSilo().ToLookup(x => (x.Grain, x.SiloAddress));

            counters.SimpleGrainStats = simpleGrainStatistics.Select(x =>
            {
                var grainName   = TypeFormatter.Parse(x.GrainType);
                var siloAddress = x.SiloAddress.ToParsableString();

                var result = new SimpleGrainStatisticCounter
                {
                    ActivationCount = x.ActivationCount,
                    GrainType       = grainName,
                    SiloAddress     = siloAddress,
                    TotalSeconds    = elapsedTime
                };

                foreach (var item in aggregatedTotals[(grainName, siloAddress)])
                {
                    result.TotalAwaitTime  += item.ElapsedTime;
                    result.TotalCalls      += item.Count;
                    result.TotalExceptions += item.ExceptionCount;
                }

                return(result);
            }).ToArray();