Commit b76162fe by Tomasz Ciesielczyk

api update

parent f6ec91ac
......@@ -28,11 +28,6 @@ object ActionCache {
//#endregion
override fun toString(): String {
// printConsole("testxx")
// printConsole(LightStorage.instance.listIndex("PCM_PERFORMANCE_SETTINGS")!!.toJson())
// printConsole("testx: "+LightStorage.getObjectTree("PCM_PERFORMANCE_SETTINGS").toString())
// printConsole("testx: "+LightStorage.getObjectIndex<String>("PCM_PERFORMANCE_SETTINGS").toString())
// printConsole("tesxctx: "+LightStorage.getObjectIndex<String>("PCM_PERFORMANCE_SETTINGS").toJson())
return StorageKeys.PERFORMANCE_SETTINGS.getMap().toJson()
}
......
package psnc.m2dc.rtm
import psnc.m2dc.rtm.dao.DAO
import psnc.m2dc.rtm.model.rest.NodePriority
import psnc.m2dc.rtm.model.rest.Values
import psnc.m2dc.rtm.model.rest.validate
import psnc.m2dc.rtm.model.rpm.Resource
import psnc.m2dc.rtm.rpm.RPMApi
import psnc.m2dc.rtm.utils.logDebug
import psnc.m2dc.rtm.utils.logInfo
import psnc.m2dc.rtm.utils.toJson
/**
*
* Created by Tomek on 2019-06-17.
*/
object RTMApi {
fun setNodePriorities(priorities: ArrayList<NodePriority>) {
priorities.forEach({
it.validate()
})
priorities.forEach({
if (it.powerCapabilities.isEmpty())
StorageKeys.NODE_PRIORITIES_MAP[it.nodeId]?.let { previous ->
it.powerCapabilities.addAll(previous.powerCapabilities)
}
it.validate()//additional check, just in case
StorageKeys.NODE_PRIORITIES_MAP[it.nodeId] = it
})
}
fun getNodePrioritiesAsMap(): Map<String, NodePriority> {
return StorageKeys.NODE_PRIORITIES_MAP.getMap()
}
fun getNodePerformance(resources: Map<String, Resource>? = DAO.Resource.getResources()): HashMap<String,
ActionCache.Setting> {
val result = HashMap<String, ActionCache.Setting>()
resources?.forEach({
val performance = ActionCache.getState(it.value.id)
result[it.value.id] = performance
})
return result
}
fun setPerformance(resId: String, perf: Double, profile: String?) {
val resource = DAO.Resource.getResource(resId)
val currentProfile = profile ?: ActionCache.getProfile(resId)
val state = CurrentState.NodeState(resource, -1.0, -1.0, currentProfile, Values.nodePerformance(perf))
val setting = PowerSettings(mapOf(resource to state)).getActions(resource)
setting.actions.forEach {
RPMApi.instance().startAction(it, {
ActionCache.setPerformance(resource.id, setting.performance, currentProfile)
logInfo("Successful action: ${it.powerAction}:${it.resourceId}")
logDebug("Successful action: ${it.toJson()}")
})
}
}
}
\ No newline at end of file
......@@ -13,12 +13,13 @@ object StorageKeys {
private const val fm = "FM_"
private const val rtm = "RTM_"
val PERFORMANCE_SETTINGS = LightStorage.getNullableMapWrapper<Double>("${rtm}PERFORMANCE_SETTINGS")
val MIN_PERFORMANCE_SETTINGS = LightStorage.getNullableMapWrapper<Double>("${rtm}MIN_PERFORMANCE_SETTINGS")
val PROFILE_MAP = LightStorage.getNullableMapWrapper<String>("${rtm}PROFILE_MAP")
val TEMPERATURE_LIMIT = LightStorage.getNullableMapWrapper<TemperatureLimit>("${fm}TEMPERATURE_LIMIT")
var POWER_LIMIT: Double?
get() = LightStorage.instance.get("${pcm}POWER_LIMIT")
set(value) = value?.let { LightStorage.instance.put("${pcm}POWER_LIMIT", value) }
?: LightStorage.instance.delete("${pcm}POWER_LIMIT")
set(value) = value?.let { LightStorage.instance.put("${pcm}POWER_LIMIT", value) ;LightStorage.saveStorage() }
?: {LightStorage.instance.delete("${pcm}POWER_LIMIT");LightStorage.saveStorage()}()
var PC_POWER_POLICY: PowerCappingMode
......
......@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory
import psnc.m2dc.rtm.CurrentState
import psnc.m2dc.rtm.StorageKeys
import psnc.m2dc.rtm.model.rest.ESMPowerPolicy
import psnc.m2dc.rtm.model.rest.Values
import psnc.m2dc.rtm.rpm.RPMApi
import psnc.m2dc.rtm.utils.logError
import psnc.m2dc.rtm.utils.printConsole
......@@ -67,6 +68,14 @@ class ESMApi {
return StorageKeys.ESM_POWER_POLICY
}
fun setMinimumPerformance(id: String, perf: Double) {
StorageKeys.MIN_PERFORMANCE_SETTINGS[id]= Values.nodePerformance(perf)
}
fun getMinimumPerformance(id: String)= StorageKeys.MIN_PERFORMANCE_SETTINGS[id]
}
......@@ -4,47 +4,46 @@ package psnc.m2dc.rtm.pcm
import org.slf4j.LoggerFactory
import psnc.m2dc.rtm.ActionCache
import psnc.m2dc.rtm.CurrentState
import psnc.m2dc.rtm.PowerSettings
import psnc.m2dc.rtm.StorageKeys
import psnc.m2dc.rtm.dao.DAO
import psnc.m2dc.rtm.dao.LightStorage
import psnc.m2dc.rtm.model.rest.*
import psnc.m2dc.rtm.model.rest.PCMState
import psnc.m2dc.rtm.model.rest.PowerCappingMode
import psnc.m2dc.rtm.model.rest.PowerCappingStrategy
import psnc.m2dc.rtm.model.rest.Values
import psnc.m2dc.rtm.model.rpm.Resource
import psnc.m2dc.rtm.properties.keys.Keys
import psnc.m2dc.rtm.rpm.RPMApi
import psnc.m2dc.rtm.utils.Timer
import psnc.m2dc.rtm.utils.printConsole
import psnc.m2dc.rtm.utils.sum
import psnc.m2dc.rtm.utils.toJson
class PCMApi() {
//#region initialize INSTANCE
companion object {
val log = LoggerFactory.getLogger(PCMApi::class.java.name)!!
private var Instance: PCMApi? = null
private lateinit var pcmApiInstance: PCMApi
val Instance: PCMApi
get() = synchronized(lock) {
this.pcmApiInstance
}
private val lock: Any = Any()
private var initialized = false
fun instance(): PCMApi {
init {
synchronized(lock) {
if (Instance == null) {
log.warn("Initializing default PCM API", NullPointerException("PCM API not initialized"))
Instance = PCMApi()
}
if (!initialized) {
log.warn("PCM API not initialized, using default")
}
return Instance!!
this.pcmApiInstance = PCMApi()
log.info("PCM Api initialized")
}
}
fun init() {
fun reset() {
synchronized(lock) {
this.Instance = PCMApi()
log.info("PCM Api initialized")
initialized = true
this.pcmApiInstance = PCMApi()
}
}
}
//#endregion
......@@ -67,7 +66,7 @@ class PCMApi() {
fun resetPowerLimit() {
if (StorageKeys.POWER_LIMIT != null)
StorageKeys.POWER_LIMIT = null
if (Keys.PCM.fire_null_limit_restore.getNullable() == true) {
if (Keys.PCM.power_limit_reset_all.getNullable() == true) {
ActionCache.resetPowerSettings(DAO.Resource.getNodes().keys)
} else
ActionCache.resetPowerSettings()
......@@ -75,55 +74,15 @@ class PCMApi() {
fun setPowerLimit(limit: Double): Boolean {
StorageKeys.POWER_LIMIT = Values.powerLimit(limit) ?: 0.0
ActionPredictor.predict(this.getPowerLimit())
return instance().checkState()
}
fun getPowerLimit(): Double? = StorageKeys.POWER_LIMIT?:Keys.PCM.default_power_limit.get()
fun getNodePerformance(resources: Map<String, Resource>? = DAO.Resource.getResources()): HashMap<String,
ActionCache.Setting> {
val result = HashMap<String, ActionCache.Setting>()
resources?.forEach({
val performance = ActionCache.getState(it.value.id)
result[it.value.id] = performance
})
return result
}
ActionPredictor.predict(this.getPowerLimit())
return Instance.checkState()
fun setPerformance(resId: String, perf: Double, profile: String?) {
val resource = DAO.Resource.getResource(resId)
val currentProfile = profile ?: ActionCache.getProfile(resId)
val state = CurrentState.NodeState(resource, -1.0, -1.0, currentProfile, perf)
val setting = PowerSettings(mapOf(resource to state)).getActions(resource)
setting.actions.forEach {
RPMApi.instance().startAction(it)
}
ActionCache.setPerformance(resource.id, setting.performance, currentProfile)
}
fun setNodePriorities(priorities: ArrayList<NodePriority>) {
priorities.forEach({
it.validate()
})
priorities.forEach({
if (it.powerCapabilities.isEmpty())
StorageKeys.NODE_PRIORITIES_MAP[it.nodeId]?.let { previous ->
it.powerCapabilities.addAll(previous.powerCapabilities)
}
it.validate()//additional check, just in case
StorageKeys.NODE_PRIORITIES_MAP[it.nodeId] = it
})
}
fun getPowerLimit(): Double? = StorageKeys.POWER_LIMIT ?: Keys.PCM.default_power_limit.get()
fun getNodePrioritiesAsMap(): Map<String, NodePriority> {
return StorageKeys.NODE_PRIORITIES_MAP.getMap()
}
fun getCurrentState(): Any = PCMWorker.getCurrentState() ?: this.checkLimits()
......@@ -152,7 +111,7 @@ class PCMApi() {
fun checkLimits(): PCMState {
try {
Timer.start()
val currentPowerOverLimit: Pair<Double, Double> = instance().getPowerOverLimit(true)
val currentPowerOverLimit: Pair<Double, Double> = Instance.getPowerOverLimit(true)
return PCMState(currentPowerOverLimit.first > 0, -currentPowerOverLimit.first,
currentPowerOverLimit.second)
} finally {
......@@ -161,6 +120,11 @@ class PCMApi() {
}
/**
* todo: move to other api
*/
private fun getMaxPowerUsageList(): HashMap<String, Double> {
val res = HashMap<String, Double>()
DAO.Resource.getResources().filter {
......@@ -195,9 +159,6 @@ class PCMApi() {
} else {
this.getMaxPowerUsageList()
}
printConsole("test0:" + this.getPowerCappingStrategy())
printConsole("test1:" + map.toJson())
printConsole("test2:" + map.sum())
if (totalLimit == null) {
totalLimit = this.getMaxPowerUsageList().sum()
}
......
......@@ -199,7 +199,7 @@ class Evaluation(initialPowerToReduce: Double, tradeOff: Double = 0.4, private v
return state.model.getPower(perfLvlx, util)
}
fun evaluateState(resourceId: String, perfLvlx: Double): Double {
fun evaluateState(resourceId: String, perfLvlx: Double,alphaValue: Double=this.alpha): Double {
val i0 = this.stateMap.get(resourceId) ?: throw NullPointerException("resource not found: ${resourceId}")
// print("resourceid: ${resourceId} ")
......@@ -207,7 +207,7 @@ class Evaluation(initialPowerToReduce: Double, tradeOff: Double = 0.4, private v
//sprawdzic ten wynik{"compute18":73.0,"compute16":41.0,"compute15":95.0}
//czemu ooplaca bardzie sie zwiekszy dla priorytetu 0 niz 1 , perf 95 >= perf 73 ? -> sprawdzić
// parametr x w funkcji celu
return this.evaluateState(i0, perfLvlx)
return this.evaluateState(i0, perfLvlx,alphaValue)
}
// fun absoluteGain(): Double {
......@@ -232,7 +232,7 @@ class Evaluation(initialPowerToReduce: Double, tradeOff: Double = 0.4, private v
//
fun evaluateState(currentState: StateDefinition, perfLvlx: Double, print: Boolean = false): Double {
fun evaluateState(currentState: StateDefinition, perfLvlx: Double,alphaValue: Double=this.alpha): Double {
val model = currentState.model
// power_{iyi}*r(i)(t_{ij})^{\alpha}(eff_{ij})^{1-\alpha}
val util_0 = model.calculateUtil(MAX_PERFORMANCE_LVL, currentState.perfLevel, currentState.util)
......@@ -242,8 +242,8 @@ class Evaluation(initialPowerToReduce: Double, tradeOff: Double = 0.4, private v
val perfValue = model.getPerformance(perfLvlx)
val effValue = model.getEfficiency(perfLvlx)
if (perfValue > 0 && effValue > 0) {
val performanceImpact = Math.pow(perfValue, alpha)
val efficiencyImpact = Math.pow(effValue, 1 - alpha)
val performanceImpact = Math.pow(perfValue, alphaValue)
val efficiencyImpact = Math.pow(effValue, 1 - alphaValue)
val eval = power * r_i * performanceImpact * efficiencyImpact
return eval
......
......@@ -330,6 +330,7 @@ open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double,
while (idx < slots.size) {
var slot = slots[idx]
val budgetChange = nodeSet[slot.node.id]!!.first - slot.powerReduction
if (-budgetChange >= 0 || powerBudget - budgetChange>0 ) {//power budget increases
nodeSet[slot.node.id] = Pair(slot.powerReduction, slot.gain)
result[slot.node.id] = slot.settingValue
......@@ -499,6 +500,152 @@ open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double,
return result
}
private fun greedyRandom(): HashMap<String, Double>? {
if (upperBoundCheck(null) < -currentBudget) {
/**impossible to fulfil requirements*/
return null
}
val result = HashMap<String, Double>() //initialize results <id,power setting>
val r = updatePowerToReduce(result)
// var powerToReduce = r.first
val group = r.second
/**set minimum performance*/
var powerSavings = 0.0 //power savings from maximum performance reduction
nodes.forEach { priority, nodes ->
if (priority.priorityValue <= group.priorityValue)
nodes.forEach { node ->
if (this.eval.getState(node.id) != null) {
result.put(node.id, 0.0)
powerSavings += node.state.getSavings(0)
settings.forEach { setting ->
slots[priority]!!.add(Slot(setting, node))
}
}
}
}
val nodeSet = HashMap<String, Pair<Double, Double>>()
//how much energy should be decreased within each group
// var powerBudget = powerSavings - powerToReduce
// var powerBudget = powerSavings - eval.powerOverLimit // powerToReduce
var powerBudget = powerSavings + currentBudget
val list = slots.filter { it.key.priorityValue == group.priorityValue }.flatMap { it.value }
val shuffled= list.shuffled()
/**greedy power distribution*/
shuffled.forEach { slot ->
if (!nodeSet.contains(slot.node.id)) {
val budgetChange = slot.node.state.savingsVector[0] - slot.powerReduction
if (powerBudget - budgetChange >= 0) {
nodeSet[slot.node.id] = Pair(slot.powerReduction, slot.gain)
result[slot.node.id] = slot.settingValue
powerSavings -= budgetChange
powerBudget -= budgetChange
}
} else if (nodeSet[slot.node.id]!!.second < slot.gain) {
val budgetChange = nodeSet[slot.node.id]!!.first - slot.powerReduction
if (powerBudget - budgetChange >= 0) {
nodeSet[slot.node.id] = Pair(slot.powerReduction, slot.gain)
result[slot.node.id] = slot.settingValue
powerSavings -= budgetChange
powerBudget -= budgetChange
}
}
}
/**
* power savings can be less than zero in case of performance increase
*/
this.powerSavings = eval.totalPowerSavings(result)
this.currentGain = eval.totalGain(result)
return result
}
private fun effectiveGreedy(): HashMap<String, Double>? {
if (upperBoundCheck(null) < -currentBudget) {
return null
}
val result = HashMap<String, Double>()
val r = updatePowerToReduce(result)
val group = r.second
/**set minimum performance*/
var powerSavings = 0.0 //power savings from maximum performance reduction
nodes.forEach { priority, nodes ->
if (priority.priorityValue <= group.priorityValue)
nodes.forEach { node ->
if (this.eval.getState(node.id) != null) {
result.put(node.id, 0.0)
powerSavings += node.state.getSavings(0)
settings.forEach { setting ->
slots[priority]!!.add(Slot(setting, node))
}
}
}
}
val nodeSet = HashMap<String, Pair<Double, Double>>()
var powerBudget = powerSavings + currentBudget // powerToReduce
//println("min:$powerBudget")
// posortować tak zeby uwaglednic rowniez ujemny zysk
// val sorted = slots.values.flatMap { it }.sortedByDescending { it.ratioMin }
//filter out necessaery priority groups. eg. "0 priority" -> all minimum performance, "(0-1) priorities" ->
// assign spare power budget
val sorted = slots.filter { it.key.priorityValue == group.priorityValue }.flatMap { it.value }
.sortedByDescending {
it.ratioMin
}
val sortedEff = slots.filter { it.key.priorityValue == group.priorityValue }.flatMap { it.value }
.sortedByDescending {
it.efficiencyRatio
}
/**greedy power distribution*/
sortedEff.forEach { slot ->
if (!nodeSet.contains(slot.node.id)) {
val budgetChange = slot.node.state.savingsVector[0] - slot.powerReduction
if (powerBudget - budgetChange >= 0) {
nodeSet[slot.node.id] = Pair(slot.powerReduction, slot.gain)
result[slot.node.id] = slot.settingValue
powerSavings -= budgetChange
powerBudget -= budgetChange
}
} else if (nodeSet[slot.node.id]!!.second < slot.gain) {
val budgetChange = nodeSet[slot.node.id]!!.first - slot.powerReduction
if (powerBudget - budgetChange >= 0) {
nodeSet[slot.node.id] = Pair(slot.powerReduction, slot.gain)
result[slot.node.id] = slot.settingValue
powerSavings -= budgetChange
powerBudget -= budgetChange
}
}
}
sorted.forEach { slot ->
if (!nodeSet.contains(slot.node.id)) {
val budgetChange = slot.node.state.savingsVector[0] - slot.powerReduction
if (powerBudget - budgetChange >= 0) {
nodeSet[slot.node.id] = Pair(slot.powerReduction, slot.gain)
result[slot.node.id] = slot.settingValue
powerSavings -= budgetChange
powerBudget -= budgetChange
}
} else if (nodeSet[slot.node.id]!!.second < slot.gain) {
val budgetChange = nodeSet[slot.node.id]!!.first - slot.powerReduction
if (powerBudget - budgetChange >= 0) {
nodeSet[slot.node.id] = Pair(slot.powerReduction, slot.gain)
result[slot.node.id] = slot.settingValue
powerSavings -= budgetChange
powerBudget -= budgetChange
}
}
}
/**
* power savings can be less than zero in case of performance increase
*/
this.powerSavings = eval.totalPowerSavings(result)
this.currentGain = eval.totalGain(result)
// println(result)
// println("heuristic: " + this.eval.totalGain(result))
return result
}
}
......@@ -550,6 +697,11 @@ data class Slot(val performanceSetting: PerformanceSetting, val node: Node) {
val power = node.solver.eval.powerUsage(node.id, settingValue)
val gain = node.solver.eval.evaluateState(node.id, settingValue)
val efficiency = node.solver.eval.evaluateState(node.id, settingValue,0.0)
val efficiencyRatio = {
val efficiency0 = node.solver.eval.evaluateState(node.id, 0.0,0.0)
(efficiency - efficiency0) / power
}()
// val ratio = gain / power
val ratioMin = {
val gain0 = node.solver.eval.evaluateState(node.id, 0.0)
......
package psnc.m2dc.rtm.utils
/**
* Created by Tomek on 2019-06-15.
*/
internal class UtilsKtTest {
@org.junit.jupiter.api.Test
fun loadDataTable() {
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import psnc.m2dc.rtm.model.rpm.ModelMap
import psnc.m2dc.rtm.model.rpm.Resource
import psnc.m2dc.rtm.properties.RTMProperties
import psnc.m2dc.rtm.properties.keys.Keys
import psnc.m2dc.rtm.rpm.nativeapi.RECSApiImpl
import psnc.m2dc.rtm.utils.*
import java.io.File
import java.io.FileNotFoundException
......@@ -27,10 +28,8 @@ object ServerConfInitializer {
resources.toJson(RTMProperties.parsePath("${RTMProperties.basePath}/_resource.conf").toString(), true)
//TODO: make this configurable
val overwrite = true
if (overwrite) {
printConsole("Save resources")
DAO.ResourcesManagerApi.saveResourcesToFile(resources)
}
DAO.ResourcesManagerApi.saveResourcesToFile(resources, !overwrite)
LightStorage.instance.save(null)
printConsole("end init")
} catch (e: Exception) {
......@@ -39,46 +38,50 @@ object ServerConfInitializer {
System.exit(-1)
}
}
private fun checkScripts(){
var exists = true
private fun checkScripts() {
var exists = true
exists = exists && File("bin/get_recs_nodes.sh").exists()
exists = exists && File("bin/install_node.sh").exists()
if(!exists){
throw FileNotFoundException("Check install_node.sh asd get_recs_nodes.sh exist in the bin direcotry ")
}
if (!exists) {
throw FileNotFoundException("Check install_node.sh asd get_recs_nodes.sh exist in the bin directory ")
}
}
fun installResources() {
try {
logInfo("version: $APP_VERSION")
checkScripts()
loadConfig()
RTMProperties.parsePath("${RTMProperties.basePath}/_resource.conf")
val params = mutableListOf<String>()
Keys.RTM.recs_user.getNullable()?.let { params.add("-u");params.add(it) }
Keys.RTM.recs_password.getNullable()?.let { params.add("-p");params.add(it) }
Keys.RTM.recs_host_src_list.get().forEach {
RECSApiImpl.Instance.loadRECSHosts().forEach {
params.add("-h");params.add(it)
}
val result = runScript("bin/get_recs_nodes.sh", params)
val result = runScript("bin/get_recs_nodes.sh", params, true)
val lines = result.split("\n")
val nodeData = File("resource_map").loadDataTable()
val nodeData = File("resource_map.data").loadDataTable()
lines.forEach {
it.split(";").let {
nodeData[it[0]]?.set("recs_id", it[1])
}
}
val resources = nodeData.filter { nodeRow ->
nodeRow.value["is_active"] ?: "0" == "1"
}.map { nodeRow ->
val cells = nodeRow.value
val nodeId = cells["node_id"]!!
val typeId = cells["type_id"]!!
@Suppress("UNCHECKED_CAST")
install(Resource(nodeId, typeId, null, properties = cells as MutableMap<String, Any>))
}.toList()
DAO.ResourcesManagerApi.saveResourcesToFile(resources)
DAO.ResourcesManagerApi.saveResourcesToFile(resources, false)
val bindToml = generateBindToml(nodeData, Keys.RTM.default_ssh_user.getNullable() ?: "tomaszc")
File("""${RTMProperties.basePath}/bind.sample.toml""").writeText(bindToml)
LightStorage.instance.save(null)
logInfo("End init resources")
} catch (e: Exception) {
......@@ -91,18 +94,18 @@ private fun checkScripts(){
private val installProperties = listOf("RAPL")
private fun install(resource: Resource): Resource {
val params = mutableListOf<String>()
resource.get("ssh_host")?.let { params.add("-u");params.add(it) }
resource.get("ssh_host")?.let { params.add("-h");params.add(it) }
installProperties.forEach { prop ->
resource.get(prop)?.let {
if (it == "1") {
params.add("-p");params.add(it)
params.add("-p");params.add(prop)
}
}
}
val result = runScript("bin/get_recs_nodes.sh", params)
d
runScript("bin/install_node.sh", params, true)
return resource
}
......
package psnc.m2dc.rtm.commands.java
val APP_VERSION = "1.0.556_58610"
\ No newline at end of file
val APP_VERSION = "1.0.624_54345"
\ No newline at end of file
package psnc.m2dc.rtm.client
const val APP_VERSION = "1.1.556_58611"
\ No newline at end of file
const val APP_VERSION = "1.1.624_54346"
\ No newline at end of file
......@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package psnc.m2dc.mock.rtm.rpm;
package psnc.m2dc.mock.rtm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
package psnc.m2dc.mock.rtm.rpm
package psnc.m2dc.mock.rtm
import com.google.gson.Gson
import com.thoughtworks.xstream.XStream
......
package psnc.m2dc.mock.rtm.rpm
package psnc.m2dc.mock.rtm
import com.google.gson.reflect.TypeToken
import org.slf4j.LoggerFactory
......@@ -114,8 +114,8 @@ class SSHApiMock(val resource: Resource) : SSHApi {
},
"gpu_power_limit": {
"${resource.id}_gpu_0":"$gpuMax"
,"${resource.id}_gpu_1":"$gpuMax"
"${resource.id}_gpu_0":"${gpuMax}"
,"${resource.id}_gpu_1":"${gpuMax}"
},
"gpu_util": {
......
package psnc.m2dc.mock.rtm.rpm
package psnc.m2dc.mock.rtm
import org.slf4j.LoggerFactory
import java.util.*
......@@ -85,17 +85,15 @@ class StateMock {
try {
val modelMin = 50f
val modelMax = 250f
val idx = StateMock.getIdx(host)
val minPowerUsage = if ((StateMock.currentPerformance[idx] <= 0.0001f)) 0f else modelMin
if (StateMock.LOW_POWER_MODE) {
val idx = getIdx(host)
val minPowerUsage = if ((currentPerformance[idx] <= 0.0001f)) 0f else modelMin
if (LOW_POWER_MODE) {
val loadPowerUsage = modelMax * StateMock.lowerLoad[idx]/100.0f * StateMock
.currentPerformance[idx] /
val loadPowerUsage = modelMax * lowerLoad[idx]/100.0f * currentPerformance[idx] /
100
res = minPowerUsage + loadPowerUsage
} else {
val loadPowerUsage = modelMax * StateMock.higherLoad[idx]/100.0f * StateMock
.currentPerformance[idx] / 100
val loadPowerUsage = modelMax * higherLoad[idx]/100.0f * currentPerformance[idx] / 100
res = minPowerUsage + loadPowerUsage
}
......