From 21270e0b4250bd6927e85227fa825cf8ed59aaed Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 22 Sep 2022 10:55:13 +0200 Subject: refactor(compute): Add separate error host state This change adds a new HostState to indicate that the host is in an error state as opposed to being purposefully unavailable. --- .../kotlin/org/opendc/compute/service/driver/HostState.kt | 11 ++++++++--- .../org/opendc/compute/service/internal/ComputeServiceImpl.kt | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'opendc-compute/opendc-compute-service/src') diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/driver/HostState.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/driver/HostState.kt index 6d85ee2d..ca6c625c 100644 --- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/driver/HostState.kt +++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/driver/HostState.kt @@ -27,12 +27,17 @@ package org.opendc.compute.service.driver */ public enum class HostState { /** - * The host is up. + * The host is up and able to host guests. */ UP, /** - * The host is down. + * The host is in a (forced) down state and unable to host any guests. */ - DOWN + DOWN, + + /** + * The host is in an error state and unable to host any guests. + */ + ERROR, } diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/ComputeServiceImpl.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/ComputeServiceImpl.kt index 21aaa19e..52ee780b 100644 --- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/ComputeServiceImpl.kt +++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/ComputeServiceImpl.kt @@ -411,7 +411,7 @@ internal class ComputeServiceImpl( // Re-schedule on the new machine requestSchedulingCycle() } - HostState.DOWN -> { + else -> { logger.debug { "[${clock.instant()}] Host ${host.uid} state changed: $newState" } val hv = hostToView[host] ?: return -- cgit v1.2.3