From c27c43fd0f34b8ae95ce2a0939d827530b9e2bf2 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 5 May 2020 18:16:40 +0200 Subject: Add basic replay policy --- .../virt/service/allocation/ReplayAllocationPolicy.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt (limited to 'opendc/opendc-compute/src') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt new file mode 100644 index 00000000..31731256 --- /dev/null +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt @@ -0,0 +1,19 @@ +package com.atlarge.opendc.compute.virt.service.allocation + +import com.atlarge.opendc.compute.virt.service.HypervisorView +import com.atlarge.opendc.compute.virt.service.SimpleVirtProvisioningService + +class ReplayAllocationPolicy(val vmPlacements: Map) : AllocationPolicy { + override fun invoke(): AllocationPolicy.Logic = object : AllocationPolicy.Logic { + override fun select( + hypervisors: Set, + image: SimpleVirtProvisioningService.ImageView + ): HypervisorView? { + val clusterName = vmPlacements[image.name] + ?: throw IllegalArgumentException("Could not find placement data in VM placement file for VM ${image.name}") + val machinesInCluster = hypervisors.filter { it.server.name.contains(clusterName) } + return machinesInCluster.minBy { it.numberOfActiveServers } + ?: throw IllegalArgumentException("Cloud not find any machines belonging to cluster $clusterName for image ${image.name}") + } + } +} -- cgit v1.2.3 From d6b3ecfc6737638af48caca3c369087e8c3da3db Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 5 May 2020 18:17:52 +0200 Subject: Add docs --- .../compute/virt/service/allocation/ReplayAllocationPolicy.kt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'opendc/opendc-compute/src') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt index 31731256..790121c4 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt @@ -3,6 +3,12 @@ package com.atlarge.opendc.compute.virt.service.allocation import com.atlarge.opendc.compute.virt.service.HypervisorView import com.atlarge.opendc.compute.virt.service.SimpleVirtProvisioningService +/** + * Policy replaying VM-cluster assignnment. + * + * Within each cluster, the active servers on each node determine which node gets + * assigned the VM image. + */ class ReplayAllocationPolicy(val vmPlacements: Map) : AllocationPolicy { override fun invoke(): AllocationPolicy.Logic = object : AllocationPolicy.Logic { override fun select( -- cgit v1.2.3 From b8637f4d54dd228f08029f66f45cfe4d2240ddff Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 5 May 2020 19:01:39 +0200 Subject: Fix cluster format --- .../opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'opendc/opendc-compute/src') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt index 790121c4..280f3028 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt @@ -16,10 +16,10 @@ class ReplayAllocationPolicy(val vmPlacements: Map) : Allocation image: SimpleVirtProvisioningService.ImageView ): HypervisorView? { val clusterName = vmPlacements[image.name] - ?: throw IllegalArgumentException("Could not find placement data in VM placement file for VM ${image.name}") + ?: throw RuntimeException("Could not find placement data in VM placement file for VM ${image.name}") val machinesInCluster = hypervisors.filter { it.server.name.contains(clusterName) } return machinesInCluster.minBy { it.numberOfActiveServers } - ?: throw IllegalArgumentException("Cloud not find any machines belonging to cluster $clusterName for image ${image.name}") + ?: throw RuntimeException("Cloud not find any machines belonging to cluster $clusterName for image ${image.name}") } } } -- cgit v1.2.3 From 9892e3d9a6755e4b9ec213adc30e7539696248f6 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 5 May 2020 19:38:09 +0200 Subject: Add check for VMs not in placement data --- .../opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'opendc/opendc-compute/src') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt index 280f3028..1276a973 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt @@ -18,7 +18,7 @@ class ReplayAllocationPolicy(val vmPlacements: Map) : Allocation val clusterName = vmPlacements[image.name] ?: throw RuntimeException("Could not find placement data in VM placement file for VM ${image.name}") val machinesInCluster = hypervisors.filter { it.server.name.contains(clusterName) } - return machinesInCluster.minBy { it.numberOfActiveServers } + return machinesInCluster.maxBy { it.availableMemory } ?: throw RuntimeException("Cloud not find any machines belonging to cluster $clusterName for image ${image.name}") } } -- cgit v1.2.3 From c4ba00bdb3a777dea866a043820e2df89ff81f86 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 5 May 2020 22:23:11 +0200 Subject: Change exception --- .../opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'opendc/opendc-compute/src') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt index 1276a973..f88eaed8 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt @@ -16,10 +16,10 @@ class ReplayAllocationPolicy(val vmPlacements: Map) : Allocation image: SimpleVirtProvisioningService.ImageView ): HypervisorView? { val clusterName = vmPlacements[image.name] - ?: throw RuntimeException("Could not find placement data in VM placement file for VM ${image.name}") + ?: throw IllegalStateException("Could not find placement data in VM placement file for VM ${image.name}") val machinesInCluster = hypervisors.filter { it.server.name.contains(clusterName) } return machinesInCluster.maxBy { it.availableMemory } - ?: throw RuntimeException("Cloud not find any machines belonging to cluster $clusterName for image ${image.name}") + ?: throw IllegalStateException("Cloud not find any machines belonging to cluster $clusterName for image ${image.name}") } } } -- cgit v1.2.3