diff options
Diffstat (limited to 'opendc-compute/opendc-compute-api/src/main/kotlin')
6 files changed, 23 insertions, 257 deletions
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 deleted file mode 100644 index 9e24a3fd..00000000 --- a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/ComputeClient.kt +++ /dev/null @@ -1,126 +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 org.opendc.simulator.compute.workload.SimWorkload -import java.util.UUID - -/** - * A client interface for the OpenDC Compute service. - */ -public interface ComputeClient : AutoCloseable { - /** - * Obtain the list of [Flavor]s accessible by the requesting user. - */ - public fun queryFlavors(): List<Flavor> - - /** - * Obtain a [Flavor] by its unique identifier. - * - * @param id The identifier of the flavor. - */ - public fun findFlavor(id: UUID): Flavor? - - /** - * Create a new [Flavor] instance at this compute service. - * - * @param name The name of the flavor. - * @param cpuCount The amount of CPU cores for this flavor. - * @param memorySize The size of the memory in MB. - * @param labels The identifying labels of the image. - * @param meta The non-identifying meta-data of the image. - */ - public fun newFlavor( - name: String, - cpuCount: Int, - memorySize: Long, - labels: Map<String, String> = emptyMap(), - meta: Map<String, Any> = emptyMap(), - ): Flavor - - /** - * Obtain the list of [Image]s accessible by the requesting user. - */ - public fun queryImages(): List<Image> - - /** - * Obtain a [Image] by its unique identifier. - * - * @param id The identifier of the image. - */ - public fun findImage(id: UUID): Image? - - /** - * Create a new [Image] instance at this compute service. - * - * @param name The name of the image. - * @param labels The identifying labels of the image. - * @param meta The non-identifying meta-data of the image. - */ - public fun newImage( - name: String, - labels: Map<String, String> = emptyMap(), - meta: Map<String, Any> = emptyMap(), - ): Image - - /** - * Obtain the list of [Task]s accessible by the requesting user. - */ - public fun queryTasks(): List<Task> - - /** - * Obtain a [Task] by its unique identifier. - * - * @param id The identifier of the task. - */ - public fun findTask(id: UUID): Task? - - /** - * Create a new [Task] instance at this compute service. - * - * @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 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 newTask( - name: String, - image: Image, - flavor: Flavor, - labels: Map<String, String> = emptyMap(), - meta: Map<String, Any> = emptyMap(), - start: Boolean = true, - ): Task - - public fun rescheduleTask( - task: Task, - workload: SimWorkload, - ) - - /** - * Release the resources associated with this client, preventing any further API calls. - */ - public override fun close() -} 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 99042c24..e88379f6 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,7 +23,7 @@ package org.opendc.compute.api /** - * Flavors define the compute and memory capacity of [Task] instance. To put it simply, a flavor is an available + * Flavors define the compute and memory capacity of [ServiceTask] 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 { diff --git a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Resource.kt b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Resource.kt index 58082130..2c3822a7 100644 --- a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Resource.kt +++ b/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Resource.kt @@ -39,11 +39,6 @@ public interface Resource { public val name: String /** - * The identifying labels attached to the resource. - */ - public val labels: Map<String, String> - - /** * The non-identifying metadata attached to the resource. */ public val meta: Map<String, Any> 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 deleted file mode 100644 index 23f2cb91..00000000 --- a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/Task.kt +++ /dev/null @@ -1,79 +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 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 number of times a Task has been stopped due to failures - */ - public val numFailures: Int - - /** - * 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 index a093ff47..f3f2ca6f 100644 --- 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 @@ -27,14 +27,15 @@ package org.opendc.compute.api */ public enum class TaskState { /** - * Resources are being allocated for the instance. The instance is not running yet. + * A static task is created + * */ - PROVISIONING, + CREATED, /** - * A user shut down the instance. + * Resources are being allocated for the instance. The instance is not running yet. */ - TERMINATED, + PROVISIONING, /** * The task instance is booting up or running. @@ -42,12 +43,26 @@ public enum class TaskState { RUNNING, /** - * The task is in an error state. + * The task is in a failed state. + */ + FAILED, + + /** + * The task has been terminated due to too many failures + * + */ + TERMINATED, + + /** + * The task has been completed successfully + * */ - ERROR, + COMPLETED, /** - * The task has been deleted and cannot be started later on. + * Task has been deleted + * + * @constructor Create empty Deleted */ 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 deleted file mode 100644 index 423d7dec..00000000 --- a/opendc-compute/opendc-compute-api/src/main/kotlin/org/opendc/compute/api/TaskWatcher.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 [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, - ) {} -} |
