internal SenderInstrumentationPublisher(string instanceName, SenderInstrumentationManager instrumentationManager)
        {
            _totalMessagesSentCounter = 
                instrumentationManager.TotalMessagesSentCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalMessagesRequestedCounter = 
                instrumentationManager.TotalMessagesRequestedCounterDefinition.CreatePerformanceCounter(instanceName);
            _messagesSentPerSecondCounter = 
                instrumentationManager.MessagesSentPerSecondCounterDefinition.CreatePerformanceCounter(instanceName);
            _messagesRequestedPerSecondCounter = 
                instrumentationManager.MessagesRequestedPerSecondCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalBytesSentCounter = 
                instrumentationManager.TotalBytesSentCounterDefinition.CreatePerformanceCounter(instanceName);
            _bytesPerSecondSentCounter = 
                instrumentationManager.BytesSentPerSecondCounterDefinition.CreatePerformanceCounter(instanceName);
            _averageMessageSendingTimeCounter = 
                instrumentationManager.AverageMessageSendingTimeCounterDefinition.CreatePerformanceCounter(instanceName);
            _averageMessageSendingTimeBaseCounter = 
                instrumentationManager.AverageMessageSendingTimeBaseCounterDefinition.CreatePerformanceCounter(instanceName);

            _totalMessagesSentCounter.RawValue = 0L;
            _totalMessagesRequestedCounter.RawValue = 0L;
            _totalBytesSentCounter.RawValue = 0L;
            _averageMessageSendingTimeCounter.RawValue = 0L;
            _averageMessageSendingTimeBaseCounter.RawValue = 0L;
        }
        internal SenderInstrumentationPublisher(string instanceName, SenderInstrumentationManager instrumentationManager)
        {
            _totalMessagesSentCounter =
                instrumentationManager.TotalMessagesSentCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalMessagesRequestedCounter =
                instrumentationManager.TotalMessagesRequestedCounterDefinition.CreatePerformanceCounter(instanceName);
            _messagesSentPerSecondCounter =
                instrumentationManager.MessagesSentPerSecondCounterDefinition.CreatePerformanceCounter(instanceName);
            _messagesRequestedPerSecondCounter =
                instrumentationManager.MessagesRequestedPerSecondCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalBytesSentCounter =
                instrumentationManager.TotalBytesSentCounterDefinition.CreatePerformanceCounter(instanceName);
            _bytesPerSecondSentCounter =
                instrumentationManager.BytesSentPerSecondCounterDefinition.CreatePerformanceCounter(instanceName);
            _averageMessageSendingTimeCounter =
                instrumentationManager.AverageMessageSendingTimeCounterDefinition.CreatePerformanceCounter(instanceName);
            _averageMessageSendingTimeBaseCounter =
                instrumentationManager.AverageMessageSendingTimeBaseCounterDefinition.CreatePerformanceCounter(instanceName);

            _totalMessagesSentCounter.RawValue             = 0L;
            _totalMessagesRequestedCounter.RawValue        = 0L;
            _totalBytesSentCounter.RawValue                = 0L;
            _averageMessageSendingTimeCounter.RawValue     = 0L;
            _averageMessageSendingTimeBaseCounter.RawValue = 0L;
        }
Example #3
0
        private static void Main(string[] args)
        {
            var configuration = SimulatorConfiguration.GetCurrentConfiguration();

            var instrumentationPublisher =
                new SenderInstrumentationManager(instrumentationEnabled: true, installInstrumentation: true)
                    .CreatePublisher("Console");

            var carEmulator = new SimulationProfile("Console", 1, instrumentationPublisher, configuration);

            var options = SimulationScenarios
                .AllScenarios
                .ToDictionary(
                    scenario => "Run " + scenario,
                    scenario => (Func<CancellationToken, Task>)(token => carEmulator.RunEmulationAsync(scenario, token)));

            // Add Single shot
            foreach (var scenario in SimulationScenarios.AllScenarios)
            {
                var name = scenario;
                options.Add(
                    "Send 1 message from " + name,
                    token => carEmulator.RunOneMessageEmulationAsync(name, token)
                    );
            }

            ConsoleHost.WithOptions(options, configuration.ScenarioDuration);
        }
Example #4
0
        public override bool OnStart()
        {
            try
            {
                ServicePointManager.DefaultConnectionLimit = int.MaxValue;

                // We obtain the number of instance running this role and pass it along
                // to the simulation profile. Note that we are not supporting runtime
                // changing in the number of instances. Adding new instances at runtime will
                // increase the number of cars beyond the number specified in the configuration.
                var instanceCount = RoleEnvironment.CurrentRoleInstance.Role.Instances.Count;

                // Obtain the simulation configuration and generate a simulation profile.  Set up
                // the cancellation token to terminate the simulation after the configured duration 
                var configuration = SimulatorConfiguration.GetCurrentConfiguration();

                _scenario = string.IsNullOrEmpty(configuration.Scenario)
                    ? SimulationScenarios.DefaultScenario()
                    : configuration.Scenario;

                var instrumentationPublisher =
                    new SenderInstrumentationManager(instrumentationEnabled: true, installInstrumentation: false)
                        .CreatePublisher("WaWorkerHost");

                var hostName = ConfigurationHelper.SourceName;

                _simulationProfile = new SimulationProfile(
                    hostName,
                    instanceCount,
                    instrumentationPublisher,
                    configuration);

                _cancellationTokenSource.CancelAfter(configuration.ScenarioDuration);

                Logger.WorkerRoleStartedWith(configuration);
            }
            catch (Exception ex)
            {
                // Hard error on startup, usually configuration or security related
                // Ensure that we log this error, including a direct post to the local
                // event log
                LogHelpers.HandleRoleException(Logger, "OnStart()", ex);
                throw;
            }

            return base.OnStart();
        }