Skip to content

Commit

Permalink
Updated for spotless apply
Browse files Browse the repository at this point in the history
  • Loading branch information
DanteNiewenhuis committed Mar 5, 2024
1 parent b0db142 commit ff39550
Show file tree
Hide file tree
Showing 14 changed files with 975 additions and 872 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,61 @@ import java.util.random.RandomGenerator
/**
* Create a [ComputeScheduler] for the experiment.
*/
public fun createComputeScheduler(name: String, seeder: RandomGenerator, placements: Map<String, String> = emptyMap()): ComputeScheduler {
public fun createComputeScheduler(
name: String,
seeder: RandomGenerator,
placements: Map<String, String> = emptyMap(),
): ComputeScheduler {
val cpuAllocationRatio = 1.0

Check warning on line 45 in opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt

View check run for this annotation

Codecov / codecov/patch

opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt#L45

Added line #L45 was not covered by tests
val ramAllocationRatio = 1.5
return when (name) {
"mem" -> FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(RamWeigher(multiplier = 1.0))
)
"mem-inv" -> FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(RamWeigher(multiplier = -1.0))
)
"core-mem" -> FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(CoreRamWeigher(multiplier = 1.0))
)
"core-mem-inv" -> FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(CoreRamWeigher(multiplier = -1.0))
)
"active-servers" -> FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(InstanceCountWeigher(multiplier = -1.0))
)
"active-servers-inv" -> FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(InstanceCountWeigher(multiplier = 1.0))
)
"provisioned-cores" -> FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = 1.0))
)
"provisioned-cores-inv" -> FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = -1.0))
)
"random" -> FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = emptyList(),
subsetSize = Int.MAX_VALUE,
random = SplittableRandom(seeder.nextLong())
)
"mem" ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(RamWeigher(multiplier = 1.0)),
)
"mem-inv" ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(RamWeigher(multiplier = -1.0)),
)
"core-mem" ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(CoreRamWeigher(multiplier = 1.0)),
)
"core-mem-inv" ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(CoreRamWeigher(multiplier = -1.0)),
)
"active-servers" ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(InstanceCountWeigher(multiplier = -1.0)),
)
"active-servers-inv" ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(InstanceCountWeigher(multiplier = 1.0)),
)
"provisioned-cores" ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = 1.0)),
)
"provisioned-cores-inv" ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = -1.0)),
)
"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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ import org.opendc.compute.service.HostView
* @param allocationRatio Virtual CPU to physical CPU allocation ratio.
*/
public class VCpuFilter(private val allocationRatio: Double) : HostFilter {
override fun test(host: HostView, server: Server): Boolean {
override fun test(
host: HostView,
server: Server,
): Boolean {
val requested = server.flavor.coreCount
val total = host.host.model.coreCount
val limit = total * allocationRatio
Expand Down
Loading

0 comments on commit ff39550

Please sign in to comment.