summaryrefslogtreecommitdiff
path: root/opendc-workflow/opendc-workflow-service/src/main/kotlin
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2024-08-27 13:48:46 +0200
committerGitHub <noreply@github.com>2024-08-27 13:48:46 +0200
commit3363df4c72a064e590ca98f8e01832cfa4e15a3f (patch)
tree9a938700fe08ce344ff5d0d475d0b64d7233d1fc /opendc-workflow/opendc-workflow-service/src/main/kotlin
parentc21708013f2746807f5bdb3fc47c2b47ed15b7c8 (diff)
Renamed input files and internally server is changed to task (#246)
* Updated SimTrace to use a single ArrayDeque instead of three separate lists for deadline, cpuUsage, and coreCount * Renamed input files to tasks.parquet and fragments.parquet. Renamed server to task. OpenDC nows exports tasks.parquet instead of server.parquet
Diffstat (limited to 'opendc-workflow/opendc-workflow-service/src/main/kotlin')
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/WorkflowService.kt89
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/JobState.kt40
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/TaskState.kt83
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/TaskStatus.kt33
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/WorkflowSchedulerListener.kt65
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/WorkflowServiceImpl.kt387
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/StagePolicy.kt36
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/DurationJobOrderPolicy.kt106
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/JobAdmissionPolicy.kt70
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/JobOrderPolicy.kt31
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/LimitJobAdmissionPolicy.kt45
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/NullJobAdmissionPolicy.kt38
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/RandomJobOrderPolicy.kt66
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/SizeJobOrderPolicy.kt38
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/SubmissionTimeJobOrderPolicy.kt38
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/ActiveTaskOrderPolicy.kt71
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/BalancingTaskEligibilityPolicy.kt77
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/CompletionTaskOrderPolicy.kt67
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DependenciesTaskOrderPolicy.kt40
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DependentsTaskOrderPolicy.kt40
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DurationHistoryTaskOrderPolicy.kt72
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DurationTaskOrderPolicy.kt71
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/LimitPerJobTaskEligibilityPolicy.kt69
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/LimitTaskEligibilityPolicy.kt43
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/NullTaskEligibilityPolicy.kt39
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/RandomTaskEligibilityPolicy.kt46
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/RandomTaskOrderPolicy.kt63
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/SubmissionTimeTaskOrderPolicy.kt40
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/TaskEligibilityPolicy.kt70
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/TaskOrderPolicy.kt32
-rw-r--r--opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/telemetry/SchedulerStats.kt42
31 files changed, 0 insertions, 2047 deletions
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/WorkflowService.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/WorkflowService.kt
deleted file mode 100644
index 4efc7953..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/WorkflowService.kt
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service
-
-import org.opendc.common.Dispatcher
-import org.opendc.compute.api.ComputeClient
-import org.opendc.workflow.api.Job
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-import org.opendc.workflow.service.scheduler.job.JobAdmissionPolicy
-import org.opendc.workflow.service.scheduler.job.JobOrderPolicy
-import org.opendc.workflow.service.scheduler.task.TaskEligibilityPolicy
-import org.opendc.workflow.service.scheduler.task.TaskOrderPolicy
-import org.opendc.workflow.service.scheduler.telemetry.SchedulerStats
-import java.time.Duration
-
-/**
- * A service for cloud workflow execution.
- *
- * The workflow scheduler is modelled after the Reference Architecture for Topology Scheduling by Andreadis et al.
- */
-public interface WorkflowService : AutoCloseable {
- /**
- * Submit the specified [Job] and suspend execution until the job is finished.
- */
- public suspend fun invoke(job: Job)
-
- /**
- * Collect statistics about the workflow scheduler.
- */
- public fun getSchedulerStats(): SchedulerStats
-
- /**
- * Terminate the lifecycle of the workflow service, stopping all running workflows.
- */
- public override fun close()
-
- public companion object {
- /**
- * Construct a new [WorkflowService] implementation.
- *
- * @param dispatcher A [Dispatcher] to schedule future events.
- * @param compute The "Compute" client to use.
- * @param schedulingQuantum The scheduling quantum to use (minimum duration between scheduling cycles).
- * @param jobAdmissionPolicy The job admission policy to use.
- * @param jobOrderPolicy The job order policy to use.
- * @param taskEligibilityPolicy The task eligibility policy to use.
- * @param taskOrderPolicy The task order policy to use.
- */
- public operator fun invoke(
- dispatcher: Dispatcher,
- compute: ComputeClient,
- schedulingQuantum: Duration,
- jobAdmissionPolicy: JobAdmissionPolicy,
- jobOrderPolicy: JobOrderPolicy,
- taskEligibilityPolicy: TaskEligibilityPolicy,
- taskOrderPolicy: TaskOrderPolicy,
- ): WorkflowService {
- return WorkflowServiceImpl(
- dispatcher,
- compute,
- schedulingQuantum,
- jobAdmissionPolicy,
- jobOrderPolicy,
- taskEligibilityPolicy,
- taskOrderPolicy,
- )
- }
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/JobState.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/JobState.kt
deleted file mode 100644
index d2fc1ed7..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/JobState.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.internal
-
-import org.opendc.workflow.api.Job
-import kotlin.coroutines.Continuation
-
-public class JobState(public val job: Job, public val submittedAt: Long, internal val cont: Continuation<Unit>) {
- /**
- * A flag to indicate whether this job is finished.
- */
- public val isFinished: Boolean
- get() = tasks.isEmpty()
-
- internal val tasks: MutableSet<TaskState> = mutableSetOf()
-
- override fun equals(other: Any?): Boolean = other is JobState && other.job == job
-
- override fun hashCode(): Int = job.hashCode()
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/TaskState.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/TaskState.kt
deleted file mode 100644
index c3ce1492..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/TaskState.kt
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.internal
-
-import org.opendc.compute.api.Server
-import org.opendc.workflow.api.Task
-
-public class TaskState(public val job: JobState, public val task: Task) {
- /**
- * The moment in time the task was started.
- */
- public var startedAt: Long = Long.MIN_VALUE
-
- /**
- * The moment in time the task was finished.
- */
- public var finishedAt: Long = Long.MIN_VALUE
-
- /**
- * The dependencies of this task.
- */
- public val dependencies: HashSet<TaskState> = HashSet()
-
- /**
- * The dependents of this task.
- */
- public val dependents: HashSet<TaskState> = HashSet()
-
- /**
- * A flag to indicate whether this workflow task instance is a workflow root.
- */
- public val isRoot: Boolean
- get() = dependencies.isEmpty()
-
- public var state: TaskStatus = TaskStatus.CREATED
- set(value) {
- field = value
-
- // Mark the process as terminated in the graph
- if (value == TaskStatus.FINISHED) {
- markTerminated()
- }
- }
-
- public var server: Server? = null
-
- /**
- * Mark the specified [TaskView] as terminated.
- */
- private fun markTerminated() {
- for (dependent in dependents) {
- dependent.dependencies.remove(this)
-
- if (dependent.isRoot) {
- dependent.state = TaskStatus.READY
- }
- }
- }
-
- override fun equals(other: Any?): Boolean = other is TaskState && other.job == job && other.task == task
-
- override fun hashCode(): Int = task.hashCode()
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/TaskStatus.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/TaskStatus.kt
deleted file mode 100644
index e5475ee6..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/TaskStatus.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.internal
-
-/**
- * The state of a workflow task.
- */
-public enum class TaskStatus {
- CREATED,
- READY,
- ACTIVE,
- FINISHED,
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/WorkflowSchedulerListener.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/WorkflowSchedulerListener.kt
deleted file mode 100644
index 8e76a36e..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/WorkflowSchedulerListener.kt
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.internal
-
-import org.opendc.workflow.service.WorkflowService
-
-/**
- * Interface for listening to events emitted by the [WorkflowService].
- */
-public interface WorkflowSchedulerListener {
- /**
- * This method is invoked when [job] is submitted to the service.
- */
- public fun jobSubmitted(job: JobState) {}
-
- /**
- * This method is invoked when [job] is started by the service.
- */
- public fun jobStarted(job: JobState) {}
-
- /**
- * This method is invoked when [job] finishes.
- */
- public fun jobFinished(job: JobState) {}
-
- /**
- * This method is invoked when [task] becomes ready to be scheduled.
- */
- public fun taskReady(task: TaskState) {}
-
- /**
- * This method is invoked when [task] is assigned to a machine.
- */
- public fun taskAssigned(task: TaskState) {}
-
- /**
- * This method is invoked when [task] is started.
- */
- public fun taskStarted(task: TaskState) {}
-
- /**
- * This method is invoked when [task] finishes.
- */
- public fun taskFinished(task: TaskState) {}
-}
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
deleted file mode 100644
index 93a55c3d..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/internal/WorkflowServiceImpl.kt
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.internal
-
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.cancel
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.suspendCancellableCoroutine
-import org.opendc.common.Dispatcher
-import org.opendc.common.asCoroutineDispatcher
-import org.opendc.common.util.Pacer
-import org.opendc.compute.api.ComputeClient
-import org.opendc.compute.api.Image
-import org.opendc.compute.api.Server
-import org.opendc.compute.api.ServerState
-import org.opendc.compute.api.ServerWatcher
-import org.opendc.workflow.api.Job
-import org.opendc.workflow.api.WORKFLOW_TASK_CORES
-import org.opendc.workflow.service.WorkflowService
-import org.opendc.workflow.service.scheduler.job.JobAdmissionPolicy
-import org.opendc.workflow.service.scheduler.job.JobOrderPolicy
-import org.opendc.workflow.service.scheduler.task.TaskEligibilityPolicy
-import org.opendc.workflow.service.scheduler.task.TaskOrderPolicy
-import org.opendc.workflow.service.scheduler.telemetry.SchedulerStats
-import java.time.Duration
-import java.time.InstantSource
-import java.util.PriorityQueue
-import java.util.Queue
-import kotlin.coroutines.resume
-
-/**
- * A [WorkflowService] that distributes work through a multi-stage process based on the Reference Architecture for
- * Datacenter Scheduling.
- */
-public class WorkflowServiceImpl(
- dispatcher: Dispatcher,
- private val computeClient: ComputeClient,
- schedulingQuantum: Duration,
- jobAdmissionPolicy: JobAdmissionPolicy,
- jobOrderPolicy: JobOrderPolicy,
- taskEligibilityPolicy: TaskEligibilityPolicy,
- taskOrderPolicy: TaskOrderPolicy,
-) : WorkflowService, ServerWatcher {
- /**
- * The [CoroutineScope] of the service bounded by the lifecycle of the service.
- */
- private val scope = CoroutineScope(dispatcher.asCoroutineDispatcher() + kotlinx.coroutines.Job())
-
- /**
- * The [InstantSource] representing the clock of this service.
- */
- private val clock = dispatcher.timeSource
-
- /**
- * The incoming jobs ready to be processed by the scheduler.
- */
- private val incomingJobs: MutableSet<JobState> = linkedSetOf()
-
- /**
- * The incoming tasks ready to be processed by the scheduler.
- */
- private val incomingTasks: MutableSet<TaskState> = linkedSetOf()
-
- /**
- * The job queue.
- */
- private val jobQueue: Queue<JobState>
-
- /**
- * The task queue.
- */
- private val taskQueue: Queue<TaskState>
-
- /**
- * The active jobs in the system.
- */
- internal val activeJobs: MutableSet<JobState> = mutableSetOf()
-
- /**
- * The active tasks in the system.
- */
- internal val activeTasks: MutableSet<TaskState> = mutableSetOf()
-
- /**
- * The running tasks by [Server].
- */
- private val taskByServer = mutableMapOf<Server, TaskState>()
-
- /**
- * The root listener of this scheduler.
- */
- private val rootListener =
- object : WorkflowSchedulerListener {
- /**
- * The listeners to delegate to.
- */
- val listeners = mutableListOf<WorkflowSchedulerListener>()
-
- override fun jobSubmitted(job: JobState) {
- listeners.forEach { it.jobSubmitted(job) }
- }
-
- override fun jobStarted(job: JobState) {
- listeners.forEach { it.jobStarted(job) }
- }
-
- override fun jobFinished(job: JobState) {
- listeners.forEach { it.jobFinished(job) }
- }
-
- override fun taskReady(task: TaskState) {
- listeners.forEach { it.taskReady(task) }
- }
-
- override fun taskAssigned(task: TaskState) {
- listeners.forEach { it.taskAssigned(task) }
- }
-
- override fun taskStarted(task: TaskState) {
- listeners.forEach { it.taskStarted(task) }
- }
-
- override fun taskFinished(task: TaskState) {
- listeners.forEach { it.taskFinished(task) }
- }
- }
-
- private var localWorkflowsSubmitted: Int = 0
- private var localWorkflowsRunning: Int = 0
- private var localWorkflowsFinished: Int = 0
- private var localTasksSubmitted: Int = 0
- private var localTasksRunning: Int = 0
- private var localTasksFinished: Int = 0
-
- /**
- * The [Pacer] to use for scheduling the scheduler cycles.
- */
- private val pacer =
- Pacer(dispatcher, schedulingQuantum.toMillis()) { doSchedule() }
-
- private val jobAdmissionPolicy: JobAdmissionPolicy.Logic
- private val taskEligibilityPolicy: TaskEligibilityPolicy.Logic
- private lateinit var image: Image
-
- init {
- this.jobAdmissionPolicy = jobAdmissionPolicy(this)
- this.jobQueue = PriorityQueue(100, jobOrderPolicy(this).thenBy { it.job.uid })
- this.taskEligibilityPolicy = taskEligibilityPolicy(this)
- this.taskQueue = PriorityQueue(1000, taskOrderPolicy(this).thenBy { it.task.uid })
-
- scope.launch { image = computeClient.newImage("workflow-runner") }
- }
-
- override suspend fun invoke(job: Job): Unit =
- suspendCancellableCoroutine { cont ->
- // J1 Incoming Jobs
- val jobInstance = JobState(job, clock.millis(), cont)
- val instances =
- job.tasks.associateWith {
- TaskState(jobInstance, it)
- }
-
- for ((task, instance) in instances) {
- instance.dependencies.addAll(task.dependencies.map { instances[it]!! })
- task.dependencies.forEach {
- instances[it]!!.dependents.add(instance)
- }
-
- // If the task has no dependency, it is a root task and can immediately be evaluated
- if (instance.isRoot) {
- instance.state = TaskStatus.READY
- }
-
- localTasksSubmitted++
- }
-
- instances.values.toCollection(jobInstance.tasks)
- incomingJobs += jobInstance
- rootListener.jobSubmitted(jobInstance)
- localWorkflowsSubmitted++
-
- pacer.enqueue()
- }
-
- override fun getSchedulerStats(): SchedulerStats {
- return SchedulerStats(
- localWorkflowsSubmitted,
- localWorkflowsRunning,
- localWorkflowsFinished,
- localTasksSubmitted,
- localTasksRunning,
- localTasksFinished,
- )
- }
-
- override fun close() {
- scope.cancel()
- }
-
- /**
- * Register a [WorkflowSchedulerListener].
- */
- public fun addListener(listener: WorkflowSchedulerListener) {
- rootListener.listeners += listener
- }
-
- /**
- * Unregister a [WorkflowSchedulerListener].
- */
- public fun removeListener(listener: WorkflowSchedulerListener) {
- rootListener.listeners -= listener
- }
-
- /**
- * Perform a scheduling cycle immediately.
- */
- private fun doSchedule() {
- // J2 Create list of eligible jobs
- val iterator = incomingJobs.iterator()
- while (iterator.hasNext()) {
- val jobInstance = iterator.next()
- val advice = jobAdmissionPolicy(jobInstance)
- if (advice.stop) {
- break
- } else if (!advice.admit) {
- continue
- }
-
- iterator.remove()
- jobQueue.add(jobInstance)
- activeJobs += jobInstance
-
- localWorkflowsRunning++
- rootListener.jobStarted(jobInstance)
- }
-
- // J4 Per job
- while (true) {
- val jobInstance = jobQueue.poll() ?: break
-
- // Edge-case: job has no tasks
- if (jobInstance.isFinished) {
- finishJob(jobInstance)
- }
-
- // Add job roots to the scheduling queue
- for (task in jobInstance.tasks) {
- if (task.state != TaskStatus.READY) {
- continue
- }
-
- incomingTasks += task
- rootListener.taskReady(task)
- }
- }
-
- // T1 Create list of eligible tasks
- val taskIterator = incomingTasks.iterator()
- while (taskIterator.hasNext()) {
- val taskInstance = taskIterator.next()
- val advice = taskEligibilityPolicy(taskInstance)
- if (advice.stop) {
- break
- } else if (!advice.admit) {
- continue
- }
-
- taskIterator.remove()
- taskQueue.add(taskInstance)
- }
-
- // T3 Per task
- while (taskQueue.isNotEmpty()) {
- val instance = taskQueue.peek()
-
- val cores = instance.task.metadata[WORKFLOW_TASK_CORES] as? Int ?: 1
- val image = image
- scope.launch {
- val flavor =
- computeClient.newFlavor(
- instance.task.name,
- cores,
- 1000,
- ) // TODO How to determine memory usage for workflow task
- val server =
- computeClient.newServer(
- instance.task.name,
- image,
- flavor,
- start = false,
- meta = instance.task.metadata,
- )
-
- instance.state = TaskStatus.ACTIVE
- instance.server = server
- taskByServer[server] = instance
-
- server.watch(this@WorkflowServiceImpl)
- server.start()
- }
-
- activeTasks += instance
- taskQueue.poll()
- rootListener.taskAssigned(instance)
- }
- }
-
- override fun onStateChanged(
- server: Server,
- newState: ServerState,
- ) {
- when (newState) {
- ServerState.PROVISIONING -> {}
- ServerState.RUNNING -> {
- val task = taskByServer.getValue(server)
- task.startedAt = clock.millis()
- localTasksRunning++
- rootListener.taskStarted(task)
- }
- ServerState.TERMINATED, ServerState.ERROR -> {
- val task = taskByServer.remove(server) ?: throw IllegalStateException()
-
- scope.launch {
- server.delete()
- server.flavor.delete()
- }
-
- val job = task.job
- task.state = TaskStatus.FINISHED
- task.finishedAt = clock.millis()
- job.tasks.remove(task)
- activeTasks -= task
-
- localTasksRunning--
- localTasksFinished++
- rootListener.taskFinished(task)
-
- // Add job roots to the scheduling queue
- for (dependent in task.dependents) {
- if (dependent.state != TaskStatus.READY) {
- continue
- }
-
- incomingTasks += dependent
- rootListener.taskReady(dependent)
- }
-
- if (job.isFinished) {
- finishJob(job)
- }
-
- pacer.enqueue()
- }
- ServerState.DELETED -> {}
- else -> throw IllegalStateException()
- }
- }
-
- private fun finishJob(job: JobState) {
- activeJobs -= job
- localWorkflowsRunning--
- localWorkflowsFinished++
- rootListener.jobFinished(job)
-
- job.cont.resume(Unit)
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/StagePolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/StagePolicy.kt
deleted file mode 100644
index 359fc223..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/StagePolicy.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler
-
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-import java.io.Serializable
-
-/**
- * A scheduling stage policy.
- */
-public interface StagePolicy<T : Any> : Serializable {
- /**
- * Build the logic of the stage policy.
- */
- public operator fun invoke(scheduler: WorkflowServiceImpl): T
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/DurationJobOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/DurationJobOrderPolicy.kt
deleted file mode 100644
index 7ae3244e..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/DurationJobOrderPolicy.kt
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.job
-
-import org.opendc.workflow.api.Job
-import org.opendc.workflow.api.Task
-import org.opendc.workflow.api.WORKFLOW_TASK_DEADLINE
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.internal.WorkflowSchedulerListener
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [JobOrderPolicy] that orders jobs based on its critical path length.
- */
-public data class DurationJobOrderPolicy(val ascending: Boolean = true) : JobOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<JobState> =
- object :
- Comparator<JobState>,
- WorkflowSchedulerListener {
- private val results = HashMap<Job, Long>()
-
- init {
- scheduler.addListener(this)
- }
-
- private val Job.duration: Long
- get() = results[this]!!
-
- override fun jobSubmitted(job: JobState) {
- results[job.job] =
- job.job.toposort().map { task ->
- val estimable = task.metadata[WORKFLOW_TASK_DEADLINE] as? Long?
- estimable ?: Long.MAX_VALUE
- }.sum()
- }
-
- override fun jobFinished(job: JobState) {
- results.remove(job.job)
- }
-
- override fun compare(
- o1: JobState,
- o2: JobState,
- ): Int {
- return compareValuesBy(o1, o2) { it.job.duration }.let { if (ascending) it else -it }
- }
- }
-
- override fun toString(): String {
- return "Job-Duration(${if (ascending) "asc" else "desc"})"
- }
-}
-
-/**
- * Create a topological sorting of the tasks in a job.
- *
- * @return The list of tasks within the job topologically sorted.
- */
-public fun Job.toposort(): List<Task> {
- val res = mutableListOf<Task>()
- val visited = mutableSetOf<Task>()
- val adjacent = mutableMapOf<Task, MutableList<Task>>()
-
- for (task in tasks) {
- for (dependency in task.dependencies) {
- adjacent.getOrPut(dependency) { mutableListOf() }.add(task)
- }
- }
-
- fun visit(task: Task) {
- visited.add(task)
-
- adjacent[task] ?: emptyList<Task>()
- .asSequence()
- .filter { it !in visited }
- .forEach { visit(it) }
-
- res.add(task)
- }
-
- tasks
- .asSequence()
- .filter { it !in visited }
- .forEach { visit(it) }
- return res
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/JobAdmissionPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/JobAdmissionPolicy.kt
deleted file mode 100644
index 475c8f97..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/JobAdmissionPolicy.kt
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.job
-
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.scheduler.StagePolicy
-
-/**
- * A policy interface for admitting [JobState]s to a scheduling cycle.
- */
-public interface JobAdmissionPolicy : StagePolicy<JobAdmissionPolicy.Logic> {
- public interface Logic {
- /**
- * Determine whether the specified [JobState] should be admitted to the scheduling cycle.
- *
- * @param job The workflow that has been submitted.
- * @return The advice for admitting the job.
- */
- public operator fun invoke(job: JobState): Advice
- }
-
- /**
- * The advice given to the scheduler by an admission policy.
- *
- * @property admit A flag to indicate to the scheduler that the job should be admitted.
- * @property stop A flag to indicate the scheduler should immediately stop admitting jobs to the scheduling queue and wait
- * for the next scheduling cycle.
- */
- public enum class Advice(public val admit: Boolean, public val stop: Boolean) {
- /**
- * Admit the current job to the scheduling queue and continue admitting jobs.
- */
- ADMIT(true, false),
-
- /**
- * Admit the current job to the scheduling queue and stop admitting jobs.
- */
- ADMIT_LAST(true, true),
-
- /**
- * Deny the current job, but continue admitting jobs.
- */
- DENY(false, false),
-
- /**
- * Deny the current job and also stop admitting jobs.
- */
- STOP(false, true),
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/JobOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/JobOrderPolicy.kt
deleted file mode 100644
index adaa6671..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/JobOrderPolicy.kt
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.job
-
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.scheduler.StagePolicy
-
-/**
- * A policy interface for ordering admitted workflows in the scheduling queue.
- */
-public interface JobOrderPolicy : StagePolicy<Comparator<JobState>>
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/LimitJobAdmissionPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/LimitJobAdmissionPolicy.kt
deleted file mode 100644
index f1b81259..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/LimitJobAdmissionPolicy.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.job
-
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [JobAdmissionPolicy] that limits the amount of active jobs in the system.
- *
- * @property limit The maximum number of concurrent jobs in the system.
- */
-public data class LimitJobAdmissionPolicy(public val limit: Int) : JobAdmissionPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): JobAdmissionPolicy.Logic =
- object : JobAdmissionPolicy.Logic {
- override fun invoke(job: JobState): JobAdmissionPolicy.Advice =
- if (scheduler.activeJobs.size < limit) {
- JobAdmissionPolicy.Advice.ADMIT
- } else {
- JobAdmissionPolicy.Advice.STOP
- }
- }
-
- override fun toString(): String = "Limit-Active($limit)"
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/NullJobAdmissionPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/NullJobAdmissionPolicy.kt
deleted file mode 100644
index 731a0047..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/NullJobAdmissionPolicy.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.job
-
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [JobAdmissionPolicy] that admits all jobs.
- */
-public object NullJobAdmissionPolicy : JobAdmissionPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): JobAdmissionPolicy.Logic =
- object : JobAdmissionPolicy.Logic {
- override fun invoke(job: JobState): JobAdmissionPolicy.Advice = JobAdmissionPolicy.Advice.ADMIT
- }
-
- override fun toString(): String = "Always"
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/RandomJobOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/RandomJobOrderPolicy.kt
deleted file mode 100644
index ea005e97..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/RandomJobOrderPolicy.kt
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.job
-
-import org.opendc.workflow.api.Job
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.internal.WorkflowSchedulerListener
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-import java.util.Random
-import kotlin.collections.HashMap
-
-/**
- * A [JobOrderPolicy] that randomly orders jobs.
- */
-public object RandomJobOrderPolicy : JobOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<JobState> =
- object :
- Comparator<JobState>,
- WorkflowSchedulerListener {
- private val random = Random(123)
- private val ids = HashMap<Job, Int>()
-
- init {
- scheduler.addListener(this)
- }
-
- override fun jobSubmitted(job: JobState) {
- ids[job.job] = random.nextInt()
- }
-
- override fun jobFinished(job: JobState) {
- ids.remove(job.job)
- }
-
- override fun compare(
- o1: JobState,
- o2: JobState,
- ): Int {
- return compareValuesBy(o1, o2) { ids.getValue(it.job) }
- }
- }
-
- override fun toString(): String {
- return "Random"
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/SizeJobOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/SizeJobOrderPolicy.kt
deleted file mode 100644
index 6998606d..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/SizeJobOrderPolicy.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.job
-
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [SizeJobOrderPolicy] that orders jobs based on the number of tasks it has.
- */
-public data class SizeJobOrderPolicy(public val ascending: Boolean = true) : JobOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<JobState> =
- compareBy { it.tasks.size.let { if (ascending) it else -it } }
-
- override fun toString(): String {
- return "Job-Size(${if (ascending) "asc" else "desc"})"
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/SubmissionTimeJobOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/SubmissionTimeJobOrderPolicy.kt
deleted file mode 100644
index 53d06023..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/job/SubmissionTimeJobOrderPolicy.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.job
-
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [JobOrderPolicy] orders jobs in FIFO order.
- */
-public data class SubmissionTimeJobOrderPolicy(public val ascending: Boolean = true) : JobOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<JobState> =
- compareBy { it.submittedAt.let { if (ascending) it else -it } }
-
- override fun toString(): String {
- return "Submission-Time(${if (ascending) "asc" else "desc"})"
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/ActiveTaskOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/ActiveTaskOrderPolicy.kt
deleted file mode 100644
index 48fdafe9..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/ActiveTaskOrderPolicy.kt
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowSchedulerListener
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [TaskOrderPolicy] that orders tasks based on the number of active relative tasks (w.r.t. its job) in the system.
- */
-public data class ActiveTaskOrderPolicy(public val ascending: Boolean = true) : TaskOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<TaskState> =
- object : Comparator<TaskState>, WorkflowSchedulerListener {
- private val active = mutableMapOf<JobState, Int>()
-
- init {
- scheduler.addListener(this)
- }
-
- override fun jobStarted(job: JobState) {
- active[job] = 0
- }
-
- override fun jobFinished(job: JobState) {
- active.remove(job)
- }
-
- override fun taskAssigned(task: TaskState) {
- active.merge(task.job, 1, Int::plus)
- }
-
- override fun taskFinished(task: TaskState) {
- active.merge(task.job, -1, Int::plus)
- }
-
- override fun compare(
- o1: TaskState,
- o2: TaskState,
- ): Int {
- return compareValuesBy(o1, o2) { active.getValue(it.job) }.let {
- if (ascending) it else -it
- }
- }
- }
-
- override fun toString(): String {
- return "Active-Per-Job(${if (ascending) "asc" else "desc"})"
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/BalancingTaskEligibilityPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/BalancingTaskEligibilityPolicy.kt
deleted file mode 100644
index a2c11e4d..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/BalancingTaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowSchedulerListener
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-import kotlin.math.max
-
-/**
- * A [TaskEligibilityPolicy] that balances the tasks based on their job, e.g. do not allow a single job to claim all
- * resources of the system.
- *
- * @property tolerance The maximum difference from the average number of tasks per job in the system as a fraction of
- * the average.
- */
-public data class BalancingTaskEligibilityPolicy(public val tolerance: Double = 1.5) : TaskEligibilityPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): TaskEligibilityPolicy.Logic =
- object : TaskEligibilityPolicy.Logic, WorkflowSchedulerListener {
- private val active = mutableMapOf<JobState, Int>()
-
- init {
- scheduler.addListener(this)
- }
-
- override fun jobStarted(job: JobState) {
- active[job] = 0
- }
-
- override fun jobFinished(job: JobState) {
- active.remove(job)
- }
-
- override fun taskAssigned(task: TaskState) {
- active.merge(task.job, 1, Int::plus)
- }
-
- override fun taskFinished(task: TaskState) {
- active.merge(task.job, -1, Int::plus)
- }
-
- override fun invoke(task: TaskState): TaskEligibilityPolicy.Advice {
- val activeJobs = scheduler.activeJobs.size
- val activeTasks = scheduler.activeTasks.size
- val baseline = max(activeTasks / activeJobs.toDouble(), 1.0)
- val activeForJob = active[task.job]!!
- return if ((activeForJob + 1) / baseline < tolerance) {
- TaskEligibilityPolicy.Advice.ADMIT
- } else {
- TaskEligibilityPolicy.Advice.DENY
- }
- }
- }
-
- override fun toString(): String = "Job-Balance($tolerance)"
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/CompletionTaskOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/CompletionTaskOrderPolicy.kt
deleted file mode 100644
index 104de105..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/CompletionTaskOrderPolicy.kt
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowSchedulerListener
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [TaskOrderPolicy] that orders tasks based on the number of completed relative tasks.
- */
-public data class CompletionTaskOrderPolicy(public val ascending: Boolean = true) : TaskOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<TaskState> =
- object : Comparator<TaskState>, WorkflowSchedulerListener {
- private val finished = mutableMapOf<JobState, Int>()
-
- init {
- scheduler.addListener(this)
- }
-
- override fun jobStarted(job: JobState) {
- finished[job] = 0
- }
-
- override fun jobFinished(job: JobState) {
- finished.remove(job)
- }
-
- override fun taskFinished(task: TaskState) {
- finished.merge(task.job, 1, Int::plus)
- }
-
- override fun compare(
- o1: TaskState,
- o2: TaskState,
- ): Int {
- return compareValuesBy(o1, o2) { finished.getValue(it.job) / it.job.tasks.size.toDouble() }.let {
- if (ascending) it else -it
- }
- }
- }
-
- override fun toString(): String {
- return "Job-Completion(${if (ascending) "asc" else "desc"})"
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DependenciesTaskOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DependenciesTaskOrderPolicy.kt
deleted file mode 100644
index df9ebfad..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DependenciesTaskOrderPolicy.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [TaskOrderPolicy] that orders tasks based on the number of dependency tasks it has.
- */
-public data class DependenciesTaskOrderPolicy(public val ascending: Boolean = true) : TaskOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<TaskState> =
- compareBy {
- it.task.dependencies.size.let { if (ascending) it else -it }
- }
-
- override fun toString(): String {
- return "Task-Dependencies(${if (ascending) "asc" else "desc"})"
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DependentsTaskOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DependentsTaskOrderPolicy.kt
deleted file mode 100644
index bbc20348..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DependentsTaskOrderPolicy.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [TaskOrderPolicy] that orders tasks based on the number of dependent tasks it has.
- */
-public data class DependentsTaskOrderPolicy(public val ascending: Boolean = true) : TaskOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<TaskState> =
- compareBy {
- it.dependents.size.let { if (ascending) it else -it }
- }
-
- override fun toString(): String {
- return "Task-Dependents(${if (ascending) "asc" else "desc"})"
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DurationHistoryTaskOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DurationHistoryTaskOrderPolicy.kt
deleted file mode 100644
index e21acb41..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DurationHistoryTaskOrderPolicy.kt
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowSchedulerListener
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [TaskOrderPolicy] that orders tasks based on the average duration of the preceding tasks in the job.
- */
-public data class DurationHistoryTaskOrderPolicy(public val ascending: Boolean = true) : TaskOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<TaskState> =
- object : Comparator<TaskState>, WorkflowSchedulerListener {
- private val results = HashMap<JobState, MutableList<Long>>()
-
- init {
- scheduler.addListener(this)
- }
-
- override fun jobStarted(job: JobState) {
- results[job] = mutableListOf()
- }
-
- override fun jobFinished(job: JobState) {
- results.remove(job)
- }
-
- override fun taskFinished(task: TaskState) {
- results.getValue(task.job) += task.finishedAt - task.startedAt
- }
-
- override fun compare(
- o1: TaskState,
- o2: TaskState,
- ): Int {
- return compareValuesBy(o1, o2) { key ->
- val history = results.getValue(key.job)
- if (history.isEmpty()) {
- Long.MAX_VALUE
- } else {
- history.average()
- }
- }.let { if (ascending) it else -it }
- }
- }
-
- override fun toString(): String {
- return "Task-Duration-History(${if (ascending) "asc" else "desc"})"
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DurationTaskOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DurationTaskOrderPolicy.kt
deleted file mode 100644
index 170f3394..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/DurationTaskOrderPolicy.kt
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.api.WORKFLOW_TASK_DEADLINE
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowSchedulerListener
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-import java.util.UUID
-import kotlin.collections.HashMap
-import kotlin.collections.getValue
-import kotlin.collections.set
-
-/**
- * A [TaskOrderPolicy] orders tasks based on the pre-specified (approximate) duration of the task.
- */
-public data class DurationTaskOrderPolicy(public val ascending: Boolean = true) : TaskOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<TaskState> =
- object : Comparator<TaskState>, WorkflowSchedulerListener {
- private val results = HashMap<UUID, Long>()
-
- init {
- scheduler.addListener(this)
- }
-
- override fun taskReady(task: TaskState) {
- val deadline = task.task.metadata[WORKFLOW_TASK_DEADLINE] as? Long?
- results[task.task.uid] = deadline ?: Long.MAX_VALUE
- }
-
- override fun taskFinished(task: TaskState) {
- results -= task.task.uid
- }
-
- private val TaskState.duration: Long
- get() = results.getValue(task.uid)
-
- override fun compare(
- o1: TaskState,
- o2: TaskState,
- ): Int {
- return compareValuesBy(o1, o2) { state -> state.duration }.let {
- if (ascending) it else -it
- }
- }
- }
-
- override fun toString(): String {
- return "Task-Duration(${if (ascending) "asc" else "desc"})"
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/LimitPerJobTaskEligibilityPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/LimitPerJobTaskEligibilityPolicy.kt
deleted file mode 100644
index b0eb3f2c..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/LimitPerJobTaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.JobState
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowSchedulerListener
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [TaskEligibilityPolicy] that limits the number of active tasks of a job in the system.
- */
-public data class LimitPerJobTaskEligibilityPolicy(public val limit: Int) : TaskEligibilityPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): TaskEligibilityPolicy.Logic =
- object : TaskEligibilityPolicy.Logic, WorkflowSchedulerListener {
- private val active = mutableMapOf<JobState, Int>()
-
- init {
- scheduler.addListener(this)
- }
-
- override fun jobStarted(job: JobState) {
- active[job] = 0
- }
-
- override fun jobFinished(job: JobState) {
- active.remove(job)
- }
-
- override fun taskAssigned(task: TaskState) {
- active.merge(task.job, 1, Int::plus)
- }
-
- override fun taskFinished(task: TaskState) {
- active.merge(task.job, -1, Int::plus)
- }
-
- override fun invoke(task: TaskState): TaskEligibilityPolicy.Advice {
- val activeForJob = active[task.job]!!
- return if (activeForJob <= limit) {
- TaskEligibilityPolicy.Advice.ADMIT
- } else {
- TaskEligibilityPolicy.Advice.DENY
- }
- }
- }
-
- override fun toString(): String = "Limit-Active-Job($limit)"
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/LimitTaskEligibilityPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/LimitTaskEligibilityPolicy.kt
deleted file mode 100644
index 0e9c93da..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/LimitTaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [TaskEligibilityPolicy] that limits the total number of active tasks in the system.
- */
-public data class LimitTaskEligibilityPolicy(val limit: Int) : TaskEligibilityPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): TaskEligibilityPolicy.Logic =
- object : TaskEligibilityPolicy.Logic {
- override fun invoke(task: TaskState): TaskEligibilityPolicy.Advice =
- if (scheduler.activeTasks.size < limit) {
- TaskEligibilityPolicy.Advice.ADMIT
- } else {
- TaskEligibilityPolicy.Advice.STOP
- }
- }
-
- override fun toString(): String = "Limit-Active($limit)"
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/NullTaskEligibilityPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/NullTaskEligibilityPolicy.kt
deleted file mode 100644
index 50a11784..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/NullTaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [TaskEligibilityPolicy] that always allows new tasks to enter.
- */
-public object NullTaskEligibilityPolicy : TaskEligibilityPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): TaskEligibilityPolicy.Logic = Logic
-
- private object Logic : TaskEligibilityPolicy.Logic {
- override fun invoke(task: TaskState): TaskEligibilityPolicy.Advice = TaskEligibilityPolicy.Advice.ADMIT
- }
-
- override fun toString(): String = "Always"
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/RandomTaskEligibilityPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/RandomTaskEligibilityPolicy.kt
deleted file mode 100644
index a883ac99..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/RandomTaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-import java.util.Random
-
-/**
- * A [TaskEligibilityPolicy] that randomly accepts tasks in the system with some [probability].
- */
-public data class RandomTaskEligibilityPolicy(val probability: Double = 0.5) : TaskEligibilityPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): TaskEligibilityPolicy.Logic =
- object : TaskEligibilityPolicy.Logic {
- val random = Random(123)
-
- override fun invoke(task: TaskState): TaskEligibilityPolicy.Advice =
- if (random.nextDouble() <= probability || scheduler.activeTasks.isEmpty()) {
- TaskEligibilityPolicy.Advice.ADMIT
- } else {
- TaskEligibilityPolicy.Advice.DENY
- }
- }
-
- override fun toString(): String = "Random($probability)"
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/RandomTaskOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/RandomTaskOrderPolicy.kt
deleted file mode 100644
index 134d22e0..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/RandomTaskOrderPolicy.kt
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.api.Task
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowSchedulerListener
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-import kotlin.random.Random
-
-/**
- * A [TaskOrderPolicy] that orders the tasks randomly.
- */
-public object RandomTaskOrderPolicy : TaskOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<TaskState> =
- object : Comparator<TaskState>, WorkflowSchedulerListener {
- private val random = Random(123)
- private val ids = HashMap<Task, Int>()
-
- init {
- scheduler.addListener(this)
- }
-
- override fun taskReady(task: TaskState) {
- ids[task.task] = random.nextInt()
- }
-
- override fun taskFinished(task: TaskState) {
- ids.remove(task.task)
- }
-
- override fun compare(
- o1: TaskState,
- o2: TaskState,
- ): Int {
- return compareValuesBy(o1, o2) { ids.getValue(it.task) }
- }
- }
-
- override fun toString(): String {
- return "Random"
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/SubmissionTimeTaskOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/SubmissionTimeTaskOrderPolicy.kt
deleted file mode 100644
index 3b4bca8f..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/SubmissionTimeTaskOrderPolicy.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.internal.WorkflowServiceImpl
-
-/**
- * A [TaskOrderPolicy] that orders tasks based on the order of arrival in the queue.
- */
-public data class SubmissionTimeTaskOrderPolicy(public val ascending: Boolean = true) : TaskOrderPolicy {
- override fun invoke(scheduler: WorkflowServiceImpl): Comparator<TaskState> =
- compareBy {
- it.job.submittedAt.let { if (ascending) it else -it }
- }
-
- override fun toString(): String {
- return "Submission-Time(${if (ascending) "asc" else "desc"})"
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/TaskEligibilityPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/TaskEligibilityPolicy.kt
deleted file mode 100644
index 89ec3847..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/TaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.scheduler.StagePolicy
-
-/**
- * A policy interface for determining the eligibility of tasks in a scheduling cycle.
- */
-public interface TaskEligibilityPolicy : StagePolicy<TaskEligibilityPolicy.Logic> {
- public interface Logic {
- /**
- * Determine whether the specified [TaskState] is eligible to be scheduled.
- *
- * @param task The task instance to schedule.
- * @return The advice for marking the task.
- */
- public operator fun invoke(task: TaskState): Advice
- }
-
- /**
- * The advice given to the scheduler by an admission policy.
- *
- * @property admit A flag to indicate to the scheduler that the job should be admitted.
- * @property stop A flag to indicate the scheduler should immediately stop admitting jobs to the scheduling queue and wait
- * for the next scheduling cycle.
- */
- public enum class Advice(public val admit: Boolean, public val stop: Boolean) {
- /**
- * Admit the current job to the scheduling queue and continue admitting jobs.
- */
- ADMIT(true, false),
-
- /**
- * Admit the current job to the scheduling queue and stop admitting jobs.
- */
- ADMIT_LAST(true, true),
-
- /**
- * Deny the current job, but continue admitting jobs.
- */
- DENY(false, false),
-
- /**
- * Deny the current job and also stop admitting jobs.
- */
- STOP(false, true),
- }
-}
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/TaskOrderPolicy.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/TaskOrderPolicy.kt
deleted file mode 100644
index fffcb765..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/task/TaskOrderPolicy.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2021 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.workflow.service.scheduler.task
-
-import org.opendc.workflow.service.internal.TaskState
-import org.opendc.workflow.service.scheduler.StagePolicy
-
-/**
- * This interface represents the **T2** stage of the Reference Architecture for Topology Schedulers and provides the
- * scheduler with a sorted list of tasks to schedule.
- */
-public interface TaskOrderPolicy : StagePolicy<Comparator<TaskState>>
diff --git a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/telemetry/SchedulerStats.kt b/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/telemetry/SchedulerStats.kt
deleted file mode 100644
index c4f180b1..00000000
--- a/opendc-workflow/opendc-workflow-service/src/main/kotlin/org/opendc/workflow/service/scheduler/telemetry/SchedulerStats.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2022 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.workflow.service.scheduler.telemetry
-
-/**
- * Statistics about the workflow scheduler.
- *
- * @property workflowsSubmitted The number of workflows submitted to the scheduler.
- * @property workflowsRunning The number of workflows that are currently running.
- * @property workflowsFinished The number of workflows that have completed since the scheduler started.
- * @property tasksSubmitted The number of tasks submitted to the scheduler.
- * @property tasksRunning The number of tasks that are currently running.
- * @property tasksFinished The number of tasks that have completed.
- */
-public data class SchedulerStats(
- val workflowsSubmitted: Int,
- val workflowsRunning: Int,
- val workflowsFinished: Int,
- val tasksSubmitted: Int,
- val tasksRunning: Int,
- val tasksFinished: Int,
-)