2016-11-10 19:55:28 -05:00
/ *
Constants that are used across scripts
1. The available hosts = stratos - 00 x ( 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
2016-11-25 16:04:11 -05:00
var Hosts = [ ] string { "stratos-001.cs.binghamton.edu" , "stratos-002.cs.binghamton.edu" ,
2016-11-25 17:42:08 -05:00
"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" }
2016-11-10 19:55:28 -05:00
// Add a new host to the slice of hosts.
2016-11-28 17:18:33 -05:00
func AddNewHost ( newHost string ) bool {
2016-11-25 17:42:08 -05:00
// Validation
2016-11-28 17:18:33 -05:00
if newHost == "" {
2016-11-25 17:42:08 -05:00
return false
} else {
2016-11-28 17:18:33 -05:00
Hosts = append ( Hosts , newHost )
2016-11-25 17:42:08 -05:00
return true
}
2016-11-10 19:55:28 -05:00
}
// Lower bound of the percentage of requested power, that can be allocated to a task.
2016-11-28 17:18:33 -05:00
var PowerThreshold = 0.6 // Right now saying that a task will never be given lesser than 60% of the power it requested.
2016-11-10 19:55:28 -05:00
/ *
Margin with respect to the required power for a job .
So , if power required = 10 W , the node would be capped to 75 % * 10 W .
This value can be changed upon convenience .
* /
2016-11-28 17:18:33 -05:00
var CapMargin = 0.70
2016-11-10 19:55:28 -05:00
// Modify the cap margin.
2016-11-28 17:18:33 -05:00
func UpdateCapMargin ( newCapMargin float64 ) bool {
2016-11-25 17:42:08 -05:00
// Checking if the new_cap_margin is less than the power threshold.
2016-11-28 17:18:33 -05:00
if newCapMargin < StarvationFactor {
2016-11-25 17:42:08 -05:00
return false
} else {
2016-11-28 17:18:33 -05:00
CapMargin = newCapMargin
2016-11-25 17:42:08 -05:00
return true
}
2016-11-10 19:55:28 -05:00
}
// Threshold factor that would make (Cap_margin * task.Watts) equal to (60/100 * task.Watts).
2016-11-28 17:18:33 -05:00
var StarvationFactor = 0.8
2016-11-10 19:55:28 -05:00
// Total power per node.
2016-11-28 17:18:33 -05:00
var TotalPower map [ string ] float64
2016-11-10 19:55:28 -05:00
// Initialize the total power per node. This should be done before accepting any set of tasks for scheduling.
2016-11-28 17:18:33 -05:00
func AddTotalPowerForHost ( host string , totalPower float64 ) bool {
2016-11-25 17:42:08 -05:00
// Validation
2016-11-28 17:18:33 -05:00
isCorrectHost := false
for _ , existingHost := range Hosts {
if host == existingHost {
isCorrectHost = true
2016-11-25 17:42:08 -05:00
}
}
2016-11-10 19:55:28 -05:00
2016-11-28 17:18:33 -05:00
if ! isCorrectHost {
2016-11-25 17:42:08 -05:00
return false
} else {
2016-11-28 17:18:33 -05:00
TotalPower [ host ] = totalPower
2016-11-25 17:42:08 -05:00
return true
}
2016-11-10 19:55:28 -05:00
}
// Window size for running average
2016-11-28 17:18:33 -05:00
var WindowSize = 160
2016-11-10 19:55:28 -05:00
// Update the window size.
2016-11-28 17:18:33 -05:00
func UpdateWindowSize ( newWindowSize int ) bool {
2016-11-25 17:42:08 -05:00
// Validation
2016-11-28 17:18:33 -05:00
if newWindowSize == 0 {
2016-11-25 17:42:08 -05:00
return false
} else {
2016-11-28 17:18:33 -05:00
WindowSize = newWindowSize
2016-11-25 17:42:08 -05:00
return true
}
}