public async Task <ActionResult> Start() { int batch_count = int.Parse(Request.Params["batchcount"]); int batch_size = int.Parse(Request.Params["batchsize"]); int delay = int.Parse(Request.Params["delay"]); int runtime = int.Parse(Request.Params["runtime"]); string url = Request.Params["testurl"]; // create an aggregator grain to track results from the load test IAggregatorGrain aggregator = AggregatorGrainFactory.GetGrain(0); // set this SimulationController class as an observer on the aggregator grain ISimulationObserver observer = await SimulationObserverFactory.CreateObjectReference(MvcApplication.GlobalObserver); // convert our class into a grain reference await aggregator.SetObserver(observer); // then set ourselves up to receive notifications on ReportResults() // Instantiate the manager grains and start the simulations // Pause between each batch to ramp up load gradually for (int i = 0; i < batch_count; i++) { Console.WriteLine("Starting batch #{0}", i + 1); IManagerGrain manager = ManagerGrainFactory.GetGrain(i); await manager.SetAggregator(aggregator); // link in the aggregator await manager.StartSimulators(i *delay, batch_size, url); // start the simulation } return(RedirectToAction("index")); }
public async Task StartSimulation(int batch_count, int batch_size, int delay, int runtime, string url) { // List of cities with coordinates var cities = new CityCoordinates(); // create an aggregator grain to track results from the load test IAggregatorGrain aggregator = AggregatorGrainFactory.GetGrain(0); // Instantiate the manager grains and start the simulations List <Task> tasks = new List <Task>(); for (int i = 0; i < batch_count; i++) { Console.WriteLine("Starting batch #{0}", i + 1); IManagerGrain manager = ManagerGrainFactory.GetGrain(i); all_managers.Add(manager); var city = cities.RandomCity(); tasks.Add(manager.SetAggregator(aggregator)); // link in the aggregator tasks.Add(manager.StartSimulators(i * delay, batch_size, url, city.Latitude, city.Longitude)); // start the simulation } await Task.WhenAll(tasks); }
public static async void InitializeOrleans() { // Create the Observer object MvcApplication.GlobalObserver = new SimulationObserver(); // Get a reference to the aggregator grain IAggregatorGrain aggregator = AggregatorGrainFactory.GetGrain(0); // Set observer on the aggregator grain ISimulationObserver observer = await SimulationObserverFactory.CreateObjectReference(MvcApplication.GlobalObserver); // convert our class into a grain reference await aggregator.SetObserver(observer); // then set ourselves up to receive notifications on ReportResults() }
const string URL = "http://devicetracker.cloudapp.net:8080/api/devices/processmessage"; // Change to point to the web site under test /// <summary> /// Start the simulation via the controller grain. /// </summary> /// <returns></returns> public async Task Run() { OrleansClient.Initialize(); // create an aggregator grain to track results from the load test IAggregatorGrain aggregator = AggregatorGrainFactory.GetGrain(0); // set this SimulationController class as an observer on the aggregator grain observer = await SimulationObserverFactory.CreateObjectReference(this); // convert our class into a grain reference await aggregator.SetObserver(observer); // then set ourselves up to receive notifications on ReportResults() // Instantiate the manager grains and start the simulations // Pause between each batch to ramp up load gradually for (int i = 0; i < BATCH_COUNT; i++) { Console.WriteLine("Starting batch #{0}", i + 1); IManagerGrain manager = ManagerGrainFactory.GetGrain(i); managers.Add(manager); // store grain reference await manager.SetAggregator(aggregator); // link in the aggregator await manager.StartSimulators(i *DELAY_STEPS *1000, BATCH_SIZE, URL); // start the sinulation } // Sleep for the duration of the test Console.WriteLine("Running test..."); Thread.Sleep(RUN_TIME * 1000); // low value just for test // Gradually stop simulators foreach (var i in managers) { Console.WriteLine("Stopping step #{0}", managers.IndexOf(i) + 1); await i.StopSimulators(); Thread.Sleep(DELAY_STEPS * 1000); } }