summaryrefslogtreecommitdiff
path: root/opendc-workflow
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-workflow')
-rw-r--r--opendc-workflow/opendc-workflow-api/build.gradle.kts1
-rw-r--r--opendc-workflow/opendc-workflow-service/build.gradle.kts3
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/WorkflowServiceImpl.kt38
-rw-r--r--opendc-workflow/opendc-workflow-workload/build.gradle.kts1
4 files changed, 7 insertions, 36 deletions
diff --git a/opendc-workflow/opendc-workflow-api/build.gradle.kts b/opendc-workflow/opendc-workflow-api/build.gradle.kts
index 36239d05..03569d8c 100644
--- a/opendc-workflow/opendc-workflow-api/build.gradle.kts
+++ b/opendc-workflow/opendc-workflow-api/build.gradle.kts
@@ -28,7 +28,6 @@ plugins {
}
dependencies {
- api(platform(projects.opendcPlatform))
api(projects.opendcCompute.opendcComputeApi)
implementation(libs.kotlin.logging)
}
diff --git a/opendc-workflow/opendc-workflow-service/build.gradle.kts b/opendc-workflow/opendc-workflow-service/build.gradle.kts
index 4d8b7d7f..17df33e3 100644
--- a/opendc-workflow/opendc-workflow-service/build.gradle.kts
+++ b/opendc-workflow/opendc-workflow-service/build.gradle.kts
@@ -30,11 +30,10 @@ plugins {
}
dependencies {
- api(platform(projects.opendcPlatform))
api(projects.opendcWorkflow.opendcWorkflowApi)
api(projects.opendcCompute.opendcComputeApi)
api(projects.opendcTelemetry.opendcTelemetryApi)
- implementation(projects.opendcUtils)
+ implementation(projects.opendcCommon)
implementation(libs.kotlin.logging)
testImplementation(projects.opendcWorkflow.opendcWorkflowWorkload)
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/WorkflowServiceImpl.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/WorkflowServiceImpl.kt
index 7b6d8651..cdaec021 100644
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/WorkflowServiceImpl.kt
+++ b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/WorkflowServiceImpl.kt
@@ -25,8 +25,8 @@ package org.opendc.workflow.service.internal
import io.opentelemetry.api.metrics.Meter
import io.opentelemetry.api.metrics.MeterProvider
import kotlinx.coroutines.*
+import org.opendc.common.util.Pacer
import org.opendc.compute.api.*
-import org.opendc.utils.TimerScheduler
import org.opendc.workflow.api.Job
import org.opendc.workflow.api.WORKFLOW_TASK_CORES
import org.opendc.workflow.service.*
@@ -187,9 +187,9 @@ public class WorkflowServiceImpl(
.build()
/**
- * The [TimerScheduler] to use for scheduling the scheduler cycles.
+ * The [Pacer] to use for scheduling the scheduler cycles.
*/
- private val timerScheduler: TimerScheduler<Unit> = TimerScheduler(scope.coroutineContext, clock)
+ private val pacer = Pacer(scope.coroutineContext, clock, schedulingQuantum.toMillis()) { doSchedule() }
private val jobAdmissionPolicy: JobAdmissionPolicy.Logic
private val taskEligibilityPolicy: TaskEligibilityPolicy.Logic
@@ -230,7 +230,7 @@ public class WorkflowServiceImpl(
rootListener.jobSubmitted(jobInstance)
submittedJobs.add(1)
- requestSchedulingCycle()
+ pacer.enqueue()
}
override fun close() {
@@ -252,31 +252,6 @@ public class WorkflowServiceImpl(
}
/**
- * Indicate that a new scheduling cycle is needed due to a change to the service's state.
- */
- private fun requestSchedulingCycle() {
- // Bail out in case we have already requested a new cycle or the queue is empty.
- if (timerScheduler.isTimerActive(Unit)) {
- return
- }
-
- val quantum = schedulingQuantum.toMillis()
- if (quantum == 0L) {
- doSchedule()
- return
- }
-
- // We assume that the provisioner runs at a fixed slot every time quantum (e.g t=0, t=60, t=120).
- // This is important because the slices of the VMs need to be aligned.
- // We calculate here the delay until the next scheduling slot.
- val delay = quantum - (clock.millis() % quantum)
-
- timerScheduler.startSingleTimer(Unit, delay) {
- doSchedule()
- }
- }
-
- /**
* Perform a scheduling cycle immediately.
*/
private fun doSchedule() {
@@ -409,10 +384,9 @@ public class WorkflowServiceImpl(
finishJob(job)
}
- requestSchedulingCycle()
- }
- ServerState.DELETED -> {
+ pacer.enqueue()
}
+ ServerState.DELETED -> {}
else -> throw IllegalStateException()
}
}
diff --git a/opendc-workflow/opendc-workflow-workload/build.gradle.kts b/opendc-workflow/opendc-workflow-workload/build.gradle.kts
index dfb77a39..a9d497af 100644
--- a/opendc-workflow/opendc-workflow-workload/build.gradle.kts
+++ b/opendc-workflow/opendc-workflow-workload/build.gradle.kts
@@ -29,7 +29,6 @@ plugins {
}
dependencies {
- api(platform(projects.opendcPlatform))
api(projects.opendcWorkflow.opendcWorkflowService)
implementation(projects.opendcSimulator.opendcSimulatorCompute)