/* Constants that are used across scripts 1. The available hosts = stratos-00x (x varies from 1 to 8) 2. cap_margin = percentage of the requested power to allocate 3. power_threshold = overloading factor 4. total_power = total power per node 5. window_size = number of tasks to consider for computation of the dynamic cap. Also, exposing functions to update or initialize some of the constants. */ package constants var Hosts = []string{"stratos-001.cs.binghamton.edu", "stratos-002.cs.binghamton.edu", "stratos-003.cs.binghamton.edu", "stratos-004.cs.binghamton.edu", "stratos-005.cs.binghamton.edu", "stratos-006.cs.binghamton.edu", "stratos-007.cs.binghamton.edu", "stratos-008.cs.binghamton.edu"} // Add a new host to the slice of hosts. func AddNewHost(new_host string) bool { // Validation if new_host == "" { return false } else { Hosts = append(Hosts, new_host) return true } } // Lower bound of the percentage of requested power, that can be allocated to a task. var Power_threshold = 0.6 // Right now saying that a task will never be given lesser than 60% of the power it requested. /* Margin with respect to the required power for a job. So, if power required = 10W, the node would be capped to 75%*10W. This value can be changed upon convenience. */ var Cap_margin = 0.50 // Modify the cap margin. func UpdateCapMargin(new_cap_margin float64) bool { // Checking if the new_cap_margin is less than the power threshold. if new_cap_margin < Starvation_factor { return false } else { Cap_margin = new_cap_margin return true } } // Threshold factor that would make (Cap_margin * task.Watts) equal to (60/100 * task.Watts). var Starvation_factor = 0.8 // Total power per node. var Total_power map[string]float64 // Initialize the total power per node. This should be done before accepting any set of tasks for scheduling. func AddTotalPowerForHost(host string, total_power float64) bool { // Validation is_correct_host := false for _, existing_host := range Hosts { if host == existing_host { is_correct_host = true } } if !is_correct_host { return false } else { Total_power[host] = total_power return true } } // Window size for running average var Window_size = 10 // Update the window size. func UpdateWindowSize(new_window_size int) bool { // Validation if new_window_size == 0 { return false } else { Window_size = new_window_size return true } }