Ejemplo n.º 1
0
        public void Apply_Replacement_Filter_With_Multiple_Names()
        {
            // arrange
            var counters        = Mocks.Of <ICounter>(z => z.CategoryName == "Processor" && z.CounterName == "% Processor Time" && z.InstanceName == "*").Take(1).ToList();
            var counterGroup    = Mocks.Of <ICounterGroup>(y => y.Name == "A" && y.SecondsInterval == 10 && y.Counters == counters).Take(1).ToList();
            var config          = Mock.Of <IConfig>(x => x.Groups == counterGroup);
            var counterBusiness = new PerformanceCounterProvider(null, counter => new[]
            {
                new PerformanceCounterInfo(null, null, "w3wp", null, null, null, null),
                new PerformanceCounterInfo(null, null, "w3wp", null, null, null, null),
                new PerformanceCounterInfo(null, null, "w3wp", null, null, null, null),
                new PerformanceCounterInfo(null, null, "w3wp", null, null, null, null),
            });

            // act
            var result = new[] { counterBusiness.GetGroup(counterGroup.First()) };

            // assert
            Assert.That(result.Length, Is.EqualTo(1));
            var resultCounters = result.First().GetCounters().ToList();

            Assert.That(resultCounters.Count, Is.EqualTo(4));
            Assert.That(resultCounters.First().InstanceName, Is.EqualTo("w3wp"));
            Assert.That(resultCounters.ElementAt(1).InstanceName, Is.EqualTo("w3wp#2"));
            Assert.That(resultCounters.ElementAt(2).InstanceName, Is.EqualTo("w3wp#3"));
            Assert.That(resultCounters.ElementAt(3).InstanceName, Is.EqualTo("w3wp#4"));
        }
Ejemplo n.º 2
0
        public override void Start(string [] args)
        {
            PerformanceCounterProvider provider = new PerformanceCounterProvider( );

            provider.GetPerformanceCounter("a");

            (string SourceCodeVersion, string Builder, DateTimeOffset ? BuildTime) ? a =
                typeof(ProgramBase <Program, ProgramExitCode, ProgramSetting, ProgramSettingCatalog>).Assembly.
                GetInformationalVersion( );

            Thread thread = new Thread(DoSth);

            thread.Start( );

            Dispatcher = StaticServiceProvider.Provider.GetService <ITaskDispatcher> ( );

            Dispatcher.Start( );

            OnetimeTask task1 = new OnetimeTask(PrintTime1, default);

            Dispatcher.Dispatch(task1);

            IntervalTask task2 = new IntervalTask(
                PrintTime2,
                TimeSpan.FromSeconds(1),
                priority: TaskPriority.Background);

            Dispatcher.Dispatch(task2);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ActorRuntime"/> class.
        /// </summary>
        static ActorRuntime()
        {
            NodeName = FabricRuntime.GetNodeContext().NodeName;

            try
            {
                PerformanceCounterProvider.InitializeAvailableCounterTypes();
            }
            catch (Exception e)
            {
                ActorTrace.Source.WriteWarning(
                    "ActorRegistration",
                    "Performance Counter Initialization failed with {0}",
                    e.ToString());
            }
        }