From 3363df4c72a064e590ca98f8e01832cfa4e15a3f Mon Sep 17 00:00:00 2001 From: Dante Niewenhuis Date: Tue, 27 Aug 2024 13:48:46 +0200 Subject: Renamed input files and internally server is changed to task (#246) * Updated SimTrace to use a single ArrayDeque instead of three separate lists for deadline, cpuUsage, and coreCount * Renamed input files to tasks.parquet and fragments.parquet. Renamed server to task. OpenDC nows exports tasks.parquet instead of server.parquet --- .../kotlin/org/opendc/compute/api/ComputeClient.kt | 28 ++++---- .../main/kotlin/org/opendc/compute/api/Flavor.kt | 6 +- .../main/kotlin/org/opendc/compute/api/Image.kt | 2 +- .../api/InsufficientServerCapacityException.kt | 31 --------- .../api/InsufficientTaskCapacityException.kt | 31 +++++++++ .../main/kotlin/org/opendc/compute/api/Server.kt | 74 ---------------------- .../kotlin/org/opendc/compute/api/ServerState.kt | 53 ---------------- .../kotlin/org/opendc/compute/api/ServerWatcher.kt | 39 ------------ .../src/main/kotlin/org/opendc/compute/api/Task.kt | 74 ++++++++++++++++++++++ .../kotlin/org/opendc/compute/api/TaskState.kt | 53 ++++++++++++++++ .../kotlin/org/opendc/compute/api/TaskWatcher.kt | 39 ++++++++++++ 11 files changed, 215 insertions(+), 215 deletions(-) delete mode 100644 opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/InsufficientServerCapacityException.kt create mode 100644 opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/InsufficientTaskCapacityException.kt delete mode 100644 opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Server.kt delete mode 100644 opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerState.kt delete mode 100644 opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerWatcher.kt create mode 100644 opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Task.kt create mode 100644 opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/TaskState.kt create mode 100644 opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/TaskWatcher.kt (limited to 'opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api') diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ComputeClient.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ComputeClient.kt index 7863f20b..9e24a3fd 100644 --- a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ComputeClient.kt +++ b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ComputeClient.kt @@ -84,38 +84,38 @@ public interface ComputeClient : AutoCloseable { ): Image /** - * Obtain the list of [Server]s accessible by the requesting user. + * Obtain the list of [Task]s accessible by the requesting user. */ - public fun queryServers(): List + public fun queryTasks(): List /** - * Obtain a [Server] by its unique identifier. + * Obtain a [Task] by its unique identifier. * - * @param id The identifier of the server. + * @param id The identifier of the task. */ - public fun findServer(id: UUID): Server? + public fun findTask(id: UUID): Task? /** - * Create a new [Server] instance at this compute service. + * Create a new [Task] instance at this compute service. * - * @param name The name of the server to deploy. + * @param name The name of the task to deploy. * @param image The image to be deployed. * @param flavor The flavor of the machine instance to run this [image] on. - * @param labels The identifying labels of the server. - * @param meta The non-identifying meta-data of the server. - * @param start A flag to indicate that the server should be started immediately. + * @param labels The identifying labels of the task. + * @param meta The non-identifying meta-data of the task. + * @param start A flag to indicate that the task should be started immediately. */ - public fun newServer( + public fun newTask( name: String, image: Image, flavor: Flavor, labels: Map = emptyMap(), meta: Map = emptyMap(), start: Boolean = true, - ): Server + ): Task - public fun rescheduleServer( - server: Server, + public fun rescheduleTask( + task: Task, workload: SimWorkload, ) diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Flavor.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Flavor.kt index 201a9aed..99042c24 100644 --- a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Flavor.kt +++ b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Flavor.kt @@ -23,8 +23,8 @@ package org.opendc.compute.api /** - * Flavors define the compute and memory capacity of [Server] instance. To put it simply, a flavor is an available - * hardware configuration for a server. It defines the size of a virtual server that can be launched. + * Flavors define the compute and memory capacity of [Task] instance. To put it simply, a flavor is an available + * hardware configuration for a task. It defines the size of a virtual task that can be launched. */ public interface Flavor : Resource { /** @@ -33,7 +33,7 @@ public interface Flavor : Resource { public val coreCount: Int /** - * The amount of RAM available to the server (in MB). + * The amount of RAM available to the task (in MB). */ public val memorySize: Long } diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Image.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Image.kt index c4a04b96..ce7f7f40 100644 --- a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Image.kt +++ b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Image.kt @@ -23,6 +23,6 @@ package org.opendc.compute.api /** - * An image containing a bootable operating system that can directly be executed by physical or virtual server. + * An image containing a bootable operating system that can directly be executed by physical or virtual task. */ public interface Image : Resource diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/InsufficientServerCapacityException.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/InsufficientServerCapacityException.kt deleted file mode 100644 index 497d5266..00000000 --- a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/InsufficientServerCapacityException.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.compute.api - -/** - * This exception is thrown to indicate that the compute service does not have enough capacity at the moment to - * fulfill a launch request. - */ -public class InsufficientServerCapacityException( - override val cause: Throwable? = null, -) : Exception("There was insufficient capacity available to satisfy the launch request") diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/InsufficientTaskCapacityException.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/InsufficientTaskCapacityException.kt new file mode 100644 index 00000000..ef6e4761 --- /dev/null +++ b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/InsufficientTaskCapacityException.kt @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.compute.api + +/** + * This exception is thrown to indicate that the compute service does not have enough capacity at the moment to + * fulfill a launch request. + */ +public class InsufficientTaskCapacityException( + override val cause: Throwable? = null, +) : Exception("There was insufficient capacity available to satisfy the launch request") diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Server.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Server.kt deleted file mode 100644 index b4cc5129..00000000 --- a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Server.kt +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2021 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.compute.api - -import java.time.Instant - -/** - * A stateful object representing a server instance that is running on some physical or virtual machine. - */ -public interface Server : Resource { - /** - * The flavor of the server. - */ - public val flavor: Flavor - - /** - * The image of the server. - */ - public val image: Image - - /** - * The last known state of the server. - */ - public val state: ServerState - - /** - * The most recent moment in time when the server was launched. - */ - public val launchedAt: Instant? - - /** - * Request the server to be started. - */ - public fun start() - - /** - * Request the server to be stopped. - */ - public fun stop() - - /** - * Register the specified [ServerWatcher] to watch the state of the server. - * - * @param watcher The watcher to register for the server. - */ - public fun watch(watcher: ServerWatcher) - - /** - * De-register the specified [ServerWatcher] from the server to stop it from receiving events. - * - * @param watcher The watcher to de-register from the server. - */ - public fun unwatch(watcher: ServerWatcher) -} diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerState.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerState.kt deleted file mode 100644 index a4d7d7d7..00000000 --- a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerState.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2021 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.compute.api - -/** - * An enumeration describing the possible states of a server. - */ -public enum class ServerState { - /** - * Resources are being allocated for the instance. The instance is not running yet. - */ - PROVISIONING, - - /** - * A user shut down the instance. - */ - TERMINATED, - - /** - * The server instance is booting up or running. - */ - RUNNING, - - /** - * The server is in an error state. - */ - ERROR, - - /** - * The server has been deleted and cannot be started later on. - */ - DELETED, -} diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerWatcher.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerWatcher.kt deleted file mode 100644 index 3229e101..00000000 --- a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ServerWatcher.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2021 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.compute.api - -/** - * An interface used to watch the state of [Server] instances. - */ -public interface ServerWatcher { - /** - * This method is invoked when the state of a [Server] changes. - * - * @param server The server whose state has changed. - * @param newState The new state of the server. - */ - public fun onStateChanged( - server: Server, - newState: ServerState, - ) {} -} diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Task.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Task.kt new file mode 100644 index 00000000..c9b0aeb3 --- /dev/null +++ b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Task.kt @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.compute.api + +import java.time.Instant + +/** + * A stateful object representing a task instance that is running on some physical or virtual machine. + */ +public interface Task : Resource { + /** + * The flavor of the task. + */ + public val flavor: Flavor + + /** + * The image of the task. + */ + public val image: Image + + /** + * The last known state of the task. + */ + public val state: TaskState + + /** + * The most recent moment in time when the task was launched. + */ + public val launchedAt: Instant? + + /** + * Request the task to be started. + */ + public fun start() + + /** + * Request the task to be stopped. + */ + public fun stop() + + /** + * Register the specified [TaskWatcher] to watch the state of the task. + * + * @param watcher The watcher to register for the task. + */ + public fun watch(watcher: TaskWatcher) + + /** + * De-register the specified [TaskWatcher] from the task to stop it from receiving events. + * + * @param watcher The watcher to de-register from the task. + */ + public fun unwatch(watcher: TaskWatcher) +} diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/TaskState.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/TaskState.kt new file mode 100644 index 00000000..a093ff47 --- /dev/null +++ b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/TaskState.kt @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.compute.api + +/** + * An enumeration describing the possible states of a task. + */ +public enum class TaskState { + /** + * Resources are being allocated for the instance. The instance is not running yet. + */ + PROVISIONING, + + /** + * A user shut down the instance. + */ + TERMINATED, + + /** + * The task instance is booting up or running. + */ + RUNNING, + + /** + * The task is in an error state. + */ + ERROR, + + /** + * The task has been deleted and cannot be started later on. + */ + DELETED, +} diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/TaskWatcher.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/TaskWatcher.kt new file mode 100644 index 00000000..423d7dec --- /dev/null +++ b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/TaskWatcher.kt @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.compute.api + +/** + * An interface used to watch the state of [Task] instances. + */ +public interface TaskWatcher { + /** + * This method is invoked when the state of a [Task] changes. + * + * @param task The task whose state has changed. + * @param newState The new state of the task. + */ + public fun onStateChanged( + task: Task, + newState: TaskState, + ) {} +} -- cgit v1.2.3