summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-service/src
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-11-04 17:14:46 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-11-04 17:21:58 +0100
commit7143584da87e248277ab95a4848a57eccd62db69 (patch)
treef889f310de1ec33ab59d3fe04e204f9cc7c11b4d /opendc-compute/opendc-compute-service/src
parentacb45a1dea61dd844fba839cc31c79a7aca4bbe4 (diff)
refactor: Use RandomGenerator as randomness source
This change updates the modules of OpenDC to always accept the `RandomGenerator` interface as source of randomness. This interface is implemented by the slower `java.util.Random` class, but also by the faster `java.util.SplittableRandom` class
Diffstat (limited to 'opendc-compute/opendc-compute-service/src')
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/FilterScheduler.kt7
1 files changed, 4 insertions, 3 deletions
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/FilterScheduler.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/FilterScheduler.kt
index 233f5ef6..0840ba7e 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/FilterScheduler.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/FilterScheduler.kt
@@ -26,7 +26,8 @@ import org.opendc.compute.api.Server
import org.opendc.compute.service.internal.HostView
import org.opendc.compute.service.scheduler.filters.HostFilter
import org.opendc.compute.service.scheduler.weights.HostWeigher
-import java.util.Random
+import java.util.SplittableRandom
+import java.util.random.RandomGenerator
import kotlin.math.min
/**
@@ -39,13 +40,13 @@ import kotlin.math.min
* @param filters The list of filters to apply when searching for an appropriate host.
* @param weighers The list of weighers to apply when searching for an appropriate host.
* @param subsetSize The size of the subset of best hosts from which a target is randomly chosen.
- * @param random A [Random] instance for selecting
+ * @param random A [RandomGenerator] instance for selecting
*/
public class FilterScheduler(
private val filters: List<HostFilter>,
private val weighers: List<HostWeigher>,
private val subsetSize: Int = 1,
- private val random: Random = Random(0)
+ private val random: RandomGenerator = SplittableRandom(0)
) : ComputeScheduler {
/**
* The pool of hosts available to the scheduler.