summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-simulator/src/main/java
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2024-10-30 17:35:06 +0100
committerGitHub <noreply@github.com>2024-10-30 17:35:06 +0100
commit7511fb768fab68d542adf5bbfb15e32300156c7e (patch)
tree959736689bff655be4ea7e6cc92aaec60ca74f1a /opendc-compute/opendc-compute-simulator/src/main/java
parent2325c62377e7c94e768a22807e107a9714626bfc (diff)
Added power sources to OpenDC (#258)
* Added power sources to OpenDC. In the current form each Cluster has a single power source that is connected to all hosts in that cluster * Added power sources to OpenDC. In the current form each Cluster has a single power source that is connected to all hosts in that cluster * Ran spotless Kotlin and Java
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.java19
1 files changed, 19 insertions, 0 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 84e23516..f6447573 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
@@ -50,6 +50,7 @@ import org.opendc.compute.simulator.host.HostState;
import org.opendc.compute.simulator.host.SimHost;
import org.opendc.compute.simulator.scheduler.ComputeScheduler;
import org.opendc.compute.simulator.telemetry.SchedulerStats;
+import org.opendc.simulator.compute.power.SimPowerSource;
import org.opendc.simulator.compute.workload.Workload;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -98,6 +99,11 @@ public final class ComputeService implements AutoCloseable {
private final Set<HostView> availableHosts = new HashSet<>();
/**
+ * The available powerSources
+ */
+ private final Set<SimPowerSource> powerSources = new HashSet<>();
+
+ /**
* The tasks that should be launched by the service.
*/
private final Deque<SchedulingRequest> taskQueue = new ArrayDeque<>();
@@ -283,6 +289,15 @@ public final class ComputeService implements AutoCloseable {
host.addListener(hostListener);
}
+ public void addPowerSource(SimPowerSource simPowerSource) {
+ // Check if host is already known
+ if (powerSources.contains(simPowerSource)) {
+ return;
+ }
+
+ powerSources.add(simPowerSource);
+ }
+
/**
* Remove a {@link SimHost} from the scheduling pool of the compute service.
*/
@@ -313,6 +328,10 @@ public final class ComputeService implements AutoCloseable {
return this.clock;
}
+ public Set<SimPowerSource> getPowerSources() {
+ return Collections.unmodifiableSet(this.powerSources);
+ }
+
/**
* Collect the statistics about the scheduler component of this service.
*/