Commit 3a5d805c by Tomasz Ciesielczyk

cache update

parent 2af9ede7
......@@ -22,7 +22,7 @@ abstract class RTMWorker : Runnable {
setting.actions.forEach {
RPMApi.instance().startAction(it)
}
logInfo("${resource.id} cache action: ${setting.toJson()}")
// logInfo("${resource.id} cache action: ${setting.toJson()}")
ActionCache.setPerformance(resource.id, setting.performance, state.nodeMap[resource.id]?.currentProfile)
}
}
......
......@@ -15,7 +15,7 @@ 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.logDebug
import psnc.m2dc.rtm.utils.sum
class PCMApi() {
......@@ -151,8 +151,7 @@ class PCMApi() {
*/
fun getPowerOverLimit(getSparePower: Boolean = false): Pair<Double, Double> {
printConsole("limit details:" + LightStorage.instance.getValue("PCM_POWER_LIMIT")?.type() + " : " + LightStorage.instance.getValue("PCM_POWER_LIMIT")?.get())
logDebug("Power limit:" + LightStorage.instance.getValue("PCM_POWER_LIMIT")?.type() + " : " + LightStorage.instance.getValue("PCM_POWER_LIMIT")?.get())
var totalLimit = StorageKeys.POWER_LIMIT
val map: HashMap<String, Double> = if (this.getPowerCappingStrategy() == PowerCappingStrategy.LAZY) {
RPMApi.instance().getPowerUsageList()
......
......@@ -52,12 +52,11 @@ class PCMWorker(var state: CurrentState) : RTMWorker() {
fun getCurrentState(): PCMState? {
synchronized(lock) {
return currentWorker?.state?.let {
it->
// PCMApi.instance().getPowerLimit()
PCMState(it.currentPowerOverLimit>0,-it.currentPowerOverLimit,it.powerUsage)
return currentWorker?.state?.let { it ->
// PCMApi.instance().getPowerLimit()
PCMState(it.currentPowerOverLimit > 0, -it.currentPowerOverLimit, it.powerUsage)
}
// return currentWorker?.state
// return currentWorker?.state
}
}
......@@ -74,15 +73,14 @@ class PCMWorker(var state: CurrentState) : RTMWorker() {
while (this.currentIteration < MAX_ITERATION && !stop) {
try {
if (this.checkLimits()) {
printConsole("""Current overLimit${this.state.currentPowerOverLimit}""")
printConsole("""Current overLimit:${this.state.currentPowerOverLimit}""")
logInfo("Current power settings: " + ActionCache.toString())
val actions = algorithm.next()
notify(actions)
if (Keys.RTM.debug_actions.get()) {
printConsole(actions.getSettings().toJson())
} else {
println("actioncache: " + ActionCache.toString())
println(" new: " + actions.toJson())
printConsole(" New actions: " + actions.toJson())
startActions(actions, state)
}
this.currentIteration++
......
......@@ -5,6 +5,7 @@ import psnc.m2dc.rtm.esm.ESMApi
import psnc.m2dc.rtm.pcm.ActionPredictor
import psnc.m2dc.rtm.pcm.PCMApi
import psnc.m2dc.rtm.properties.keys.Keys
import psnc.m2dc.rtm.rpm.RPMApi
import psnc.m2dc.rtm.utils.logError
import psnc.m2dc.rtm.utils.logInfo
import psnc.m2dc.rtm.utils.printConsole
......@@ -56,7 +57,7 @@ object RTMScannerWorker {
logInfo("RTM scan start")
while (Keys.RTM.scan_thread.getBoolean() && !stop) {
try {
printConsole("current scan timeout:${Keys.RTM.scan_timeout_ms.getLong()}, counter: $iter ")
// logDebug("current scan timeout: ${Keys.RTM.scan_timeout_ms.getLong()}, counter: $iter ")
val state = PCMApi.Instance.checkLimits()
if (state.limitExceeded) {
PCMApi.Instance.checkState()
......@@ -70,6 +71,7 @@ object RTMScannerWorker {
printConsole("ESM is stopped")
}
}
RPMApi.instance().restartFailedActions()
} catch (e: Exception) {
e.printStackTrace()
......
package psnc.m2dc.rtm.commands.java
val APP_VERSION = "1.0.632_47979"
\ No newline at end of file
val APP_VERSION = "1.0.632_49699"
\ No newline at end of file
package psnc.m2dc.rtm.client
const val APP_VERSION = "1.1.632_47979"
\ No newline at end of file
const val APP_VERSION = "1.1.632_49701"
\ No newline at end of file
......@@ -3,7 +3,8 @@ package psnc.m2dc.rtm.dao
import psnc.m2dc.rtm.model.rest.ResourceActionResult
import psnc.m2dc.rtm.model.rpm.ManagementApi
import psnc.m2dc.rtm.utils.printConsole
import psnc.m2dc.rtm.properties.keys.Keys
import psnc.m2dc.rtm.utils.*
import java.util.*
......@@ -72,7 +73,19 @@ object ActionCache {
fun restartActions(restartCallback: (ResourceActionResult) -> Unit) {
synchronized(this.lock) {
val mRepeatActions = repeatActions
if (!repeatActions.isEmpty()) {
logInfo("Restart actions")
logDebug(repeatActions.values.joinToString(separator = ",", prefix = "[", postfix = "]") {
it.action.toJson()
})
}
val mRepeatActions = repeatActions.filter {
val retry = it.value.failureCounter < Keys.RTM.action_max_retry.get()
if(!retry){
logError("Action disposed, retry counter exceeded: ${it.value.toJson()}")
}
retry
}
repeatActions = HashMap<String, CacheObj>()
mRepeatActions.forEach {
restartCallback(it.value.action)
......@@ -85,6 +98,7 @@ object ActionCache {
val api = DAO.Resource.getResourceManagementMethodApi(action.powerAction, action.resourceId)
this.registerFailure(api, action.resourceId)
repeatActions[action.resultId]?.let {
//overwrite previous action
it.set(action)
} ?: { repeatActions[action.resultId] = CacheObj(action) }()
}
......
......@@ -50,6 +50,7 @@ class RTM {
val load_node_children = RTMProperty(RTM + "load_node_children", false)
val dump_current_state = RTMProperty(RTM + "dump_current_state", false, description = "Dump current RTM's algorithm state to file. ")
val dump_current_state_count = RTMProperty(RTM + "dump_current_state_count", 10, description = "Number of current RTM's algorithm states. (set -1 for infinite) ")
val action_max_retry = RTMProperty(RTM + "action_max_failure", 3, description = "Maximum number of action's retry number ")
}
\ No newline at end of file
......@@ -55,7 +55,7 @@ class RPMApiImpl : RPMApi {
override fun startAction(result: ResourceActionResult, onSuccess: (() -> Unit)?): ResourceActionResult {
logDebug("startaction: " + result.toJson())
logDebug("startaction: " + (Exception().stackTrace.toJson()))
// logDebug("startaction: " + (Exception().stackTrace.toJson()))
val worker = ManagementWorkerImpl(result.resourceId + "_" + result.powerAction.name, { actionTask(result, onSuccess) })
ManagementExecutor.executeTask(worker, TaskExecutor.ExecutionMode.WAIT)
return result
......
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