From 8a3f26bfa51753c8b602985fc1965105629e5f37 Mon Sep 17 00:00:00 2001 From: Dante Niewenhuis Date: Thu, 6 Feb 2025 10:49:12 +0100 Subject: updated logging and added logging for batteries (#301) * Updated logging * removed DoubleThresholdBatteryPolicy.java --- .../compute/simulator/service/ComputeService.java | 20 ++++++++++++++++++++ 1 file changed, 20 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 6fa6af60..aa2c13b9 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 @@ -56,6 +56,7 @@ import org.opendc.compute.simulator.scheduler.SchedulingResultType; import org.opendc.compute.simulator.telemetry.ComputeMetricReader; import org.opendc.compute.simulator.telemetry.SchedulerStats; import org.opendc.simulator.compute.power.SimPowerSource; +import org.opendc.simulator.compute.power.batteries.SimBattery; import org.opendc.simulator.compute.workload.Workload; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -108,6 +109,11 @@ public final class ComputeService implements AutoCloseable { */ private final Set powerSources = new HashSet<>(); + /** + * The available powerSources + */ + private final Set batteries = new HashSet<>(); + /** * The tasks that should be launched by the service. */ @@ -307,6 +313,15 @@ public final class ComputeService implements AutoCloseable { powerSources.add(simPowerSource); } + public void addBattery(SimBattery simBattery) { + // Check if host is already known + if (batteries.contains(simBattery)) { + return; + } + + batteries.add(simBattery); + } + /** * Remove a {@link SimHost} from the scheduling pool of the compute service. */ @@ -341,6 +356,10 @@ public final class ComputeService implements AutoCloseable { return Collections.unmodifiableSet(this.powerSources); } + public Set getBatteries() { + return Collections.unmodifiableSet(this.batteries); + } + public void setMetricReader(ComputeMetricReader metricReader) { this.metricReader = metricReader; } @@ -445,6 +464,7 @@ public final class ComputeService implements AutoCloseable { final HostView hv = result.getHost(); final SchedulingRequest req = result.getReq(); final ServiceTask task = req.getTask(); + final ServiceFlavor flavor = task.getFlavor(); if (task.getNumFailures() >= maxNumFailures) { -- cgit v1.2.3