summaryrefslogtreecommitdiff
path: root/opendc/opendc-compute/src
diff options
context:
space:
mode:
Diffstat (limited to 'opendc/opendc-compute/src')
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt13
1 files changed, 12 insertions, 1 deletions
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt
index 2d467e92..6200ad7c 100644
--- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt
+++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt
@@ -106,8 +106,14 @@ class SimpleVirtProvisioningService(
return
}
+ val quantum = 300000 // 5 minutes in milliseconds
+ // We assume that the provisioner runs at a fixed slot every time quantum (e.g t=0, t=60, t=120).
+ // This is important because the slices of the VMs need to be aligned.
+ // We calculate here the delay until the next scheduling slot.
+ val delay = quantum - (ctx.clock.millis() % quantum)
+
val call = launch {
- delay(1)
+ delay(delay)
this@SimpleVirtProvisioningService.call = null
schedule()
}
@@ -148,6 +154,11 @@ class SimpleVirtProvisioningService(
if (event.server.state == ServerState.SHUTOFF) {
activeImages -= imageInstance
selectedHv.provisionedCores -= server.flavor.cpuCount
+
+ // Try to reschedule if needed
+ if (incomingImages.isNotEmpty()) {
+ requestCycle()
+ }
}
}
}