Commit c847ed32 by Tomasz Ciesielczyk

removed old storage

parent 40d23269
......@@ -13,7 +13,8 @@ import psnc.m2dc.rtm.utils.toJson
*/
object ActionCache {
data class Setting(val performance:Double,val profile:String?)
data class Setting(val performance: Double, val profile: String?)
//#region properties
private val lock = Any()
// /**
......@@ -27,18 +28,30 @@ 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()
}
//#region performance cache
fun setPerformance(resourceId: String, performance: Double, profile: String? /* = null*/) {
synchronized(this.lock) {
// printConsole(LightStorage.instance.listIndex("PCM_PERFORMANCE_SETTINGS")!!.toJson())
if(resourceId.length<3){
(Exception().printStackTrace())
throw NullPointerException("short id")
}
StorageKeys.PERFORMANCE_SETTINGS[resourceId] = performance
if (profile != null) {
StorageKeys.PROFILE_MAP[resourceId] = profile
} else {
StorageKeys.PROFILE_MAP.delete(resourceId)
}
// printConsole(LightStorage.instance.listIndex("PCM_PERFORMANCE_SETTINGS")!!.toJson())
// this.currentPerformance[resourceId] = performance
// RTMProperties.storage.put(StorageKeys.PERFORMANCE_SETTINGS, this.currentPerformance)
......@@ -53,12 +66,13 @@ object ActionCache {
//fun isPerformanceChange(resourceId: String): Boolean = currentPerformance[resourceId]?.let { true } ?: false
fun getState(resourceId: String): Setting= synchronized(lock) {
return Setting(StorageKeys.PERFORMANCE_SETTINGS[resourceId]?:100.0, StorageKeys.PROFILE_MAP[resourceId])
fun getState(resourceId: String): Setting = synchronized(lock) {
return Setting(StorageKeys.PERFORMANCE_SETTINGS[resourceId] ?: 100.0, StorageKeys.PROFILE_MAP[resourceId])
}
fun getPerformanceSetting(resourceId: String): Double = synchronized(lock) {
return StorageKeys.PERFORMANCE_SETTINGS[resourceId] ?: 100.0
}
fun getProfile(resourceId: String): String? = synchronized(lock) {
......
......@@ -17,8 +17,8 @@ import kotlin.collections.HashMap
* param: aheadBuffer -> length of the predicted load in minutes which is taken into consideration in the node
* priority
*/
class CurrentState(val powerUsage: Double, rcuUtil: RCUUtil/*, private val workload: Workload? = null*/) {
data class NodeState(val node: Resource, val powerUsage: Double, val currentPerformance: Double, val currentProfile: String?, private var newPerformance: Double = currentPerformance) {
class CurrentState(val powerUsage: Double) {
data class NodeState(val node: Resource, val powerUsage: Double, private val currentPerformance: Double, val currentProfile: String?, private var newPerformance: Double = currentPerformance) {
val performance get() = this.newPerformance
fun setPerformance(newPerformance: Double): NodeState {
this.newPerformance = newPerformance
......@@ -27,7 +27,6 @@ class CurrentState(val powerUsage: Double, rcuUtil: RCUUtil/*, private val workl
}
private val lock = Any()
/**
* contains only active nodes
......@@ -40,7 +39,6 @@ class CurrentState(val powerUsage: Double, rcuUtil: RCUUtil/*, private val workl
val unusedMachines: ArrayList<NodeUtil> = ArrayList()
private var activeMachines: ArrayList<NodeUtil> = ArrayList()
private val currentUtil: HashMap<String, NodeUtil> = HashMap()
/**
* filtered node resources Map
......@@ -50,33 +48,38 @@ class CurrentState(val powerUsage: Double, rcuUtil: RCUUtil/*, private val workl
//#region initialization
init {
try {
rcuUtil.filter(this.currentTimeInterval).forEach({
this.currentUtil[it.nodeId] = it
val currentUtil: HashMap<String, NodeUtil> = HashMap()
DAO.Chassis.getNodeUtil(this.currentTimeInterval).forEach({
if (currentUtil[it.nodeId]?.timeInterval?.compareTo(it.timeInterval) ?: 0 < 0) {
currentUtil[it.nodeId] = it
}
})
val powerMap = RPMApi.instance().getPowerUsageList()
DAO.Resource.getNodes().values.forEach({ node ->
val power = powerMap[node.id] ?: {
val nodeUtil = currentUtil[node.id]
val power = nodeUtil?.powerUsage ?: powerMap[node.id] ?: {
logError("Power Usage not provided for ${node.id}");0.0
}.invoke()
printConsole("xxx: power for${node.id}= $power")
val currentPerf = ActionCache.getPerformanceSetting(node.id)
val currentProfile = ActionCache.getProfile(node.id)
val currentProfile = nodeUtil?.loadProfile ?: ActionCache.getProfile(node.id)
nodeMap[node.id] = NodeState(node, power, currentPerf, currentProfile)
val model = DAO.Resource.getComponentPowerModel(node.typeId, null)!!
val util = if (PCMApi.instance().getPowerCappingStrategy() == PowerCappingStrategy.EAGER)
100.0
else
model.getUtil(power, currentPerf)
val nodeUtil = NodeUtil(node.id, util, null, null, currentTimeInterval)
if (nodeUtil.isInUse(currentTimeInterval)) {
this.activeMachines.add(nodeUtil)
nodeUtil?.utilization ?: model.getUtil(power, currentPerf)
printConsole("util for: ${node.id}- $util/$power")
val newNodeUtil = NodeUtil(node.id, util, power, currentProfile, null, currentTimeInterval)
currentUtil[node.id] = newNodeUtil
if (newNodeUtil.isInUse(currentTimeInterval)) {
this.activeMachines.add(newNodeUtil)
val priority = StorageKeys.NODE_PRIORITIES_MAP[node.id]?.weight ?: 0.5
val state = StateDefinition(model, util, power, currentPerf, priority)
if (this.canSetPerformance(node.id))
eval.addState(node.id, state)
} else {
this.unusedMachines.add(nodeUtil)
this.unusedMachines.add(newNodeUtil)
}
})
......@@ -155,7 +158,7 @@ class CurrentState(val powerUsage: Double, rcuUtil: RCUUtil/*, private val workl
if (c != 0) {
c
} else {
compareValues(u1.cpuUtilization, u2.cpuUtilization)
compareValues(u1.utilization, u2.utilization)
// if (c != 0 && this.workload != null) {
// 0
// } else {
......@@ -180,7 +183,7 @@ class CurrentState(val powerUsage: Double, rcuUtil: RCUUtil/*, private val workl
}
if (c == 0) {
compareValues(u1.cpuUtilization, u2.cpuUtilization)
compareValues(u1.utilization, u2.utilization)
} else {
......
package psnc.m2dc.rtm
import org.jsoup.Connection
import org.jsoup.Jsoup
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
import psnc.m2dc.rtm.utils.toJson
/**
......@@ -27,10 +29,18 @@ abstract class RTMWorker : Runnable {
protected fun notify(actions: PowerSettings) {
if (Keys.PCM.notification_endpoint.getNullable() != null) {
val endpoint = Keys.PCM.notification_endpoint.get()
// TODO:send notification instead of println
printConsole("TODO: notify($endpoint): ${actions.getSettings()}")
try {
Keys.PCM.notification_endpoint.getNullable()?.let { endpoint ->
logInfo("Action notify: $endpoint")
Jsoup.connect(endpoint).method(Connection.Method.POST).requestBody(actions.getSettings().toJson()).execute()
}
} catch (e: Exception) {
logError(e, "Power Action notification error")
}
}
}
abstract fun stop()
}
\ No newline at end of file
......@@ -4,7 +4,6 @@ package psnc.m2dc.rtm.esm
import org.slf4j.LoggerFactory
import psnc.m2dc.rtm.CurrentState
import psnc.m2dc.rtm.StorageKeys
import psnc.m2dc.rtm.dao.DAO
import psnc.m2dc.rtm.model.rest.ESMPowerPolicy
import psnc.m2dc.rtm.properties.keys.Keys
import psnc.m2dc.rtm.rpm.RPMApi
......@@ -49,7 +48,7 @@ class ESMApi {
fun optimize(): Boolean {
try {
val powerUsage = RPMApi.instance().getPowerUsageList().sum()
val state = CurrentState(powerUsage * (1 + Keys.PCM.power_buffer.get()), DAO.Chassis.getRCUUtil())
val state = CurrentState(powerUsage * (1 + Keys.PCM.power_buffer.get()))//, DAO.Chassis.getRCUUtil())
printConsole("testx $state")
ESMWorker.start(state)
return true
......
......@@ -9,11 +9,13 @@ import psnc.m2dc.rtm.StorageKeys
import psnc.m2dc.rtm.dao.DAO
import psnc.m2dc.rtm.model.rest.*
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.RPMApi
import psnc.m2dc.rtm.utils.Timer
import psnc.m2dc.rtm.utils.printConsole
import psnc.m2dc.rtm.utils.sum
import psnc.m2dc.rtm.utils.toJsonObj
class PCMApi() {
//#region initialize INSTANCE
......@@ -125,6 +127,32 @@ class PCMApi() {
fun getCurrentState(): Any = PCMWorker.getCurrentState() ?: this.checkLimits()
fun predictPCMActions(): PredictedActionList {
val powerUsage = RPMApi.instance().getPowerUsage()
val maxPower = Math.max(DAO.Resource.getMaximumPowerUsage() ?: 0.0, powerUsage)
val currentLimit = this.getPowerLimit() ?: maxPower
val pcmBuffer = currentLimit * Keys.PCM.power_buffer.get() + Keys.PCM.absolute_power_buffer.get()
val finalPowerLimit = currentLimit - (pcmBuffer)
val result = PredictedActionList()
val maximumPowerIncrease = maxPower - powerUsage
val powercapRatio = maxPower - currentLimit
var minPower = finalPowerLimit
listOf(0.1, 0.15, 0.15).forEach { lvl ->
val powerSpan = Math.min(lvl * maximumPowerIncrease, lvl * powercapRatio)
powerUsage + pcmBuffer
val state = CurrentState(pcmBuffer + powerSpan + minPower)
val algoResult = PCMAlgorithm(state).next()
val toList = algoResult.getResources().map { resource ->
resource.id to algoResult.getActions(resource)
}
val p = PredictedAction(minPower, minPower + powerSpan, toList)
minPower += powerSpan
result.list.add(p)
}
return result
}
fun checkState(): Boolean {
val limits = this.checkLimits()
......@@ -132,8 +160,7 @@ class PCMApi() {
if (limits.limitExceeded) {// || Keys.PCM.simple_performance_restore.get()) {
Timer.start()
val state = CurrentState(limits.currentPowerUsage +
((StorageKeys.POWER_LIMIT ?: 0.0) * Keys.PCM.power_buffer.get()),
DAO.Chassis.getRCUUtil())
((StorageKeys.POWER_LIMIT ?: 0.0) * Keys.PCM.power_buffer.get()))
Timer.stop()
PCMWorker.start(state)
......@@ -223,6 +250,41 @@ class PCMApi() {
return Pair(0.0, totalUsage)
}
class PredictedActionList(val list: ArrayList<PredictedAction> = ArrayList()) {
fun generateScripts() {
val sb = StringBuilder()
this.list.forEach {
sb.append(it.minPower).append(":").append(it.maxPower).append("\n")
printConsole(it.toScript())//printfile
}
printConsole(sb.toString())
}
}
class PredictedAction(val minPower: Double, val maxPower: Double, val actionList: List<Pair<String, PowerSettings.PowerSetting>> = ArrayList()) {
fun toScript(): String {
val sb = StringBuilder()
this.actionList.forEach { resourceDetails ->
val resourceId = resourceDetails.first
val performance = resourceDetails.second.performance
val actionList = resourceDetails.second.actions
sb.append(resourceId).append(":").append(performance).append("\n")
actionList.forEach { action ->
val actionValue = action.properties[ResourceAction.PROPERTY_ACTION_VALUE]
val obj = RTMProperties.JSONParser.fromJson(actionValue, Any::class.java)?.toJsonObj()
if (obj != null && obj.isJsonArray) {
val s = obj.asJsonArray.map { it.toString() }.joinToString(separator = " ") { it }
sb.append(s).append("\n")
}
}
}
return sb.toString()
}
}
// private fun getMaxPowerUsage(): Double? {
// return this.getMaxPowerUsageList().sum()
......
......@@ -4,7 +4,6 @@ import psnc.m2dc.rtm.ActionCache
import psnc.m2dc.rtm.CurrentState
import psnc.m2dc.rtm.RTMWorker
import psnc.m2dc.rtm.StorageKeys
import psnc.m2dc.rtm.dao.DAO
import psnc.m2dc.rtm.esm.ESMWorker
import psnc.m2dc.rtm.properties.keys.Keys
import psnc.m2dc.rtm.utils.Timer
......@@ -76,7 +75,8 @@ class PCMWorker(var state: CurrentState) : RTMWorker() {
printConsole(actions.getSettings().toJson())
} else {
println("actioncache: " + ActionCache.toString() + " new: " +actions.toJson())
println("actioncache: " + ActionCache.toString())
println(" new: " +actions.toJson())
startActions(actions, state)
}
this.currentIteration++
......@@ -118,10 +118,8 @@ class PCMWorker(var state: CurrentState) : RTMWorker() {
synchronized(lock) {
val limits = PCMApi.instance().checkLimits()
this.state = CurrentState(limits.currentPowerUsage.toFloat() +
((StorageKeys.POWER_LIMIT ?: 0.0) * Keys.PCM.power_buffer.get()),
DAO.Chassis.getRCUUtil())
((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} ")
}
......
package psnc.m2dc.rtm
import psnc.m2dc.rtm.dao.LightStorage
import psnc.m2dc.rtm.esm.ESMApi
import psnc.m2dc.rtm.pcm.PCMApi
import psnc.m2dc.rtm.properties.keys.Keys
......@@ -56,9 +57,15 @@ object RTMScannerWorker {
val state = PCMApi.instance().checkLimits()
if (state.limitExceeded) {
PCMApi.instance().checkState()
LightStorage.saveStorage()
iter = 0
} else if (iter > esmRatio) {
ESMApi.instance().optimize()
} else if (iter > esmRatio ) {
if(Keys.ESM.status.get()) {
ESMApi.instance().optimize()
}
else{
printConsole("ESM is stopped")
}
}
} catch (e: Exception) {
......
......@@ -3,19 +3,16 @@ package psnc.m2dc.rtm
import psnc.m2dc.rtm.commands.java.APP_VERSION
import psnc.m2dc.rtm.dao.DAO
import psnc.m2dc.rtm.dao.LightStorage
import psnc.m2dc.rtm.data.ReloadTask
import psnc.m2dc.rtm.esm.ESMApi
import psnc.m2dc.rtm.model.rest.NodePriority
import psnc.m2dc.rtm.model.rest.Values
import psnc.m2dc.rtm.model.rpm.ModelMap
import psnc.m2dc.rtm.pcm.PCMApi
import psnc.m2dc.rtm.properties.keys.Keys
import psnc.m2dc.rtm.rest.Handlers
import psnc.m2dc.rtm.rest.auth.RESTAuth
import psnc.m2dc.rtm.rpm.RPMApiImpl
import psnc.m2dc.rtm.utils.Timer
import psnc.m2dc.rtm.utils.logError
import psnc.m2dc.rtm.utils.logInfo
import psnc.m2dc.rtm.utils.setWatch
import psnc.m2dc.rtm.utils.*
import spark.Spark
/**
......@@ -30,10 +27,14 @@ object ServerInitializer {
loadResources()
PCMApi.init()
ESMApi.init()
setDefaultPriorities()
save()
StorageKeys.POWER_LIMIT = Values.powerLimit(440.0)
val a =PCMApi.instance().predictPCMActions()
a.generateScripts().toJson(true)
setScanner()
ReloadTask.start()
// ReloadTask.start()
if (Keys.Default.use_ssl.get()) {
Spark.secure(Keys.Default.keystore_path.get(), Keys.Default.keystore_password.get(), null, null)
}
......
package psnc.m2dc.rtm.commands.java
val APP_VERSION = "1.0.416_58770"
\ No newline at end of file
val APP_VERSION = "1.0.424_61797"
\ No newline at end of file
......@@ -4,7 +4,6 @@ import com.google.gson.JsonObject
import com.google.gson.reflect.TypeToken
import org.slf4j.LoggerFactory
import psnc.m2dc.rtm.model.rest.*
import psnc.m2dc.rtm.model.rpm.ResourceType
import psnc.m2dc.rtm.properties.RTMProperties
import psnc.m2dc.rtm.rest.handlers.EnergySaverHandler
import psnc.m2dc.rtm.rest.handlers.ManagementHandlers
......@@ -23,7 +22,7 @@ abstract class Handlers {
rcuUtil, timeinterval, nodes, temperature, sensor, sensors, powerBuffer, policy, strategy, powerLimit, state,
resource_id_list, resource_id,
nodePriorities, performance, workload, node_model, result, power, resource_type, power_model, node_type,
time_interval_points, temperature_limit_list, settings, profile
time_interval_points, temperature_limit_list, settings, profile,node_util
}
object RESTParams {
......@@ -105,11 +104,15 @@ abstract class Handlers {
protected fun getRCUUtil(jo: JsonObject): RCUUtil? = this.getObject(jo, RESTKeys.rcuUtil)
protected fun getNodeUtil(jo: JsonObject): ArrayList<NodeUtil> = this.getObject(jo, RESTKeys
.node_util, object : TypeToken<ArrayList<NodeUtil>>() {}.type) ?: throw NullPointerException(
"node utils parameter not found")
protected fun getTimeInterval(jo: JsonObject): TimeInterval? = this.getObject(jo, RESTKeys.timeinterval)
protected fun getResourceType(jo: JsonObject): ResourceType = this.getObject(jo, RESTKeys.resource_type)
?: throw NullPointerException("resource_type parameter not " +
"found")
// protected fun getResourceType(jo: JsonObject): ResourceType = this.getObject(jo, RESTKeys.resource_type)
// ?: throw NullPointerException("resource_type parameter not " +
// "found")
protected fun getNodeList(jo: JsonObject): ArrayList<String> = this.getObject(jo, RESTKeys.nodes)
?: throw NullPointerException("nodes parameter not found")
......@@ -126,8 +129,8 @@ abstract class Handlers {
protected fun getSensor(jo: JsonObject): String = this.getObject(jo, RESTKeys.sensor) ?: throw NullPointerException(
"sensor parameter not found")
protected fun getPowerBuffer(jo: JsonObject): Double = Values.powerBuffer(this.getObject(jo, RESTKeys.powerBuffer))
//
// protected fun getPowerBuffer(jo: JsonObject): Double = Values.powerBuffer(this.getObject(jo, RESTKeys.powerBuffer))
protected fun getPCPowerPolicy(jo: JsonObject): PowerCappingMode = this.getObject(jo, RESTKeys.policy)
?: throw NullPointerException("policy parameter not found")
......@@ -152,11 +155,7 @@ abstract class Handlers {
?: throw NullPointerException("performance parameter not found")
protected fun getProfile(jo: JsonObject): String? = this.getObject(jo, RESTKeys.profile)
// protected fun getWorkload(jo: JsonObject): Workload = this.getObject(jo, RESTKeys.workload)
// ?: throw NullPointerException("workload parameter not found")
protected fun getNodeType(jo: JsonObject): ResourceType = this.getObject(jo, RESTKeys.node_type)
?: throw NullPointerException("node_type parameter not found")
protected fun getTimeIntervals(jo: JsonObject): List<TimeInterval> = this.getObject(jo,
RESTKeys.time_interval_points, object : TypeToken<ArrayList<TimeInterval>>() {}.type)
......
......@@ -71,6 +71,7 @@ object HandlersMap {
.RESTParams.metadata_value}"
val get_node_metadata = "/node/metadata/:${Handlers.RESTParams.node_id}/:${Handlers.RESTParams.metadata_key}"
val node_util = "/node/util/:${Handlers.RESTParams.node_id_list}"
val node_sensor_list = "/node/sensor/:${Handlers.RESTParams.node_id_list}"
val nodes_sensor_value = "/node/sensor/:${Handlers.RESTParams.node_id_list}/:${Handlers.RESTParams.sensor_id}"
val nodes_sensor_type_value = "/node/sensor/type/:${Handlers.RESTParams.node_id_list}/:${Handlers.RESTParams
......
......@@ -4,8 +4,8 @@ import org.slf4j.LoggerFactory
import psnc.m2dc.rtm.RTMApi
import psnc.m2dc.rtm.StorageKeys
import psnc.m2dc.rtm.dao.DAO
import psnc.m2dc.rtm.dao.LightStorage
import psnc.m2dc.rtm.pcm.PCMApi
import psnc.m2dc.rtm.properties.RTMProperties
import psnc.m2dc.rtm.rest.Handlers
import psnc.m2dc.rtm.rest.HandlersMap
import psnc.m2dc.rtm.rest.JsonBuilder
......@@ -48,7 +48,7 @@ class ManagementHandlers : Handlers() {
val jb = JsonBuilder()
jb.addObj(RESTKeys.state,
hashMapOf(
"storage_size" to RTMProperties.storage.listKeys().size,
"storage_size" to LightStorage.size(),
"node_count" to DAO.Resource.getNodes().size,
"resource_count" to DAO.Resource.getResources().size,
"power_limit" to PCMApi.instance().getPowerLimit(),
......@@ -86,7 +86,8 @@ class ManagementHandlers : Handlers() {
return try {
req.logDebug()
val jb = JsonBuilder()
RTMProperties.storage.save()
// RTMProperties.storage.save()
LightStorage.saveStorage()
jb.addOK()
jb.toJson()
} catch (e: Exception) {
......
......@@ -7,7 +7,6 @@ import psnc.m2dc.rtm.dao.DAO
import psnc.m2dc.rtm.model.rpm.ManagementMethodType
import psnc.m2dc.rtm.model.rpm.Resource
import psnc.m2dc.rtm.pcm.PCMApi
import psnc.m2dc.rtm.properties.RTMProperties
import psnc.m2dc.rtm.rest.Handlers
import psnc.m2dc.rtm.rest.HandlersMap
import psnc.m2dc.rtm.rest.JsonBuilder
......@@ -93,6 +92,12 @@ class ResourceHandler : Handlers() {
get(HandlersMap.node_rcuutil) { req, res ->
ResourceHandler.instance.getRcuUtil(req, res)
}
post(HandlersMap.node_util) { req, res ->
ResourceHandler.instance.setNodeUtil(req, res)
}
get(HandlersMap.node_util) { req, res ->
ResourceHandler.instance.getNodeUtil(req, res)
}
get(HandlersMap.resource_list) { req, res ->
ResourceHandler.instance.listResources(req, res)
}
......@@ -206,7 +211,6 @@ class ResourceHandler : Handlers() {
}
private fun setResourcesType(req: Request, res: Response): String {
//TODO: test
return try {
val resource = URLHelper.getResource(req)
val resourceType = URLHelper.getResourceType(req)
......@@ -438,8 +442,9 @@ class ResourceHandler : Handlers() {
val jo = RTMApi.getJsonObj(req.body())
val rcu = getRCUUtil(jo)!!
val ttl = rcu.timeInterval.ttl() - 300 //5 min
RTMProperties.storage.put("RCU_UTIL", rcu, ttl * 1000)
RTMProperties.storage.save()
DAO.Chassis.addRCUUtil(rcu)
// RTMProperties.storage.put("RCU_UTIL", rcu, ttl * 1000)
// RTMProperties.storage.save()
RESTExamples.OK_RESPONSE
} catch (e: Exception) {
res.status(400)
......@@ -463,6 +468,40 @@ class ResourceHandler : Handlers() {
}
}
fun getNodeUtil(req: Request, res: Response): String {
return try {
req.logDebug()
val jo = RTMApi.getJsonObj(req.body())
val timeInterval = this.getTimeInterval(jo)
val nodeUtil = if (timeInterval != null) {
DAO.Chassis.getNodeUtil(timeInterval)
} else
DAO.Chassis.getNodeUtil()
val jb = JsonBuilder()
jb.addObj(RESTKeys.node_util.toString(), nodeUtil)
jb.toJson()
} catch (e: Exception) {
res.status(400)
Handlers.log.debug("400: Bad request!", e)
"Bad request!" + e.message
}
}
fun setNodeUtil(req: Request, res: Response): String {
return try {
req.logDebug()
val jo = RTMApi.getJsonObj(req.body())
val nodeUtils = this.getNodeUtil(jo)
DAO.Chassis.addNodeUtil(nodeUtils)
JsonBuilder().addOK().toJson()
} catch (e: Exception) {
res.status(400)
Handlers.log.debug("400: Bad request!", e)
"Bad request!" + e.message
}
}
fun setResourcePerformance(req: Request, res: Response): String {
return try {
req.logDebug()
......@@ -473,12 +512,12 @@ class ResourceHandler : Handlers() {
val profile = this.getProfile(jo)
if (resourceId == "nodes") {
DAO.Resource.getNodes().values.forEach {
PCMApi.instance().setPerformance(it.id, performance.toDouble(),profile)
PCMApi.instance().setPerformance(it.id, performance.toDouble(), profile)
}
} else {
val nodes = TypeConverters.Resource.convertToList(req, "node_id_list")
nodes!!.forEach { resource ->
PCMApi.instance().setPerformance(resource.id, performance.toDouble(),profile)
PCMApi.instance().setPerformance(resource.id, performance.toDouble(), profile)
}
}
jsonBuilder.addOK()
......@@ -507,7 +546,7 @@ class ResourceHandler : Handlers() {
}
else -> {
val nodes = TypeConverters.Resource.convertToList(req, "node_id_list")
val map = HashMap<String,ActionCache.Setting>()
val map = HashMap<String, ActionCache.Setting>()
nodes!!.forEach { resource ->
val performance = ActionCache.getState(resource.id)
map[resourceId] = performance
......
package psnc.m2dc.rtm.client
const val APP_VERSION = "1.1.424_39667"
\ No newline at end of file
const val APP_VERSION = "1.1.424_61798"
\ No newline at end of file
[default]
## sample property replacement
## timeout = 5000
## custom_message = $[timeout]
## global keys: $[basePath]
## $[null] empty value
test_path = D:/Temp
#keystone, no_auth, basic (username,password), token - @see token_auth section for more details
auth_type = basic
port = 9000
#test_mode = review_1
#log4j conf file
#log_configuration_file = <none>
log_configuration_file = $[default.test_path]/log4j.properties
#log_location = <none>
#available drivers : file (@see [file_storage] section)
#data_store_driver = file
data_store_driver = file
#private_key_file =
private_key_file = $[default.test_path]/private_key_2048.pem
#private_key_file =
public_key_file = $[default.test_path]/public_key_2048.pem
#use socks 5 proxy
use_proxy = true
proxy_host = localhost
proxy_port = 9000
password = some_secret_password
test_resource_list = xeon_12
parallel_action_execution = false
#mock_list =
# SSH, RECS, IPMI
mock_list = SSH, IPMI, RECS
debug = true
sensor_map_file = $[default.test_path]/sensor_map.json
[token_auth]
#token timeout - time in seconds for token's lifetime
#token_timeout = 300
token_timeout = 36000
token_issuer = RTM
[auth]
password = admin
username = admin
#
#user_data_location = <path to user data>
user_data_location = $[default.test_path]/users.conf
#jwks_file_host = <path to JWK store>
[keystone_auth]
admin_password = "admin_password"
admin_user = "admin_user"
auth_uri = "auth_uri"
domain = "domain"
[esm]
auto_perform_actions = true
[rpm]
use_local_storage = false
#resources_src_list = FILE, RECS
#metadata file
resources_src_list = RECS
#remote_script_location = /usr/bin/rtm/bin
#remote_script_location = ~/rtm/bin
remote_script_location = /home/$user/rtm/bin
# recs_host_src_list = LDAP, FILE (TOD O), CONF/CONFIG( @see psnc.recs_hosts)
recs_host_src_list = CONFIG
#recs_hosts_file= $[default.test_path]/recs_hosts.conf
#recs_hosts = 192.168.1.1,192.168.1.1
#recs_hosts = 192.168.13.50
recs_hosts = 10.11.12.246
#CALLBACK, USER, OPERATOR, ADMINISTRATOR
ipmi_privilage_lvl = OPERATOR
ipmi_user = tomaszc
ipmi_password = tomek1234!
resource_metadata_file = $[default.test_path]/resources.conf
resource_model_directory = $[default.test_path]/models
#recs_host_filter =
recs_node_filter = RCU_86659187833_BB_1_0, RCU_86659187833_BB_2_0, RCU_86659187833_BB_3_0, RCU_86659187833_BB_4_0, RCU_86659187833_BB_5_0
#host_block_filter =
#node_block_filter =
[file_storage]
storage_location = $[default.test_path]/rtmserver.conf
#it is better to leave this value null
#default_key_timeout = 1800000
#default_key_timeout =
#timeout miliseconds
object_long_timeout = 3600000