summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-simulator/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-compute/opendc-compute-simulator/src/main/java')
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/ComputeService.java9
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/ServiceTask.java25
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/TaskNature.java32
3 files changed, 63 insertions, 3 deletions
diff --git a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/ComputeService.java b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/ComputeService.java
index eb8d3377..69625306 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/ComputeService.java
+++ b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/ComputeService.java
@@ -25,6 +25,7 @@ package org.opendc.compute.simulator.service;
import java.time.Duration;
import java.time.Instant;
import java.time.InstantSource;
+import java.time.temporal.TemporalAmount;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
@@ -499,7 +500,6 @@ public final class ComputeService implements AutoCloseable {
SimHost host = hv.getHost();
// Remove request from queue
- taskQueue.remove(req);
tasksPending--;
LOGGER.info("Assigned task {} to host {}", task, host);
@@ -642,6 +642,9 @@ public final class ComputeService implements AutoCloseable {
@NotNull
public ServiceTask newTask(
@NotNull String name,
+ @NotNull TaskNature nature,
+ @NotNull TemporalAmount duration,
+ @NotNull Long deadline,
@NotNull ServiceFlavor flavor,
@NotNull Workload workload,
@NotNull Map<String, ?> meta) {
@@ -652,9 +655,9 @@ public final class ComputeService implements AutoCloseable {
// final ServiceFlavor internalFlavor =
// Objects.requireNonNull(service.flavorById.get(flavor.getUid()), "Unknown flavor");
-
// ServiceTask task = new ServiceTask(service, uid, name, internalFlavor, workload, meta);
- ServiceTask task = new ServiceTask(service, uid, name, flavor, workload, meta);
+
+ ServiceTask task = new ServiceTask(service, uid, name, nature, duration, deadline, flavor, workload, meta);
service.taskById.put(uid, task);
diff --git a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/ServiceTask.java b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/ServiceTask.java
index dac65d67..4d5611a8 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/ServiceTask.java
+++ b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/ServiceTask.java
@@ -23,6 +23,7 @@
package org.opendc.compute.simulator.service;
import java.time.Instant;
+import java.time.temporal.TemporalAmount;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -49,6 +50,9 @@ public class ServiceTask {
private final UUID uid;
private final String name;
+ private final TaskNature nature;
+ private final TemporalAmount duration;
+ private final Long deadline;
private ServiceFlavor flavor;
public Workload workload;
@@ -68,12 +72,18 @@ public class ServiceTask {
ComputeService service,
UUID uid,
String name,
+ TaskNature nature,
+ TemporalAmount duration,
+ Long deadline,
ServiceFlavor flavor,
Workload workload,
Map<String, ?> meta) {
this.service = service;
this.uid = uid;
this.name = name;
+ this.nature = nature;
+ this.duration = duration;
+ this.deadline = deadline;
this.flavor = flavor;
this.workload = workload;
this.meta = meta;
@@ -87,6 +97,21 @@ public class ServiceTask {
}
@NotNull
+ public TaskNature getNature() {
+ return nature;
+ }
+
+ @NotNull
+ public TemporalAmount getDuration() {
+ return duration;
+ }
+
+ @NotNull
+ public Long getDeadline() {
+ return deadline;
+ }
+
+ @NotNull
public String getName() {
return name;
}
diff --git a/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/TaskNature.java b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/TaskNature.java
new file mode 100644
index 00000000..ffb49143
--- /dev/null
+++ b/opendc-compute/opendc-compute-simulator/src/main/java/org/opendc/compute/simulator/service/TaskNature.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2025 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.simulator.service;
+
+public class TaskNature {
+
+ public final boolean deferrable;
+
+ public TaskNature(boolean deferrable) {
+ this.deferrable = deferrable;
+ }
+}