public void Start() { reportService.Initialize(servers.Select(s => s.Id)); foreach (var @event in events) { Logger.LogMessage($"Simualtion step {@event.Id} (t={@event.Time})"); var newVMs = AdvanceSimulation(@event); Prognose(@event.Id); DiagnoseAndMigrateIfNeeded(diagnosticService.DetectOverloadedMachines, migrationManager.MigrateFromOverloaded); if (newVMs.Count() > 0) { // assign new VMs var result = vmAsigner.Asign(newVMs, servers); VMs.Add(result.Asigned); } // TODO: should we used prgnoses for releasing too? DiagnoseAndMigrateIfNeeded(diagnosticService.DetectLowloadedMachines, migrationManager.ReleaseLowloadedMachines); WriteServerStatistics(@event.Id); } SaveResults(); }
//Fork means to duplicate proccess public VirtualMachine ForkVirtualMachine(VirtualMachine virtualMachine) { VirtualMachine vm; try { vm = new VirtualMachine(virtualMachine); VirtualMachines.Add(vm); return(vm); } catch (Exception) { if (virtualMachine != null) { virtualMachine.ReleaseResources(); } throw new InsufficientMemoryException("No more memmory"); } }
/// <summary> /// Returns a list of Permanent Virtual Machine roles. Each Virtual Machine object contains some metadata of the actual virtual machine /// </summary> /// <returns>A list of Permanent Virtual Machine Roles</returns> public VirtualMachines GetAllVirtualMachineRoles() { ComputeManagementClient client = new ComputeManagementClient(MyCloudCredentials); try { VirtualMachines vms = new VirtualMachines(new List <VirtualMachine>()); var hostedServices = client.HostedServices.List(); foreach (var service in hostedServices) { var deployment = GetAzureDeyployment(service.ServiceName, DeploymentSlot.Production); if (deployment != null) { if (deployment.Roles.Count > 0) { VirtualMachine vm = null; foreach (var role in deployment.Roles) { if (role.RoleType == VirtualMachineRoleType.PersistentVMRole.ToString()) { var operatingSystem = string.Format("{0}--{1}", role.OSVirtualHardDisk.OperatingSystem, role.OSVirtualHardDisk.SourceImageName); var rate = Configuration.GetAzureRates().GetMyRate(role.RoleSize); vm = new VirtualMachine(role.RoleName, role.RoleSize, role.RoleType, operatingSystem, rate); vms.Add(vm); } } } } } return(vms); } catch (CloudException ce) { Logger.Warn(ce, String.Format("Exception during retrieval of Virtual Machine Roles Exception: {0}", ce)); } return(null); }