summaryrefslogtreecommitdiff
path: root/opendc-compute
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-compute')
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt10
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt2
-rw-r--r--opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt19
-rw-r--r--opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt4
4 files changed, 11 insertions, 24 deletions
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt
index 451ea4b6..cefb3f7a 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt
@@ -36,15 +36,15 @@ public class VCpuFilter(private val allocationRatio: Double) : HostFilter {
server: Server,
): Boolean {
val requested = server.flavor.coreCount
- val total = host.host.model.coreCount
- val limit = total * allocationRatio
+ val totalCores = host.host.model.coreCount
+ val limit = totalCores * allocationRatio
// Do not allow an instance to overcommit against itself, only against other instances
- if (requested > total) {
+ if (requested > totalCores) {
return false
}
- val free = limit - host.provisionedCores
- return free >= requested
+ val availableCores = limit - host.provisionedCores
+ return availableCores >= requested
}
}
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt
index bfd21a3c..84799123 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt
+++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt
@@ -146,7 +146,7 @@ public class SimHost(
override fun canFit(server: Server): Boolean {
val sufficientMemory = model.memoryCapacity >= server.flavor.memorySize
- val enoughCpus = model.cpuCount >= server.flavor.coreCount
+ val enoughCpus = model.coreCount >= server.flavor.coreCount
val canFit = hypervisor.canFit(server.flavor.toMachineModel())
return sufficientMemory && enoughCpus && canFit
diff --git a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt
index f8c7afbd..549086d4 100644
--- a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt
+++ b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt
@@ -24,7 +24,6 @@
package org.opendc.compute.topology
-import org.opendc.compute.topology.specs.CPUJSONSpec
import org.opendc.compute.topology.specs.ClusterJSONSpec
import org.opendc.compute.topology.specs.HostJSONSpec
import org.opendc.compute.topology.specs.HostSpec
@@ -104,14 +103,14 @@ private fun ClusterJSONSpec.toHostSpecs(random: RandomGenerator): List<HostSpec>
* Helper method to convert a [HostJSONSpec] into a [HostSpec]s.
*/
private var hostId = 0
+private var globalCoreId = 0
private fun HostJSONSpec.toHostSpecs(
clusterId: Int,
random: RandomGenerator,
): HostSpec {
- val unknownProcessingNode = ProcessingNode("unknown", "unknown", "unknown", cpus.sumOf { it.coreCount })
-
- val units = cpus.flatMap { cpu -> List(cpu.count) { cpu.toProcessingUnits(unknownProcessingNode) }.flatten() }
+ val unknownProcessingNode = ProcessingNode("unknown", "unknown", "unknown", cpu.coreCount)
+ val units = List(cpu.count) { ProcessingUnit(unknownProcessingNode, globalCoreId++, cpu.coreSpeed) }
val unknownMemoryUnit = MemoryUnit(memory.vendor, memory.modelName, memory.memorySpeed, memory.memorySize)
val machineModel =
@@ -134,15 +133,3 @@ private fun HostJSONSpec.toHostSpecs(
return hostSpec
}
-
-/**
- * Helper method to convert a [CPUJSONSpec] into a list of [ProcessingUnit]s.
- */
-private var globalCoreId = 0
-
-private fun CPUJSONSpec.toProcessingUnits(unknownProcessingNode: ProcessingNode): List<ProcessingUnit> {
- val units = List(coreCount) { ProcessingUnit(unknownProcessingNode, globalCoreId++, coreSpeed) }
- return units
-
-// return listOf(ProcessingUnit(unknownProcessingNode, globalCoreId++, coreSpeed))
-}
diff --git a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt
index 8f73f524..2bfed502 100644
--- a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt
+++ b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt
@@ -54,7 +54,7 @@ public data class ClusterJSONSpec(
* Definition of a compute host modeled in the simulation.
*
* @param name The name of the host.
- * @param cpus List of the different CPUs available in this cluster
+ * @param cpu The CPU available in this cluster
* @param memory The amount of RAM memory available in Byte
* @param powerModel The power model used to determine the power draw of a host
* @param count The power model used to determine the power draw of a host
@@ -62,7 +62,7 @@ public data class ClusterJSONSpec(
@Serializable
public data class HostJSONSpec(
val name: String = "Host",
- val cpus: List<CPUJSONSpec>,
+ val cpu: CPUJSONSpec,
val memory: MemoryJSONSpec,
val powerModel: PowerModelJSONSpec = PowerModelJSONSpec("linear", 350.0, 400.0, 200.0),
val count: Int = 1,