Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions piflow-server/src/main/scala/cn/piflow/api/API.scala
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,23 @@ object API {
val matricInfo = MapUtil.get(yarnInfo, "clusterMetrics").asInstanceOf[Map[String, Any]]


val totalVirtualCores = matricInfo.getOrElse("totalVirtualCores","");
val allocatedVirtualCores = matricInfo.getOrElse("allocatedVirtualCores","")
val remainingVirtualCores = totalVirtualCores.toString.toDouble - allocatedVirtualCores.toString.toDouble;
val totalVirtualCores = matricInfo.getOrElse("totalVirtualCores","").toString
val allocatedVirtualCores = matricInfo.getOrElse("allocatedVirtualCores","").toString
val remainingVirtualCores = totalVirtualCores.toDouble - allocatedVirtualCores.toDouble
val cpuInfo = Map(
"totalVirtualCores" -> totalVirtualCores,
"allocatedVirtualCores" -> allocatedVirtualCores,
"remainingVirtualCores" -> remainingVirtualCores
)

val totalMemoryGB = matricInfo.getOrElse("totalMB","").toString.toDouble/1024;
val allocatedMemoryGB = matricInfo.getOrElse("allocatedMB","").toString.toDouble/1024;
val remainingMemoryGB = totalMemoryGB - allocatedMemoryGB;
val totalMemoryGB = matricInfo.getOrElse("totalMB","").toString.toDouble/1024
val allocatedMemoryGB = matricInfo.getOrElse("allocatedMB","").toString.toDouble/1024
val remainingMemoryGB = totalMemoryGB - allocatedMemoryGB
val memoryInfo = Map(
"totalMemoryGB" -> totalMemoryGB,
"allocatedMemoryGB" -> allocatedMemoryGB,
"remainingMemoryGB" -> remainingMemoryGB
)

val hdfsInfo = HdfsUtil.getCapacity()
val map = Map("cpu" -> cpuInfo, "memory" -> memoryInfo, "hdfs" -> hdfsInfo)
val resultMap = Map("resource" -> map)
Expand Down