diff options
Diffstat (limited to 'opendc-compute/opendc-compute-simulator/src/main')
| -rw-r--r-- | opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt | 37 |
1 files changed, 28 insertions, 9 deletions
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 a44ccc27..ec71f095 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 @@ -65,9 +65,9 @@ import java.util.function.Supplier * @param optimize A flag to indicate to optimize the machine models of the virtual machines. */ public class SimHost( - override val uid: UUID, - override val name: String, - override val meta: Map<String, Any>, + private val uid: UUID, + private val name: String, + private val meta: Map<String, Any>, private val clock: InstantSource, private val machine: SimBareMetalMachine, private val hypervisor: SimHypervisor, @@ -87,11 +87,6 @@ public class SimHost( private val guests = HashMap<Server, Guest>() private val _guests = mutableListOf<Guest>() - override val instances: Set<Server> - get() = guests.keys - - override val state: HostState - get() = _state private var _state: HostState = HostState.DOWN set(value) { if (value != field) { @@ -100,7 +95,7 @@ public class SimHost( field = value } - override val model: HostModel = HostModel( + private val model: HostModel = HostModel( machine.model.cpus.sumOf { it.frequency }, machine.model.cpus.size, machine.model.memory.sumOf { it.size } @@ -123,6 +118,30 @@ public class SimHost( launch() } + override fun getUid(): UUID { + return uid + } + + override fun getName(): String { + return name + } + + override fun getModel(): HostModel { + return model + } + + override fun getMeta(): Map<String, *> { + return meta + } + + override fun getState(): HostState { + return _state + } + + override fun getInstances(): Set<Server> { + return guests.keys + } + override fun canFit(server: Server): Boolean { val sufficientMemory = model.memoryCapacity >= server.flavor.memorySize val enoughCpus = model.cpuCount >= server.flavor.cpuCount |
