summaryrefslogtreecommitdiff
path: root/simulator/opendc-workflows/src/main
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-03-09 20:29:33 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-03-09 20:33:29 +0100
commit40e5871e01858a55372bfcb51cf90069c080e751 (patch)
treebc880252a935cc0b1558c50fe83f71d21b735d29 /simulator/opendc-workflows/src/main
parent44ed0023ed783437c3c838780f73e28efe1cc4ca (diff)
workflow: Split workflow module in API and service module
Diffstat (limited to 'simulator/opendc-workflows/src/main')
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/JobState.kt39
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/StageWorkflowSchedulerListener.kt37
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/StageWorkflowService.kt355
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/TaskState.kt83
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/TaskStatus.kt35
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowEvent.kt79
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowSchedulerMode.kt105
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowService.kt44
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/StagePolicy.kt36
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/DurationJobOrderPolicy.kt100
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/JobAdmissionPolicy.kt70
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/JobOrderPolicy.kt31
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/LimitJobAdmissionPolicy.kt45
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/NullJobAdmissionPolicy.kt37
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/RandomJobOrderPolicy.kt63
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/SizeJobOrderPolicy.kt38
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/SubmissionTimeJobOrderPolicy.kt38
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/ActiveTaskOrderPolicy.kt68
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/BalancingTaskEligibilityPolicy.kt76
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/CompletionTaskOrderPolicy.kt64
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DependenciesTaskOrderPolicy.kt39
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DependentsTaskOrderPolicy.kt39
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DurationHistoryTaskOrderPolicy.kt69
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DurationTaskOrderPolicy.kt70
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/LimitPerJobTaskEligibilityPolicy.kt68
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/LimitTaskEligibilityPolicy.kt43
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/NullTaskEligibilityPolicy.kt41
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/RandomTaskEligibilityPolicy.kt45
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/RandomTaskOrderPolicy.kt62
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/SubmissionTimeTaskOrderPolicy.kt41
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/TaskEligibilityPolicy.kt72
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/TaskOrderPolicy.kt34
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Job.kt46
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Metadata.kt35
-rw-r--r--simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Task.kt47
35 files changed, 0 insertions, 2194 deletions
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/JobState.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/JobState.kt
deleted file mode 100644
index 89849f6a..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/JobState.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service
-
-import org.opendc.workflows.workload.Job
-
-public class JobState(public val job: Job, public val submittedAt: Long) {
- /**
- * 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/StageWorkflowSchedulerListener.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/StageWorkflowSchedulerListener.kt
deleted file mode 100644
index 18721889..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/StageWorkflowSchedulerListener.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service
-
-public interface StageWorkflowSchedulerListener {
- public fun cycleStarted(scheduler: StageWorkflowService) {}
- public fun cycleFinished(scheduler: StageWorkflowService) {}
-
- public fun jobSubmitted(job: JobState) {}
- public fun jobStarted(job: JobState) {}
- public fun jobFinished(job: JobState) {}
-
- public fun taskReady(task: TaskState) {}
- public fun taskAssigned(task: TaskState) {}
- public fun taskStarted(task: TaskState) {}
- public fun taskFinished(task: TaskState) {}
-}
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/StageWorkflowService.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/StageWorkflowService.kt
deleted file mode 100644
index c5c4bf97..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/StageWorkflowService.kt
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service
-
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.launch
-import mu.KotlinLogging
-import org.opendc.compute.api.*
-import org.opendc.trace.core.EventTracer
-import org.opendc.trace.core.consumeAsFlow
-import org.opendc.trace.core.enable
-import org.opendc.workflows.service.stage.job.JobAdmissionPolicy
-import org.opendc.workflows.service.stage.job.JobOrderPolicy
-import org.opendc.workflows.service.stage.task.TaskEligibilityPolicy
-import org.opendc.workflows.service.stage.task.TaskOrderPolicy
-import org.opendc.workflows.workload.Job
-import org.opendc.workflows.workload.WORKFLOW_TASK_CORES
-import java.time.Clock
-import java.util.*
-
-/**
- * A [WorkflowService] that distributes work through a multi-stage process based on the Reference Architecture for
- * Datacenter Scheduling.
- */
-public class StageWorkflowService(
- internal val coroutineScope: CoroutineScope,
- internal val clock: Clock,
- internal val tracer: EventTracer,
- private val computeClient: ComputeClient,
- mode: WorkflowSchedulerMode,
- jobAdmissionPolicy: JobAdmissionPolicy,
- jobOrderPolicy: JobOrderPolicy,
- taskEligibilityPolicy: TaskEligibilityPolicy,
- taskOrderPolicy: TaskOrderPolicy
-) : WorkflowService, ServerWatcher {
- /**
- * The logger instance to use.
- */
- private val logger = KotlinLogging.logger {}
-
- /**
- * The incoming jobs ready to be processed by the scheduler.
- */
- internal val incomingJobs: MutableSet<JobState> = linkedSetOf()
-
- /**
- * The incoming tasks ready to be processed by the scheduler.
- */
- internal val incomingTasks: MutableSet<TaskState> = linkedSetOf()
-
- /**
- * The job queue.
- */
- internal val jobQueue: Queue<JobState>
-
- /**
- * The task queue.
- */
- internal 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].
- */
- internal val taskByServer = mutableMapOf<Server, TaskState>()
-
- /**
- * The root listener of this scheduler.
- */
- private val rootListener = object : StageWorkflowSchedulerListener {
- /**
- * The listeners to delegate to.
- */
- val listeners = mutableSetOf<StageWorkflowSchedulerListener>()
-
- override fun cycleStarted(scheduler: StageWorkflowService) {
- listeners.forEach { it.cycleStarted(scheduler) }
- }
-
- override fun cycleFinished(scheduler: StageWorkflowService) {
- listeners.forEach { it.cycleFinished(scheduler) }
- }
-
- 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 val mode: WorkflowSchedulerMode.Logic
- private val jobAdmissionPolicy: JobAdmissionPolicy.Logic
- private val taskEligibilityPolicy: TaskEligibilityPolicy.Logic
- private lateinit var image: Image
-
- init {
- this.mode = mode(this)
- 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 })
- coroutineScope.launch {
- image = computeClient.newImage("workflow-runner")
- }
- }
-
- override val events: Flow<WorkflowEvent> = tracer.openRecording().let {
- it.enable<WorkflowEvent.JobSubmitted>()
- it.enable<WorkflowEvent.JobStarted>()
- it.enable<WorkflowEvent.JobFinished>()
- it.enable<WorkflowEvent.TaskStarted>()
- it.enable<WorkflowEvent.TaskFinished>()
- it.consumeAsFlow().map { event -> event as WorkflowEvent }
- }
-
- override suspend fun submit(job: Job) {
- // J1 Incoming Jobs
- val jobInstance = JobState(job, clock.millis())
- 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
- }
- }
-
- instances.values.toCollection(jobInstance.tasks)
- incomingJobs += jobInstance
- rootListener.jobSubmitted(jobInstance)
- tracer.commit(WorkflowEvent.JobSubmitted(this, jobInstance.job))
-
- requestCycle()
- }
-
- /**
- * Indicate to the scheduler that a scheduling cycle is needed.
- */
- private fun requestCycle() = mode.requestCycle()
-
- /**
- * Perform a scheduling cycle immediately.
- */
- @OptIn(ExperimentalCoroutinesApi::class)
- internal suspend fun schedule() {
- // 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
- tracer.commit(WorkflowEvent.JobStarted(this, jobInstance.job))
- rootListener.jobStarted(jobInstance)
- }
-
- // J4 Per job
- while (jobQueue.isNotEmpty()) {
- val jobInstance = jobQueue.poll()
-
- // 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
- coroutineScope.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@StageWorkflowService)
- server.start()
- }
-
- activeTasks += instance
- taskQueue.poll()
- rootListener.taskAssigned(instance)
- }
- }
-
- public override fun onStateChanged(server: Server, newState: ServerState) {
- when (newState) {
- ServerState.PROVISIONING -> {}
- ServerState.RUNNING -> {
- val task = taskByServer.getValue(server)
- task.startedAt = clock.millis()
- tracer.commit(
- WorkflowEvent.TaskStarted(
- this@StageWorkflowService,
- task.job.job,
- task.task
- )
- )
- rootListener.taskStarted(task)
- }
- ServerState.TERMINATED, ServerState.ERROR -> {
- val task = taskByServer.remove(server) ?: throw IllegalStateException()
-
- coroutineScope.launch {
- server.delete()
- server.flavor.delete()
- }
-
- val job = task.job
- task.state = TaskStatus.FINISHED
- task.finishedAt = clock.millis()
- job.tasks.remove(task)
- activeTasks -= task
- tracer.commit(
- WorkflowEvent.TaskFinished(
- this@StageWorkflowService,
- task.job.job,
- task.task
- )
- )
- 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)
- }
-
- requestCycle()
- }
- ServerState.DELETED -> {}
- else -> throw IllegalStateException()
- }
- }
-
- private fun finishJob(job: JobState) {
- activeJobs -= job
- tracer.commit(WorkflowEvent.JobFinished(this, job.job))
- rootListener.jobFinished(job)
- }
-
- public fun addListener(listener: StageWorkflowSchedulerListener) {
- rootListener.listeners += listener
- }
-
- public fun removeListener(listener: StageWorkflowSchedulerListener) {
- rootListener.listeners -= listener
- }
-}
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/TaskState.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/TaskState.kt
deleted file mode 100644
index ef9714c2..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/TaskState.kt
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service
-
-import org.opendc.compute.api.Server
-import org.opendc.workflows.workload.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<TaskState>()
-
- /**
- * The dependents of this task.
- */
- public val dependents: HashSet<TaskState> = HashSet<TaskState>()
-
- /**
- * 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/TaskStatus.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/TaskStatus.kt
deleted file mode 100644
index 99f5bb87..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/TaskStatus.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2020 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.workflows.service
-
-/**
- * The state of a workflow task.
- */
-public enum class TaskStatus {
- CREATED,
- READY,
- ACTIVE,
- FINISHED
-}
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowEvent.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowEvent.kt
deleted file mode 100644
index bcf93562..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowEvent.kt
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service
-
-import org.opendc.trace.core.Event
-import org.opendc.workflows.workload.Job
-import org.opendc.workflows.workload.Task
-
-/**
- * An event emitted by the [WorkflowService].
- */
-public sealed class WorkflowEvent : Event() {
- /**
- * The [WorkflowService] that emitted the event.
- */
- public abstract val service: WorkflowService
-
- /**
- * This event is emitted when a job was submitted to the scheduler.
- */
- public data class JobSubmitted(
- override val service: WorkflowService,
- public val job: Job
- ) : WorkflowEvent()
-
- /**
- * This event is emitted when a job has become active.
- */
- public data class JobStarted(
- override val service: WorkflowService,
- public val job: Job
- ) : WorkflowEvent()
-
- /**
- * This event is emitted when a job has finished processing.
- */
- public data class JobFinished(
- override val service: WorkflowService,
- public val job: Job
- ) : WorkflowEvent()
-
- /**
- * This event is emitted when a task of a job has started processing.
- */
- public data class TaskStarted(
- override val service: WorkflowService,
- public val job: Job,
- public val task: Task
- ) : WorkflowEvent()
-
- /**
- * This event is emitted when a task of a job has started processing.
- */
- public data class TaskFinished(
- override val service: WorkflowService,
- public val job: Job,
- public val task: Task
- ) : WorkflowEvent()
-}
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowSchedulerMode.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowSchedulerMode.kt
deleted file mode 100644
index cf8f92e0..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowSchedulerMode.kt
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service
-
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.launch
-import org.opendc.workflows.service.stage.StagePolicy
-
-/**
- * The operating mode of a workflow scheduler.
- */
-public sealed class WorkflowSchedulerMode : StagePolicy<WorkflowSchedulerMode.Logic> {
- /**
- * The logic for operating the cycles of a workflow scheduler.
- */
- public interface Logic {
- /**
- * Request a new scheduling cycle to be performed.
- */
- public fun requestCycle()
- }
-
- /**
- * An interactive scheduler immediately triggers a new scheduling cycle when a workflow is received.
- */
- public object Interactive : WorkflowSchedulerMode() {
- override fun invoke(scheduler: StageWorkflowService): Logic = object : Logic {
- override fun requestCycle() {
- scheduler.coroutineScope.launch { scheduler.schedule() }
- }
- }
-
- override fun toString(): String = "Interactive"
- }
-
- /**
- * A batch scheduler triggers a scheduling cycle every time quantum if needed.
- */
- public data class Batch(val quantum: Long) : WorkflowSchedulerMode() {
- private var next: kotlinx.coroutines.Job? = null
-
- override fun invoke(scheduler: StageWorkflowService): Logic = object : Logic {
- override fun requestCycle() {
- if (next == null) {
- // In batch mode, we assume that the scheduler runs at a fixed slot every time
- // quantum (e.g t=0, t=60, t=120). We calculate here the delay until the next scheduling slot.
- val delay = quantum - (scheduler.clock.millis() % quantum)
-
- val job = scheduler.coroutineScope.launch {
- delay(delay)
- next = null
- scheduler.schedule()
- }
- next = job
- }
- }
- }
-
- override fun toString(): String = "Batch($quantum)"
- }
-
- /**
- * A scheduling cycle is triggered at a random point in time.
- */
- public data class Random(private val random: java.util.Random = java.util.Random(123)) : WorkflowSchedulerMode() {
- private var next: kotlinx.coroutines.Job? = null
-
- override fun invoke(scheduler: StageWorkflowService): Logic = object : Logic {
- override fun requestCycle() {
- if (next == null) {
- val delay = random.nextInt(200).toLong()
-
- val job = scheduler.coroutineScope.launch {
- delay(delay)
- next = null
- scheduler.schedule()
- }
- next = job
- }
- }
- }
-
- override fun toString(): String = "Random"
- }
-}
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowService.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowService.kt
deleted file mode 100644
index c43c72f5..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/WorkflowService.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service
-
-import kotlinx.coroutines.flow.Flow
-import org.opendc.workflows.workload.Job
-import java.util.*
-
-/**
- * A service for cloud workflow management.
- *
- * The workflow scheduler is modelled after the Reference Architecture for Topology Scheduling by Andreadis et al.
- */
-public interface WorkflowService {
- /**
- * The events emitted by the workflow scheduler.
- */
- public val events: Flow<WorkflowEvent>
-
- /**
- * Submit the specified [Job] to the workflow service for scheduling.
- */
- public suspend fun submit(job: Job)
-}
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/StagePolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/StagePolicy.kt
deleted file mode 100644
index d76579f9..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/StagePolicy.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage
-
-import org.opendc.workflows.service.StageWorkflowService
-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: StageWorkflowService): T
-}
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/DurationJobOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/DurationJobOrderPolicy.kt
deleted file mode 100644
index 1190a408..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/DurationJobOrderPolicy.kt
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.job
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.StageWorkflowSchedulerListener
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.workload.Job
-import org.opendc.workflows.workload.Task
-import org.opendc.workflows.workload.WORKFLOW_TASK_DEADLINE
-
-/**
- * A [JobOrderPolicy] that orders jobs based on its critical path length.
- */
-public data class DurationJobOrderPolicy(val ascending: Boolean = true) : JobOrderPolicy {
- override fun invoke(scheduler: StageWorkflowService): Comparator<JobState> =
- object : Comparator<JobState>, StageWorkflowSchedulerListener {
- 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/JobAdmissionPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/JobAdmissionPolicy.kt
deleted file mode 100644
index 0e5a42c0..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/JobAdmissionPolicy.kt
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.job
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.stage.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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/JobOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/JobOrderPolicy.kt
deleted file mode 100644
index 83d42b2d..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/JobOrderPolicy.kt
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.job
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.stage.StagePolicy
-
-/**
- * A policy interface for ordering admitted workflows in the scheduling queue.
- */
-public interface JobOrderPolicy : StagePolicy<Comparator<JobState>>
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/LimitJobAdmissionPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/LimitJobAdmissionPolicy.kt
deleted file mode 100644
index 6f6ccb50..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/LimitJobAdmissionPolicy.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.job
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.StageWorkflowService
-
-/**
- * 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: StageWorkflowService): 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/NullJobAdmissionPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/NullJobAdmissionPolicy.kt
deleted file mode 100644
index ac74f090..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/NullJobAdmissionPolicy.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.job
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.StageWorkflowService
-
-/**
- * A [JobAdmissionPolicy] that admits all jobs.
- */
-public object NullJobAdmissionPolicy : JobAdmissionPolicy {
- override fun invoke(scheduler: StageWorkflowService): JobAdmissionPolicy.Logic = object : JobAdmissionPolicy.Logic {
- override fun invoke(job: JobState): JobAdmissionPolicy.Advice = JobAdmissionPolicy.Advice.ADMIT
- }
-
- override fun toString(): String = "Always"
-}
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/RandomJobOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/RandomJobOrderPolicy.kt
deleted file mode 100644
index 6c747261..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/RandomJobOrderPolicy.kt
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.job
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.StageWorkflowSchedulerListener
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.workload.Job
-import java.util.*
-import kotlin.collections.HashMap
-import kotlin.collections.getValue
-import kotlin.collections.set
-
-/**
- * A [JobOrderPolicy] that randomly orders jobs.
- */
-public object RandomJobOrderPolicy : JobOrderPolicy {
- override fun invoke(scheduler: StageWorkflowService): Comparator<JobState> =
- object : Comparator<JobState>, StageWorkflowSchedulerListener {
- 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/SizeJobOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/SizeJobOrderPolicy.kt
deleted file mode 100644
index c1c244c3..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/SizeJobOrderPolicy.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.job
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.StageWorkflowService
-
-/**
- * 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: StageWorkflowService): 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/SubmissionTimeJobOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/SubmissionTimeJobOrderPolicy.kt
deleted file mode 100644
index 005f8153..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/job/SubmissionTimeJobOrderPolicy.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.job
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.StageWorkflowService
-
-/**
- * A [JobOrderPolicy] orders jobs in FIFO order.
- */
-public data class SubmissionTimeJobOrderPolicy(public val ascending: Boolean = true) : JobOrderPolicy {
- override fun invoke(scheduler: StageWorkflowService): 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/ActiveTaskOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/ActiveTaskOrderPolicy.kt
deleted file mode 100644
index 6a465746..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/ActiveTaskOrderPolicy.kt
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.StageWorkflowSchedulerListener
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-
-/**
- * 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: StageWorkflowService): Comparator<TaskState> =
- object : Comparator<TaskState>, StageWorkflowSchedulerListener {
- 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/BalancingTaskEligibilityPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/BalancingTaskEligibilityPolicy.kt
deleted file mode 100644
index f3f19ef5..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/BalancingTaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.StageWorkflowSchedulerListener
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-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: StageWorkflowService): TaskEligibilityPolicy.Logic =
- object : TaskEligibilityPolicy.Logic, StageWorkflowSchedulerListener {
- 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/CompletionTaskOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/CompletionTaskOrderPolicy.kt
deleted file mode 100644
index 0020023f..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/CompletionTaskOrderPolicy.kt
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.StageWorkflowSchedulerListener
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-
-/**
- * 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: StageWorkflowService): Comparator<TaskState> =
- object : Comparator<TaskState>, StageWorkflowSchedulerListener {
- 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DependenciesTaskOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DependenciesTaskOrderPolicy.kt
deleted file mode 100644
index a9f5eb84..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DependenciesTaskOrderPolicy.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-
-/**
- * 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: StageWorkflowService): Comparator<TaskState> = compareBy<TaskState> {
- 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DependentsTaskOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DependentsTaskOrderPolicy.kt
deleted file mode 100644
index e5a9f159..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DependentsTaskOrderPolicy.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-
-/**
- * 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: StageWorkflowService): Comparator<TaskState> = compareBy<TaskState> {
- it.dependents.size.let { if (ascending) it else -it }
- }
-
- override fun toString(): String {
- return "Task-Dependents(${if (ascending) "asc" else "desc"})"
- }
-}
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DurationHistoryTaskOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DurationHistoryTaskOrderPolicy.kt
deleted file mode 100644
index 7ce8ccce..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DurationHistoryTaskOrderPolicy.kt
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.StageWorkflowSchedulerListener
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-
-/**
- * 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: StageWorkflowService): Comparator<TaskState> =
- object : Comparator<TaskState>, StageWorkflowSchedulerListener {
- 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DurationTaskOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DurationTaskOrderPolicy.kt
deleted file mode 100644
index 3674eb01..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/DurationTaskOrderPolicy.kt
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.StageWorkflowSchedulerListener
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-import org.opendc.workflows.workload.WORKFLOW_TASK_DEADLINE
-import java.util.*
-import kotlin.collections.HashMap
-import kotlin.collections.getValue
-import kotlin.collections.minusAssign
-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: StageWorkflowService): Comparator<TaskState> =
- object : Comparator<TaskState>, StageWorkflowSchedulerListener {
- 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/LimitPerJobTaskEligibilityPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/LimitPerJobTaskEligibilityPolicy.kt
deleted file mode 100644
index 2dddbc7c..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/LimitPerJobTaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.JobState
-import org.opendc.workflows.service.StageWorkflowSchedulerListener
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-
-/**
- * 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: StageWorkflowService): TaskEligibilityPolicy.Logic =
- object : TaskEligibilityPolicy.Logic, StageWorkflowSchedulerListener {
- 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/LimitTaskEligibilityPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/LimitTaskEligibilityPolicy.kt
deleted file mode 100644
index fdc1fd5e..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/LimitTaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-
-/**
- * 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: StageWorkflowService): 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/NullTaskEligibilityPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/NullTaskEligibilityPolicy.kt
deleted file mode 100644
index b40f9823..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/NullTaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-
-/**
- * A [TaskEligibilityPolicy] that always allows new tasks to enter.
- */
-public object NullTaskEligibilityPolicy : TaskEligibilityPolicy {
- override fun invoke(scheduler: StageWorkflowService): 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/RandomTaskEligibilityPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/RandomTaskEligibilityPolicy.kt
deleted file mode 100644
index a0691b23..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/RandomTaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-import java.util.*
-
-/**
- * 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: StageWorkflowService): 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/RandomTaskOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/RandomTaskOrderPolicy.kt
deleted file mode 100644
index 890e7165..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/RandomTaskOrderPolicy.kt
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2019 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.StageWorkflowSchedulerListener
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-import org.opendc.workflows.workload.Task
-import kotlin.random.Random
-
-/**
- * A [TaskOrderPolicy] that orders the tasks randomly.
- */
-public object RandomTaskOrderPolicy : TaskOrderPolicy {
- override fun invoke(scheduler: StageWorkflowService): Comparator<TaskState> =
- object : Comparator<TaskState>, StageWorkflowSchedulerListener {
- 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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/SubmissionTimeTaskOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/SubmissionTimeTaskOrderPolicy.kt
deleted file mode 100644
index 6b0199b8..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/SubmissionTimeTaskOrderPolicy.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.StageWorkflowService
-import org.opendc.workflows.service.TaskState
-
-/**
- * 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: StageWorkflowService): Comparator<TaskState> = compareBy<TaskState> {
- it.job.submittedAt.let { if (ascending) it else -it }
- }
-
- override fun toString(): String {
- return "Submission-Time(${if (ascending) "asc" else "desc"})"
- }
-}
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/TaskEligibilityPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/TaskEligibilityPolicy.kt
deleted file mode 100644
index 37597709..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/TaskEligibilityPolicy.kt
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2019 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.TaskState
-import org.opendc.workflows.service.stage.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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/TaskOrderPolicy.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/TaskOrderPolicy.kt
deleted file mode 100644
index 5feac6d0..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/service/stage/task/TaskOrderPolicy.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2020 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.workflows.service.stage.task
-
-import org.opendc.workflows.service.TaskState
-import org.opendc.workflows.service.stage.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/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Job.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Job.kt
deleted file mode 100644
index 53116cb6..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Job.kt
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2020 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.workflows.workload
-
-import java.util.*
-
-/**
- * A workload that represents a directed acyclic graph (DAG) of tasks with control and data dependencies between tasks.
- *
- * @property uid A unique identified of this workflow.
- * @property name The name of this workflow.
- * @property tasks The tasks that are part of this workflow.
- * @property metadata Additional metadata for the job.
- */
-public data class Job(
- val uid: UUID,
- val name: String,
- val tasks: Set<Task>,
- val metadata: Map<String, Any> = emptyMap()
-) {
- override fun equals(other: Any?): Boolean = other is Job && uid == other.uid
-
- override fun hashCode(): Int = uid.hashCode()
-
- override fun toString(): String = "Job(uid=$uid, name=$name, tasks=${tasks.size}, metadata=$metadata)"
-}
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Metadata.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Metadata.kt
deleted file mode 100644
index 4305aa57..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Metadata.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2020 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.workflows.workload
-
-/**
- * Meta-data key for the deadline of a task.
- */
-public const val WORKFLOW_TASK_DEADLINE: String = "workflow:task:deadline"
-
-/**
- * Meta-data key for the number of cores needed for a task.
- */
-public const val WORKFLOW_TASK_CORES: String = "workflow:task:cores"
diff --git a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Task.kt b/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Task.kt
deleted file mode 100644
index 4ccefef9..00000000
--- a/simulator/opendc-workflows/src/main/kotlin/org/opendc/workflows/workload/Task.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2019 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.workflows.workload
-
-import java.util.*
-
-/**
- * A stage of a [Job].
- *
- * @property uid A unique identified of this task.
- * @property name The name of this task.
- * @property image The application image to run as part of this workflow task.
- * @property dependencies The dependencies of this task in order for it to execute.
- * @property metadata Additional metadata for this task.
- */
-public data class Task(
- val uid: UUID,
- val name: String,
- val dependencies: Set<Task>,
- val metadata: Map<String, Any> = emptyMap()
-) {
- override fun equals(other: Any?): Boolean = other is Task && uid == other.uid
-
- override fun hashCode(): Int = uid.hashCode()
-}