Commit ac96f9dc by Tomasz Ciesielczyk

modelmap bugfix

parent 52ff8d48
package psnc.m2dc.rtm
import com.google.gson.reflect.TypeToken
import psnc.m2dc.rtm.commands.java.APP_VERSION
import psnc.m2dc.rtm.dao.DAO
import psnc.m2dc.rtm.dao.LightStorage
import psnc.m2dc.rtm.model.rest.ResourceAction
import psnc.m2dc.rtm.model.rpm.ModelMap
import psnc.m2dc.rtm.model.rpm.Resource
import psnc.m2dc.rtm.properties.RTMProperties
......@@ -17,6 +19,24 @@ object ServerConfInitializer {
fun init() {
try {
var s = """
{"0": {"powerAction": "set_property", "value": "[\"-p\", \"cpu_freq\", \"-p\", \"40\"]"}, "16": {"powerAction": "set_property", "value": "[\"-p\", \"cpu_freq\", \"-p\", \"100\"]"}, "37": {"powerAction": "set_property", "value": "[\"-p\", \"cpu_freq\", \"-p\", \"50\"]"}, "39": {"powerAction": "set_property", "value": "[\"-p\", \"cpu_freq\", \"-p\", \"20\"]"}, "100": {"powerAction": "set_property", "value": "[\"-p\", \"cpu_freq\", \"-p\", \"30\"]"}}
""".trimIndent()
s ="""
{"0": [{
"powerAction": "set_property", "properties": {"value": "[\"-p\", \"rapl\", \"-p\", \"50\"]"}
} ] }
"""
s = """
{"0": [{"resourceId": "", "powerAction": "set_property", "properties": {"value": "[\"-p\", \"rapl\", \"-p\", \"10\"]"}}], "13": [{"resourceId": "", "powerAction": "set_property", "properties": {"value": "[\"-p\", \"rapl\", \"-p\", \"80\"]"}}], "26": [{"resourceId": "", "powerAction": "set_property", "properties": {"value": "[\"-p\", \"rapl\", \"-p\", \"95\"]"}}], "77": [{"resourceId": "", "powerAction": "set_property", "properties": {"value": "[\"-p\", \"rapl\", \"-p\", \"90\"]"}}], "100": [{"resourceId": "", "powerAction": "set_property", "properties": {"value": "[\"-p\", \"rapl\", \"-p\", \"60\"]"}}]}
"""
val parsed = s.fromJson<HashMap<Double, List<ResourceAction>>>(
object : TypeToken<HashMap<Double, List<ResourceAction>>>() {
}.type)
logInfo("version: $APP_VERSION")
loadConfig()
RTMProperties.parsePath("${RTMProperties.basePath}/_resource.conf")
......
package psnc.m2dc.rtm.commands.java
val APP_VERSION = "1.0.519_65027"
\ No newline at end of file
val APP_VERSION = "1.0.519_67629"
\ No newline at end of file
package psnc.m2dc.rtm.client
const val APP_VERSION = "1.1.519_65027"
\ No newline at end of file
const val APP_VERSION = "1.1.519_67629"
\ No newline at end of file
......@@ -164,42 +164,47 @@ object SettingsDAO : DataDAO() {
pm: PowerModelDetails = this.loadPowerModelDetails(f),
defaultUtilization: Double? = null):
ComponentPowerModel {
val name = f.name.substring(0, f.name.length - 3)
val cm = ComponentPowerModel(name, pm.perfList, utilStep, pm.suspendPowerUsage)
cm.setPower(0, 0.0, pm.min0, 0.0, pm.min0)
cm.setPower(100, 0.0, pm.max0, 0.0, pm.max0)
cm.setPower(0, 100.0, pm.min100, 100.0, pm.min0)
cm.setPower(100, 100.0, pm.max100, 100.0, pm.max0)
var first = true
var actions = ""
f.forEachLine { line ->
val lineFields = line.split("\t")
if (first) {
first = false
} else if (!line.startsWith("actions") && actions.isEmpty()) {
cm.setPower(PowerMeasurement.init(
powerSetting = lineFields[0].toDouble(),
modelDetails = pm,
power = lineFields[1].toDoubleOrNull(),
utilization = lineFields[3].toDoubleOrNull() ?: defaultUtilization,
performance = lineFields[2].toDoubleOrNull()
), pm.min0)
} else if (line.startsWith("actions")) {
actions = " "
} else {
actions += line
try {
val name = f.name.substring(0, f.name.length - 3)
val cm = ComponentPowerModel(name, pm.perfList, utilStep, pm.suspendPowerUsage)
cm.setPower(0, 0.0, pm.min0, 0.0, pm.min0)
cm.setPower(100, 0.0, pm.max0, 0.0, pm.max0)
cm.setPower(0, 100.0, pm.min100, 100.0, pm.min0)
cm.setPower(100, 100.0, pm.max100, 100.0, pm.max0)
var first = true
var actions = ""
f.forEachLine { line ->
val lineFields = line.split("\t")
if (first) {
first = false
} else if (!line.startsWith("actions") && actions.isEmpty()) {
cm.setPower(PowerMeasurement.init(
powerSetting = lineFields[0].toDouble(),
modelDetails = pm,
power = lineFields[1].toDoubleOrNull(),
utilization = lineFields[3].toDoubleOrNull() ?: defaultUtilization,
performance = lineFields[2].toDoubleOrNull()
), pm.min0)
} else if (line.startsWith("actions")) {
actions = " "
} else {
actions += line
}
}
if (actions.length > 2) {
// printConsole(actions)
val parsed = actions.fromJson<HashMap<Double, List<ResourceAction>>>(
object : TypeToken<HashMap<Double, List<ResourceAction>>>() {
}.type)
cm.addActions(parsed)
}
cm.updateModel()
return cm
} catch (e: Exception) {
logError(e, "Cannot load model ${f.name}. ")
throw e.cause ?: e
}
if (actions.length > 2) {
val parsed = actions.fromJson<HashMap<Double, List<ResourceAction>>>(
object : TypeToken<HashMap<Double, List<ResourceAction>>>() {
}.type)
cm.addActions(parsed)
}
cm.updateModel()
return cm
}
}
\ No newline at end of file
......@@ -80,10 +80,11 @@ abstract class ResourceActionBase {
}
data class ResourceAction(override val resourceId: String, override val powerAction: ManagementMethodType,
data class ResourceAction(override val resourceId: String ="", override val powerAction: ManagementMethodType,
override val properties: HashMap<String, String> = HashMap<String, String>()) :
ResourceActionBase() {
constructor(resourceId: String, powerAction: ManagementMethodType, vararg pairs: Pair<String, String>) : this(
resourceId,
powerAction) {
......
......@@ -670,7 +670,7 @@ object ModelMap {
val typeName = s[0]
val profileName = s[1]
val typeMap = map[typeName] ?: HashMap<String, ComponentPowerModel>()
typeMap[profileName] = SettingsDAO.model_map.get(modelName)
typeMap[profileName] = SettingsDAO.model_map.get("${typeName}_${profileName}")
map[typeName] = typeMap
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment