summaryrefslogtreecommitdiff
path: root/simulator/opendc-experiments/opendc-experiments-energy21/src
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-08 20:46:39 +0200
committerGitHub <noreply@github.com>2021-04-08 20:46:39 +0200
commit3820ac4d31d6eb04034b85a1b53667d64ce6ba89 (patch)
treea7506b631770d6032eddc5a8252931b03c6e1796 /simulator/opendc-experiments/opendc-experiments-energy21/src
parent5fdbfbe7d340bc10f8b9eebd5aa23bdfd7dc4e18 (diff)
parent4f80e79b567b7d91b1086dcd74ef35616d7177f2 (diff)
compute: Implement filter scheduler
This pull request implements the filter scheduler modeled after the scheduler from [OpenStack](https://docs.openstack.org/nova/latest/user/filter-scheduler.html). The scheduler is functionally equivalent to the old allocation policies, but is more flexible and allows policies to be combined. * A new interface, `ComputeScheduler` is introduced, which is used by the `ComputeServiceImpl` to pick hosts to schedule on. * `FilterScheduler` is implemented, which works by filtering and weighing the available hosts. **Breaking API Changes** * Removal of the `AllocationPolicy` interface and its implementations. Users should migrate to the filter scheduler which offers the same functionality and more.
Diffstat (limited to 'simulator/opendc-experiments/opendc-experiments-energy21/src')
-rw-r--r--simulator/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt26
1 files changed, 16 insertions, 10 deletions
diff --git a/simulator/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt b/simulator/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt
index aa0f5ab4..c5982d8c 100644
--- a/simulator/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt
+++ b/simulator/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt
@@ -32,8 +32,11 @@ import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.test.runBlockingTest
import mu.KotlinLogging
import org.opendc.compute.service.ComputeService
-import org.opendc.compute.service.scheduler.AllocationPolicy
-import org.opendc.compute.service.scheduler.RandomAllocationPolicy
+import org.opendc.compute.service.scheduler.ComputeScheduler
+import org.opendc.compute.service.scheduler.FilterScheduler
+import org.opendc.compute.service.scheduler.filters.ComputeCapabilitiesFilter
+import org.opendc.compute.service.scheduler.filters.ComputeFilter
+import org.opendc.compute.service.scheduler.weights.RandomWeigher
import org.opendc.compute.simulator.SimHost
import org.opendc.experiments.capelin.*
import org.opendc.experiments.capelin.monitor.ParquetExperimentMonitor
@@ -88,7 +91,10 @@ public class EnergyExperiment : Experiment("Energy Modeling 2021") {
val clock = DelayControllerClockAdapter(this)
val chan = Channel<Unit>(Channel.CONFLATED)
- val allocationPolicy = RandomAllocationPolicy()
+ val allocationPolicy = FilterScheduler(
+ filters = listOf(ComputeFilter(), ComputeCapabilitiesFilter()),
+ weighers = listOf(RandomWeigher(Random(0)) to 1.0)
+ )
val meterProvider: MeterProvider = SdkMeterProvider
.builder()
@@ -125,7 +131,7 @@ public class EnergyExperiment : Experiment("Energy Modeling 2021") {
public suspend fun withComputeService(
clock: Clock,
meterProvider: MeterProvider,
- allocationPolicy: AllocationPolicy,
+ scheduler: ComputeScheduler,
block: suspend CoroutineScope.(ComputeService) -> Unit
): Unit = coroutineScope {
val model = createMachineModel()
@@ -144,18 +150,18 @@ public class EnergyExperiment : Experiment("Energy Modeling 2021") {
)
}
- val schedulerMeter = meterProvider.get("opendc-compute")
- val scheduler =
- ComputeService(coroutineContext, clock, schedulerMeter, allocationPolicy)
+ val serviceMeter = meterProvider.get("opendc-compute")
+ val service =
+ ComputeService(coroutineContext, clock, serviceMeter, scheduler)
for (host in hosts) {
- scheduler.addHost(host)
+ service.addHost(host)
}
try {
- block(this, scheduler)
+ block(this, service)
} finally {
- scheduler.close()
+ service.close()
hosts.forEach(SimHost::close)
}
}