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
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
}
2016-11-28 20:00:12 -05:00
/ *
Lower bound of the percentage of requested power , that can be allocated to a task .
Note : This constant is not used for the proactive cluster wide capping schemes .
* /
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
}
2016-11-28 20:00:12 -05:00
/ *
The factor , that when multiplied with ( task . Watts * CapMargin ) results in ( task . Watts * PowerThreshold ) .
This is used to check whether available power , for a host in an offer , is not less than ( PowerThreshold * task . Watts ) ,
which is assumed to result in starvation of the task .
Here is an example ,
Suppose a task requires 100 W of power . Assuming CapMargin = 0.75 and PowerThreshold = 0.6 .
So , the assumed allocated watts is 75 W .
Now , when we get an offer , we need to check whether the available power , for the host in that offer , is
not less than 60 % ( the PowerTreshold ) of the requested power ( 100 W ) .
To put it in other words ,
availablePower >= 100 W * 0.75 * X
where X is the StarvationFactor ( 80 % in this case )
2016-11-10 19:55:28 -05:00
2016-11-28 20:00:12 -05:00
Note : This constant is not used for the proactive cluster wide capping schemes .
* /
var StarvationFactor = PowerThreshold / CapMargin
2016-11-10 19:55:28 -05:00
// Window size for running average
2017-01-06 15:56:49 -08:00
var WindowSize = 20
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
}
}