Commit b0eb163e by Tomasz Ciesielczyk

simple performance api

parent ae8d3b63
......@@ -4,6 +4,8 @@ import psnc.m2dc.rtm.model.rest.ResourceAction
import psnc.m2dc.rtm.model.rpm.ManagementMethodType
import psnc.m2dc.rtm.model.rpm.Resource
import psnc.m2dc.rtm.pcm.algorithm.Utils
import psnc.m2dc.rtm.utils.logDebug
import psnc.m2dc.rtm.utils.toJson
/**
*
......@@ -33,6 +35,7 @@ data class PowerSettings(private val map: Map<Resource, CurrentState.NodeState>)
}
}
}
logDebug("getActions: ${perf} ${result.toJson()}")
return PowerSetting(perf, result)
} ?: throw NullPointerException("Cannot get power action")
......
......@@ -33,7 +33,7 @@ abstract class RTMAlgorithm(currentState: CurrentState) {
val actions = settings.getActions(r)
"${r.id} = ${actions.performance}: ${actions.toJson()}"
}
s.store(RTMProperties.parsePath("${RTMProperties.basePath}/dmp/${this::class.java.simpleName}_$idx.dmp").toString())
s.store(RTMProperties.parsePath("${RTMProperties.basePath}/dmp/${this::class.java.simpleName}_settings_$idx.dmp").toString())
} ?: logWarn("dumpSettings: invalid dump dump_current_state_count: ${Keys.RTM.dump_current_state_count}")
......@@ -127,13 +127,20 @@ abstract class RTMAlgorithm(currentState: CurrentState) {
private fun getSuspendSavings(resourceId: String): Double {
var sum = 0.0
val power = this.getPower(resourceId)
this.state.canSuspend(resourceId)
val canSuspend = this.state.canSuspend(resourceId)
if (canSuspend) {
val typeId = DAO.Resource.getType(resourceId)!!
val model = DAO.Resource.getComponentPowerModel(typeId, null)!!
val savings = power - (model.suspendPowerUsage ?: power)
sum += savings
} else {
//get savings for minimum performance of the unused node
val savings = this.state.eval.getState(resourceId)?.getSavings(0)
if ((savings ?: 0.0) >= 5.0) { //TODO: et 5.0 as property configuration
sum += savings!!
}
val typeId = DAO.Resource.getType(resourceId)!!
val model = DAO.Resource.getComponentPowerModel(typeId, null)!!
val savings = power - (model.suspendPowerUsage ?: power)
// val savings = ManagementMethodType.suspend.getPowerSavings(model, power)
sum += savings
}
return sum
}
......@@ -166,12 +173,6 @@ abstract class RTMAlgorithm(currentState: CurrentState) {
suspendSavings += savings
savingsMap[it.nodeId] = savings
// unusedPowerUsage[it.nodeId]=p
// unusedPowerUsage[it.nodeId] = powerUsage[it.nodeId] ?: {
// logError("Power usage not provided for resource: ${it
// .nodeId}, default power: 0.0!!!"); 0.0
// }.invoke()
}
printConsole("unusedResources suspend savings: " + savingsMap.toJson())
return suspendSavings//this.getSuspendSavings(unusedPowerUsage)
......@@ -182,16 +183,16 @@ abstract class RTMAlgorithm(currentState: CurrentState) {
val node = this.state.nodeMap[nodeUtil.nodeId]!!.node
if (this.state.canSuspend(node.id)) {
// val power = RPMApi.instance().getPowerUsageList()[node.id] ?: {
// logError("Power usage not provided for " +
// "resource: ${node.id}, default power: 0.0!!!"); 0.0
// }.invoke()
val power = this.getPower(node.id)
val model = DAO.Resource.getComponentPowerModel(node.typeId, null)!!
val savings = power - (model.suspendPowerUsage ?: power)
return Pair(node, savings)
} else {
val savings = this.state.eval.getState(node.id)?.getSavings(0) ?: 0.0
if (savings >= 0.5)//TODO: make configurable threshold
return Pair(node, savings)
else null
}
return null
}
......@@ -205,7 +206,11 @@ abstract class RTMAlgorithm(currentState: CurrentState) {
// node to PowerSettings.SUSPEND
node to state.setPerformance(PowerSettings.SUSPEND)
} else if (this.state.canSetPerformance(it.nodeId)) {
node to state.setPerformance(0.0)
logWarn("Cannot suspend")
val savings = this.state.eval.getState(node.id)?.getSavings(0) ?: 0.0
if (savings >= 0.5)//TODO: make configurable threshold
node to state.setPerformance(0.0)
else null
} else
null
......
......@@ -53,6 +53,7 @@ object RTMApi {
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, {
......
......@@ -10,4 +10,4 @@ import psnc.m2dc.rtm.properties.keys.Keys
*/
class ESMSolver(e: Evaluation,algorithm: Algorithm) : Solver(e, SolverMode.esm,
Keys.ESM.power_buffer.get() *
(e.totalCurrentPowerUsage()+Keys.ESM.absolute_power_buffer.get()),algorithm)
(e.totalCurrentPowerUsage())+Keys.ESM.absolute_power_buffer.get(),algorithm)
......@@ -57,7 +57,7 @@ class PCMAlgorithm(state: CurrentState, val algorithm: Solver.Algorithm) : RTMAl
var suspendSavings = unusedResourcesSuspendSavings()
this.state.eval.resetPowerBudget(state.currentPowerOverLimit)
logInfo("PCM poweroverlimit: ${this.state.eval.powerOverLimit}, suspend: $suspendSavings")
logInfo("PCMAlgo poweroverlimit: ${this.state.eval.powerOverLimit}, suspend: $suspendSavings")
if (suspendSavings > this.state.currentPowerOverLimit) {
logInfo("Suspend unused: Stop")
......
......@@ -9,6 +9,6 @@ import psnc.m2dc.rtm.properties.keys.Keys
* Created by Tomek on 2018-06-25.
*/
class PCMSolver(e: Evaluation,algorithm: Algorithm) : Solver(e, SolverMode.pcm,Keys.PCM.power_buffer.get() *
(e.totalCurrentPowerUsage()+Keys.PCM.absolute_power_buffer.get() ),algorithm) {
(e.totalCurrentPowerUsage())+Keys.PCM.absolute_power_buffer.get(),algorithm) {
}
\ No newline at end of file
......@@ -126,7 +126,7 @@ class PCMWorker(var state: CurrentState) : RTMWorker() {
// + ((StorageKeys.POWER_LIMIT ?: 0.0) * Keys.PCM.power_buffer.get()))
this.algorithm.updateState(state)
// this.state.currentPowerOverLimit = -limit.powerBudget.toFloat()
printConsole("update limits:${limits.toJson()} : ${this.state.currentPowerOverLimit} ")
// printConsole("update limits:${limits.toJson()} : ${this.state.currentPowerOverLimit} ")
}
}
......
......@@ -3,7 +3,9 @@ package psnc.m2dc.rtm.pcm.algorithm
import psnc.m2dc.rtm.dao.DAO
import psnc.m2dc.rtm.model.rest.ResourceAction
import psnc.m2dc.rtm.model.rpm.Resource
import psnc.m2dc.rtm.utils.logDebug
import psnc.m2dc.rtm.utils.logError
import psnc.m2dc.rtm.utils.toJson
/**
* Created by Tomek on 2018-07-05.
......@@ -22,6 +24,8 @@ object Utils {
fun getPropertyAction(resource: Resource, perf: Double, profile: String?): List<ResourceAction> {
//TODO: set node id in properties of action
logDebug("getPropertyAction ${resource.id}:${resource.typeId}:${DAO.Resource.getComponentPowerModel(resource.typeId, profile)?.name
?: ""} ${DAO.Resource.getComponentPowerModel(resource.typeId, profile)?.actions?.toJson()}")
return DAO.Resource.getComponentPowerModel(resource.typeId, profile)?.actions?.get(perf)?.map {
ResourceAction(resource.id, it.powerAction, it.properties)
......
......@@ -57,7 +57,7 @@ object RTMScannerWorker {
try {
logInfo("RTM scan start")
var date = Date().time
val restore = {(Date().time - date) > 300000}
val restore = { (Date().time - date) > 300000 }
while (Keys.RTM.scan_thread.getBoolean() && !stop) {
try {
// logDebug("current scan timeout: ${Keys.RTM.scan_timeout_ms.getLong()}, counter: $iter ")
......@@ -74,8 +74,9 @@ object RTMScannerWorker {
printConsole("ESM is stopped")
}
}
RPMApi.instance().restartFailedActions()
if(restore()){
if (iter % 5 == 0)
RPMApi.instance().restartFailedActions()
if (restore()) {
ActionCache.resetPowerSettings()
}
......
package psnc.m2dc.rtm.commands.java
val APP_VERSION = "1.0.634_54798"
\ No newline at end of file
val APP_VERSION = "1.0.646_62289"
\ No newline at end of file
......@@ -40,6 +40,7 @@ abstract class Handlers {
const val api_type = "api_type"
//val priorities = "priorities"
const val node_id_list = "node_id_list"
const val performance = "performance"
}
companion object {
......
......@@ -83,6 +83,8 @@ object HandlersMap {
//#region rtm
const val rtm_current_resource_performance = "/rtm/current_performance/:${Handlers.RESTParams.node_id_list}"
const val rtm_set_current_performance = "/rtm/performance/:${Handlers.RESTParams.performance}/nodes/:${Handlers.RESTParams.node_id_list}"
const val rtm_set_current_performance_profile = "/rtm/performance/:${Handlers.RESTParams.performance}/nodes/:${Handlers.RESTParams.node_id_list}/profile/:${Handlers.RESTParams.power_model_profile_name}"
const val rtm_resource_current_performance_map = "/rtm/current_performance"
//get available performance settings
const val rtm_resource_performance_list = "/rtm/performance/:${Handlers.RESTParams.node_id_list}"
......
......@@ -6,6 +6,7 @@ import psnc.m2dc.rtm.RTMApi
import psnc.m2dc.rtm.RTMServerApi
import psnc.m2dc.rtm.dao.DAO
import psnc.m2dc.rtm.dao.LightStorage
import psnc.m2dc.rtm.model.rpm.ComponentPowerModel
import psnc.m2dc.rtm.model.rpm.ManagementMethodType
import psnc.m2dc.rtm.model.rpm.Resource
import psnc.m2dc.rtm.rest.Handlers
......@@ -13,6 +14,7 @@ import psnc.m2dc.rtm.rest.HandlersMap
import psnc.m2dc.rtm.rest.JsonBuilder
import psnc.m2dc.rtm.rest.RESTExamples
import psnc.m2dc.rtm.rpm.RPMApi
import psnc.m2dc.rtm.utils.logDebug
import spark.Request
import spark.Response
import spark.Spark.get
......@@ -105,6 +107,12 @@ class ResourceHandler : Handlers() {
post(HandlersMap.rtm_current_resource_performance) { req, res ->
instance.setResourcePerformance(req, res)
}
post(HandlersMap.rtm_set_current_performance) { req, res ->
instance.setCurrentPerformance(req, res)
}
post(HandlersMap.rtm_set_current_performance_profile) { req, res ->
instance.setCurrentPerformance(req, res)
}
get(HandlersMap.rtm_current_resource_performance) { req, res ->
instance.getResourcePerformance(req, res)
}
......@@ -533,6 +541,42 @@ class ResourceHandler : Handlers() {
}
}
fun setCurrentPerformance(req: Request, res: Response): String {
return try {
req.logDebug()
val resourceId = req.params(Handlers.RESTParams.node_id_list)
val performance = req.params(Handlers.RESTParams.performance)
val profileName: String? = req.params(Handlers.RESTParams.power_model_profile_name)
val performanceName = ComponentPowerModel.PerformanceSetting.parse(performance)
val jsonBuilder = JsonBuilder()
if (resourceId == "nodes") {
logDebug("list node perf $performance $profileName")
DAO.Resource.getNodes().values.forEach {
val model = DAO.Resource.getComponentPowerModel(it.typeId,profileName)
val perfValue = model!!.findPerformance(performanceName)
RTMApi.setPerformance(it.id, perfValue, profileName)
}
} else {
logDebug("list resource perf $resourceId $performance $profileName")
val nodes = TypeConverters.Resource.convertToList(req, "node_id_list")
nodes!!.forEach { resource ->
val model = DAO.Resource.getComponentPowerModel(resource.typeId,profileName)
val perfValue = model!!.findPerformance(performanceName)
RTMApi.setPerformance(resource.id,perfValue, profileName)
}
}
jsonBuilder.addOK()
jsonBuilder.toJson()
} catch (e: Exception) {
res.status(400)
val jsonBuilder = JsonBuilder().addErr().addMsg(e.message ?: "Unknown error")
Handlers.log.debug("400: Bad request!", e)
jsonBuilder.toJson()
}
}
fun getResourcePerformance(req: Request, res: Response): String {
return try {
req.logDebug()
......
package psnc.m2dc.rtm.client
const val APP_VERSION = "1.1.634_54800"
\ No newline at end of file
const val APP_VERSION = "1.1.646_62289"
\ No newline at end of file
......@@ -7,6 +7,7 @@ import psnc.m2dc.rtm.client.RTMCLI
import psnc.m2dc.rtm.client.RTMRestClient
import psnc.m2dc.rtm.client.utils.debugConsole
import psnc.m2dc.rtm.client.utils.printResult
import psnc.m2dc.rtm.model.rpm.ComponentPowerModel
import psnc.m2dc.rtm.rest.Handlers
import psnc.m2dc.rtm.rest.HandlersMap
import psnc.m2dc.rtm.rest.JsonBuilder
......@@ -21,7 +22,8 @@ class PowerSettingCommand : Runnable {
@CommandLine.Option(names = ["-r", "--resource"], description = ["resource id list or 'nodes' for all nodes"])
private var resourceIdList: List<String>? = null
@CommandLine.Option(names = ["-v", "--value"], description = ["setting value"])
private var settingValue: Double? = null
private var settingValue: String? = null
@CommandLine.Option(names = ["-p", "--profile"], description = ["power model profile for corresponding setting"])
private var profile: String? = null
@CommandLine.Option(names = ["-l", "--list"], description = ["get all available setting value"])
......@@ -30,7 +32,14 @@ class PowerSettingCommand : Runnable {
override fun run() {
parent.run()
if (listAvailable) {
getAvailablePerformance(resourceIdList)?.toJson(true)
getAvailablePerformance(resourceIdList)?.let {
val resourceList = resourceIdList ?: it.values.flatten().toMutableSet()
val m = ComponentPowerModel.PerformanceSetting.values().map {
(it.toString() as Any) to resourceList.toList()
}.toMap()
it.putAll(m)
it.toJson(true)
}
} else if (settingValue == null) {
this.getPerformance(resourceIdList)?.printResult(this.parent.format)
} else if (settingValue != null && resourceIdList != null) {
......@@ -40,7 +49,7 @@ class PowerSettingCommand : Runnable {
}
}
private fun getAvailablePerformance(resId: List<String>?): HashMap<Double, ArrayList<String>>? {
private fun getAvailablePerformance(resId: List<String>?): HashMap<Any, List<String>>? {
debugConsole("getPerformance: ")
var path = HandlersMap.rtm_resource_performance_list.replace(":${Handlers.RESTParams
.node_id_list}", "nodes")
......@@ -66,12 +75,32 @@ class PowerSettingCommand : Runnable {
Handlers.RESTKeys.performance.toString(), RTMRestClient.instance.debug)
}
private fun setPerformance(resId: List<String>, performance: Double, profile: String?): String? {
debugConsole("setPerformance: ")
private fun setPerformance(resId: List<String>, performanceString: String, profile: String?): String? {
val performance = performanceString.toDoubleOrNull()
debugConsole("setPerformance: $performanceString $performance ")
val s = resId.joinToString(",", "", "", -1, "") { it }
val path = HandlersMap.rtm_current_resource_performance.replace(":${Handlers.RESTParams.node_id_list}", s)
return RTMRestClient.instance.connect(path, Connection.Method.POST,
JsonBuilder().addObj(Handlers.RESTKeys.performance, performance).addObj(Handlers.RESTKeys.profile, profile).toJson()).get(
Handlers.RESTKeys.result.toString(), RTMRestClient.instance.debug)
if (performance == null) {
var p: String
if (profile != null) {
p = HandlersMap.rtm_set_current_performance_profile
p = p.replace(":${Handlers.RESTParams.power_model_profile_name}", profile)
} else {
p = HandlersMap.rtm_set_current_performance
}
p=p.replace(":${psnc.m2dc.rtm.rest.Handlers.RESTParams.node_id_list}", s)
.replace(":${Handlers.RESTParams.performance}", performanceString)
debugConsole("setPerformance: $p")
return RTMRestClient.instance.connect(p, Connection.Method.POST,
JsonBuilder().addObj(Handlers.RESTKeys.performance, performance).toJson()).get(
Handlers.RESTKeys.result.toString(), RTMRestClient.instance.debug)
} else {
val path = HandlersMap.rtm_current_resource_performance.replace(":${Handlers.RESTParams.node_id_list}", s)
return RTMRestClient.instance.connect(path, Connection.Method.POST,
JsonBuilder().addObj(Handlers.RESTKeys.performance, performance).addObj(Handlers.RESTKeys.profile, profile).toJson()).get(
Handlers.RESTKeys.result.toString(), RTMRestClient.instance.debug)
}
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ object ActionCache {
fun set(action: ResourceActionResult, onSucces: (() -> Unit)? = null) {
synchronized(this) {
logDebug("testset ${action.resourceId}: ${action.resultId == this.action.resultId}")
if (action.resultId == this.action.resultId) {
this.failureCounter++
} else {
......@@ -79,7 +80,7 @@ object ActionCache {
if (!repeatActions.isEmpty()) {
logInfo("Restart actions")
logDebug(repeatActions.values.joinToString(separator = ",", prefix = "[", postfix = "]") {
it.action.toJson()
it.action.toJson()+ " " +it.failureCounter
})
}
val mRepeatActions = repeatActions.filter {
......@@ -100,6 +101,7 @@ object ActionCache {
synchronized(this.lock) {
val api = DAO.Resource.getResourceManagementMethodApi(action.powerAction, action.resourceId)
this.registerFailure(api, action.resourceId)
logDebug("registerFailure (${action.resultId}):${action.resourceId}: "+ repeatActions[action.resultId])
repeatActions[action.resultId]?.let {
//overwrite previous action
it.set(action)
......
......@@ -102,7 +102,8 @@ class ResourceDAO(val storage: TreeStorage) {
fun getNodes(): Map<String, Resource> {
val obj = LightStorage.getObjectsTree("nodes")
return LightStorage.convert<Resource>(obj).map { it.id to it }.toMap()
val m = LightStorage.convert<Resource>(obj)
return m.map { it.id to it }.toMap()
}
......
......@@ -127,6 +127,7 @@ class ResourceManager : DataDAO() {
}
}
}
logDebug("resource: ${DAO.Resource.getNodes().toJson()}")
logInfo("""resource List after ssh filter: ${DAO.Resource.getNodes().keys.joinToString(separator = "\n", prefix = "\n") { it }}""")
}
......
......@@ -14,7 +14,38 @@ import java.io.File
*/
class ComponentPowerModel(val name: String, private val perfList: List<Double>, private val utilStep: Int =
ComponentPowerModel.DEFAULT_UTIL_STEP, val suspendPowerUsage: Double? = 1.0) {
//TODO: perfIdxMap jest rowne perflist?
enum class PerformanceSetting(val value: Int) {
MIN(0), MIDDLE(1), MAX(2), EFFICIENT(3);
companion object {
fun parse(s: String): PerformanceSetting {
s.toIntOrNull()?.let {
return when (it) {
0 -> MIN
1 -> MIDDLE
2 -> MAX
3 -> EFFICIENT
else -> throw IllegalArgumentException("No enum constant for value PerformanceSetting($s)")
}
}
return valueOf(s)
}
fun parseNull(s: String): PerformanceSetting? {
try {
return this.parse(s)
} catch (ex: IllegalArgumentException) {
return null
}
}
}
}
//#region static
companion object {
const val MAX_PERFORMANCE_LVL = 100.0
......@@ -22,43 +53,20 @@ class ComponentPowerModel(val name: String, private val perfList: List<Double>,
const val HIGH_VALUE = 10000000.0
const val LOW_VALUE = -10000000.0
const val DEFAULT_UTIL_STEP = 5
/**
* value which is considered as a full utilization
*/
const val UTIL_100_VALUE = 95.0
// val POWER_MODEL_FILE_SPEC = """
// /**
// * @param max0 maximum power usage with utilization 0
// * @param max100 maximum power usage with utilization 100
// * @param min0 minimum power usage with utilization 0
// * @param min100 minimum power usage with utilization 100
// */
// min0\tmax0\tmin100\tmax100
// /**
// * @param powerSetting measurement's power setting
// * @param power - power usage
// * @param utilization - 0.0-100.0
// * @param performance - performance - 1.0 -> no power capping
// */
// powerSetting\tpower\tutilization\tperformance
// """.trimIndent()
fun default(defaultName: String): ComponentPowerModel {
val pm = PowerModelDetails(10.0, 11.0, 11.0, 30.0, 1.0, listOf(0.0, 25.0, 50.0, 75.0, 100.0))
val model = ComponentPowerModel(defaultName, pm.perfList, 10)
val powerSpan = pm.max100 - pm.min0
model.setPower(0, 0.0, pm.min0, 0.0, pm.min0)
model.setPower(100, 0.0, pm.max0, 0.0, pm.max0)
model.setPower(0, 100.0, pm.min100, 100.0, pm.min0)
model.setPower(100, 100.0, pm.max100, 100.0, pm.max0)
model.setPower(0, 100.0, pm.min0 + powerSpan * Math.sqrt(0.6), 0.5, pm.min0)
model.setPower(25, 100.0, pm.min0 + powerSpan * Math.sqrt(0.75), 0.7, pm.max0)
model.setPower(50, 100.0, pm.min0 + powerSpan * Math.sqrt(0.9), 0.8, pm.min0)
model.setPower(75, 100.0, pm.min0 + powerSpan * Math.sqrt(1.0), 1.0, pm.min0)
model.setPower(100, 100.0, pm.min0 + powerSpan * Math.sqrt(0.9), 0.95, pm.max0)
return model
}
......@@ -211,16 +219,6 @@ class ComponentPowerModel(val name: String, private val perfList: List<Double>,
}
}
// fun getPowerDetails(powerLimit: Double, utilization: Double = 100.0): PowerMeasurement {
// val limitIdx = this.perfMap[powerLimit]!!
// val utilIdx = getUtilIdx(utilization)
// val minPower = powerUsage[limitIdx][utilIdx.first]
// val maxPower = powerUsage[limitIdx][utilIdx.second]
// val pow = minPower + (maxPower - minPower) * utilIdx.third
// val perf = performance[limitIdx] * utilization
// return PowerMeasurement(powerLimit, utilization, pow, perf)
// }
//#region other
......@@ -228,12 +226,6 @@ class ComponentPowerModel(val name: String, private val perfList: List<Double>,
//#region set powerDetails
// fun setPower(performanceSetting: Int, idlePower: Double, power: Double, performance: Double = 1.0) {
// for (utilization in 0..(this.utilSize - 1)) {
// val util = utilization.toDouble() / (this.utilSize - 1)
// setPower(performanceSetting, util, idlePower, power, performance)
// }
// }
fun setPower(m: PowerMeasurement, idlePower: Double) {
this.setPower(m.powerSetting.toInt(), m.utilization, m.power, m.performance ?: m.powerSetting, idlePower)
......@@ -359,7 +351,7 @@ class ComponentPowerModel(val name: String, private val perfList: List<Double>,
return p
}
// fun getEfficiency(perfLvl0: Double, perfLvlx: Double): Double {
// fun getEfficiency(perfLvl0: Double, perfLvlx: Double): Double {
// // util0: Double, utilx: Double -> not used because it is assumed utilization is linearly dependent to the performance
// val perf0 = this.getPerformance(perfLvl0) //* util0
// val perfx = this.getPerformance(perfLvlx) //* utilx
......@@ -367,6 +359,24 @@ class ComponentPowerModel(val name: String, private val perfList: List<Double>,
// val powx = this.getPower(perfLvlx, 100.0) // utilx)
// return pow0 / powx * perfx / perf0
// }
fun findPerformance(performance: PerformanceSetting?) = when (performance) {
PerformanceSetting.MIN -> 0.0
PerformanceSetting.MAX -> 100.0
PerformanceSetting.MIDDLE -> this.middlePerf()
PerformanceSetting.EFFICIENT -> this.maxEfficiencyPerf()
else -> 100.0
}
private fun middlePerf(): Double {
val avgPerf = this.listActionPerfLvls().average()
val middlePerfValue = this.listActionPerfLvls().minBy { it - avgPerf }!!
return middlePerfValue
}
private fun maxEfficiencyPerf(): Double {
val maxEfficiencyPerf = this.listActionPerfLvls().map { it to this.getEfficiency(it) }.maxBy { it.second }!!
return maxEfficiencyPerf.first
}
fun getEfficiency(perfLvlx: Double): Double {
val perf0 = this.getPerformance(psnc.m2dc.rtm.model.rpm.ComponentPowerModel.MAX_PERFORMANCE_LVL) //* util0
......@@ -450,10 +460,6 @@ class ComponentPowerModel(val name: String, private val perfList: List<Double>,
// }
//#endregion
//#region output
// override fun toString(): String {
// return this.toString(false)
// }
fun toString(printEfficiency: Boolean, printModel: Boolean = true): String {
val sb = StringBuilder()
......
......@@ -35,7 +35,7 @@ $[null] -> empty value"""
val debug = RTMProperty(Default + "debug", false, description = "turn debug mode on/off")
val api_map_file = RTMProperty(Default + "api_map_file", "\$[basePath]/conf/api_map.json", description = "API map file location")
//val test_mode = Default + "test_mode"
val min_active_load = RTMProperty(Default + "min_active_load", 5.0, description = "load border")
val min_active_load = RTMProperty(Default + "min_active_load", 2.0, description = "Min utilization active threshold")
val min_active_component_load = RTMProperty(Default + "min_active_component_load", 10.0, description = "load border")
val parallel_action_execution = RTMProperty(
Default + "parallel_action_execution",
......
......@@ -2,6 +2,7 @@ package psnc.m2dc.rtm.rpm.nativeapi
import psnc.m2dc.rtm.model.rpm.Resource
import psnc.m2dc.rtm.model.rpm.SSHCommand
import psnc.m2dc.rtm.utils.toJson
interface SSHApi {
......@@ -16,7 +17,7 @@ interface SSHApi {
if (host != null && username != null)
return SSHCommand(host, cmd, username, params)
else {
throw Exception("No ssh properties ")
throw Exception("No ssh properties ${resource.properties.toJson()}")
}
}
fun suspend()
......
......@@ -115,8 +115,8 @@ open class SSHApiImpl private constructor(val resource: Resource) : SSHApi {
}
private fun runScript(scriptName: String, params: List<String> = ArrayList()): String {
val mScriptName = if (!scriptName.endsWith(".sh")) scriptName else "$scriptName.sh"
val alias = mScriptName.substring(0, mScriptName.length - 3)
val mScriptName = if (scriptName.endsWith(".sh")) scriptName else "$scriptName.sh"
val alias = mScriptName//TODO: uncomment.substring(0, mScriptName.length - 3)
//First try with system alias
var cmd = getSSHCommand(this.resource, alias, params)
var result = runCommand(cmd)
......
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