From 7511fb768fab68d542adf5bbfb15e32300156c7e Mon Sep 17 00:00:00 2001 From: Dante Niewenhuis Date: Wed, 30 Oct 2024 17:35:06 +0100 Subject: 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 --- .../compute/simulator/service/ComputeService.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'opendc-compute/opendc-compute-simulator/src/main/java') 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; @@ -97,6 +98,11 @@ public final class ComputeService implements AutoCloseable { */ private final Set availableHosts = new HashSet<>(); + /** + * The available powerSources + */ + private final Set powerSources = new HashSet<>(); + /** * The tasks that should be launched by the service. */ @@ -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 getPowerSources() { + return Collections.unmodifiableSet(this.powerSources); + } + /** * Collect the statistics about the scheduler component of this service. */ -- cgit v1.2.3