formatted the code
This commit is contained in:
parent
f6ec974182
commit
81d795f197
4 changed files with 113 additions and 111 deletions
|
@ -11,19 +11,19 @@ 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"}
|
||||
"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
|
||||
}
|
||||
// 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.
|
||||
|
@ -38,16 +38,15 @@ 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
|
||||
}
|
||||
// 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
|
||||
|
||||
|
@ -56,32 +55,32 @@ 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
|
||||
}
|
||||
}
|
||||
// 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
|
||||
}
|
||||
if !is_correct_host {
|
||||
return false
|
||||
} else {
|
||||
Total_power[host] = total_power
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Window size for running average
|
||||
var Window_size = 160
|
||||
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
|
||||
}
|
||||
}
|
||||
// Validation
|
||||
if new_window_size == 0 {
|
||||
return false
|
||||
} else {
|
||||
Window_size = new_window_size
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue