diff options
Diffstat (limited to 'opendc-compute')
| -rw-r--r-- | opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt | 44 | ||||
| -rw-r--r-- | opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/failure/FailureModelFactory.kt | 41 | ||||
| -rw-r--r-- | opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/failure/models/Grid5000.kt (renamed from opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/failure/FailureModels.kt) | 52 | ||||
| -rw-r--r-- | opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt | 2 | ||||
| -rw-r--r-- | opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/internal/LoadSampledComputeWorkload.kt | 2 |
5 files changed, 102 insertions, 39 deletions
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt index 4d234b1b..7fcc670f 100644 --- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt +++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt @@ -34,65 +34,85 @@ import org.opendc.compute.service.scheduler.weights.VCpuWeigher import java.util.SplittableRandom import java.util.random.RandomGenerator +public enum class ComputeSchedulerEnum { + Mem, + MemInv, + CoreMem, + CoreMemInv, + ActiveServers, + ActiveServersInv, + ProvisionedCores, + ProvisionedCoresInv, + Random, + Replay, +} + +public fun createComputeScheduler( + name: String, + seeder: RandomGenerator, + placements: Map<String, String> = emptyMap(), +): ComputeScheduler { + return createComputeScheduler(ComputeSchedulerEnum.valueOf(name.uppercase()), seeder, placements) +} + /** * Create a [ComputeScheduler] for the experiment. */ public fun createComputeScheduler( - name: String, + name: ComputeSchedulerEnum, seeder: RandomGenerator, placements: Map<String, String> = emptyMap(), ): ComputeScheduler { val cpuAllocationRatio = 1.0 val ramAllocationRatio = 1.5 return when (name) { - "mem" -> + ComputeSchedulerEnum.Mem -> FilterScheduler( filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)), weighers = listOf(RamWeigher(multiplier = 1.0)), ) - "mem-inv" -> + ComputeSchedulerEnum.MemInv -> FilterScheduler( filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)), weighers = listOf(RamWeigher(multiplier = -1.0)), ) - "core-mem" -> + ComputeSchedulerEnum.CoreMem -> FilterScheduler( filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)), weighers = listOf(CoreRamWeigher(multiplier = 1.0)), ) - "core-mem-inv" -> + ComputeSchedulerEnum.CoreMemInv -> FilterScheduler( filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)), weighers = listOf(CoreRamWeigher(multiplier = -1.0)), ) - "active-servers" -> + ComputeSchedulerEnum.ActiveServers -> FilterScheduler( filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)), weighers = listOf(InstanceCountWeigher(multiplier = -1.0)), ) - "active-servers-inv" -> + ComputeSchedulerEnum.ActiveServersInv -> FilterScheduler( filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)), weighers = listOf(InstanceCountWeigher(multiplier = 1.0)), ) - "provisioned-cores" -> + ComputeSchedulerEnum.ProvisionedCores -> FilterScheduler( filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)), weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = 1.0)), ) - "provisioned-cores-inv" -> + ComputeSchedulerEnum.ProvisionedCoresInv -> FilterScheduler( filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)), weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = -1.0)), ) - "random" -> + ComputeSchedulerEnum.Random -> FilterScheduler( filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)), weighers = emptyList(), subsetSize = Int.MAX_VALUE, random = SplittableRandom(seeder.nextLong()), ) - "replay" -> ReplayScheduler(placements) - else -> throw IllegalArgumentException("Unknown policy $name") + ComputeSchedulerEnum.Replay -> ReplayScheduler(placements) } } diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/failure/FailureModelFactory.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/failure/FailureModelFactory.kt new file mode 100644 index 00000000..406665c7 --- /dev/null +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/failure/FailureModelFactory.kt @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.compute.simulator.failure + +import org.opendc.compute.simulator.failure.models.Grid5000 +import java.time.Duration +import kotlin.math.roundToLong + +/** + * Get failure model + * + * @param failureInterval The interval of failures occurring in s + * @return + */ +public fun getFailureModel(failureInterval: Double): FailureModel? { + return if (failureInterval > 0) { + Grid5000(Duration.ofSeconds(failureInterval.roundToLong())) + } else { + null + } +} diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/failure/FailureModels.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/failure/models/Grid5000.kt index b8887627..8aacc49d 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/failure/FailureModels.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/failure/models/Grid5000.kt @@ -22,12 +22,16 @@ @file:JvmName("FailureModels") -package org.opendc.compute.simulator.failure +package org.opendc.compute.simulator.failure.models import org.apache.commons.math3.distribution.LogNormalDistribution import org.apache.commons.math3.random.Well19937c import org.opendc.compute.service.ComputeService import org.opendc.compute.simulator.SimHost +import org.opendc.compute.simulator.failure.FailureModel +import org.opendc.compute.simulator.failure.HostFaultInjector +import org.opendc.compute.simulator.failure.StartStopHostFault +import org.opendc.compute.simulator.failure.StochasticVictimSelector import java.time.Duration import java.time.InstantSource import java.util.random.RandomGenerator @@ -35,34 +39,32 @@ import kotlin.coroutines.CoroutineContext import kotlin.math.ln /** - * Obtain a [FailureModel] based on the GRID'5000 failure trace. + * A [FailureModel] based on the GRID'5000 failure trace. * * This fault injector uses parameters from the GRID'5000 failure trace as described in * "A Framework for the Study of Grid Inter-Operation Mechanisms", A. Iosup, 2009. */ -public fun grid5000(failureInterval: Duration): FailureModel { - return object : FailureModel { - override fun createInjector( - context: CoroutineContext, - clock: InstantSource, - service: ComputeService, - random: RandomGenerator, - ): HostFaultInjector { - val rng = Well19937c(random.nextLong()) - val hosts = service.hosts.map { it as SimHost }.toSet() +public class Grid5000(private val failureInterval: Duration) : FailureModel { + override fun createInjector( + context: CoroutineContext, + clock: InstantSource, + service: ComputeService, + random: RandomGenerator, + ): HostFaultInjector { + val rng = Well19937c(random.nextLong()) + val hosts = service.hosts.map { it as SimHost }.toSet() - // Parameters from A. Iosup, A Framework for the Study of Grid Inter-Operation Mechanisms, 2009 - // GRID'5000 - return HostFaultInjector( - context, - clock, - hosts, - iat = LogNormalDistribution(rng, ln(failureInterval.toHours().toDouble()), 1.03), - selector = StochasticVictimSelector(LogNormalDistribution(rng, 1.88, 1.25), random), - fault = StartStopHostFault(LogNormalDistribution(rng, 8.89, 2.71)), - ) - } - - override fun toString(): String = "Grid5000FailureModel" + // Parameters from A. Iosup, A Framework for the Study of Grid Inter-Operation Mechanisms, 2009 + // GRID'5000 + return HostFaultInjector( + context, + clock, + hosts, + iat = LogNormalDistribution(rng, ln(failureInterval.toHours().toDouble()), 1.03), + selector = StochasticVictimSelector(LogNormalDistribution(rng, 1.88, 1.25), random), + fault = StartStopHostFault(LogNormalDistribution(rng, 8.89, 2.71)), + ) } + + override fun toString(): String = "Grid5000FailureModel" } diff --git a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt index 2202f851..9afb6a5a 100644 --- a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt +++ b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt @@ -131,7 +131,7 @@ public class ComputeWorkloadLoader(private val baseDir: File) { val memCapacity = reader.getDouble(memCol) / 1000.0 // Convert from KB to MB val uid = UUID.nameUUIDFromBytes("$id-${counter++}".toByteArray()) - val builder = fragments.getValue(id) + val builder = fragments.getValue(id) // Get all fragments related to this VM val totalLoad = builder.totalLoad entries.add( diff --git a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/internal/LoadSampledComputeWorkload.kt b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/internal/LoadSampledComputeWorkload.kt index c89507fa..51ddb27c 100644 --- a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/internal/LoadSampledComputeWorkload.kt +++ b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/internal/LoadSampledComputeWorkload.kt @@ -41,7 +41,7 @@ internal class LoadSampledComputeWorkload(val source: ComputeWorkload, val fract loader: ComputeWorkloadLoader, random: RandomGenerator, ): List<VirtualMachine> { - val vms = source.resolve(loader, random) + val vms = source.resolve(loader, random) // fixme: Should be shuffled, otherwise the first fraction is always chosen val res = mutableListOf<VirtualMachine>() val totalLoad = vms.sumOf { it.totalLoad } |
