Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,34 @@
<name>power-server : backend</name>
<description>Power consumption measuring backend</description>

<properties>
<nuprocess.version>3.0.0</nuprocess.version>
</properties>

<dependencies>
<dependency>
<groupId>net.laprun.sustainability</groupId>
<artifactId>power-server-metadata</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
<groupId>net.laprun.sustainability</groupId>
<artifactId>power-server-persistence</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>nuprocess</artifactId>
<version>3.0.0</version>
<version>${nuprocess.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.laprun.sustainability.cli;
package net.laprun.sustainability.power.sensors;

import java.time.Duration;
import java.util.Map;
Expand All @@ -15,12 +15,9 @@
import net.laprun.sustainability.power.SensorMeasure;
import net.laprun.sustainability.power.SensorMetadata;
import net.laprun.sustainability.power.persistence.Persistence;
import net.laprun.sustainability.power.sensors.Measures;
import net.laprun.sustainability.power.sensors.PowerSensor;
import net.laprun.sustainability.power.sensors.RegisteredPID;

@ApplicationScoped
public class PowerMeasurer {
public class SamplingMeasurer {

public static final String DEFAULT_SAMPLING_PERIOD = "PT0.5S";
@Inject
Expand Down
5 changes: 0 additions & 5 deletions cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
<artifactId>power-server-measure</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.laprun.sustainability</groupId>
<artifactId>power-server-persistence</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-picocli</artifactId>
Expand Down
5 changes: 3 additions & 2 deletions cli/src/main/java/net/laprun/sustainability/cli/Power.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.laprun.sustainability.power.analysis.total.TotalSyntheticComponent;
import net.laprun.sustainability.power.nuprocess.BaseProcessHandler;
import net.laprun.sustainability.power.persistence.Persistence;
import net.laprun.sustainability.power.sensors.SamplingMeasurer;
import picocli.CommandLine;

@CommandLine.Command
Expand All @@ -30,9 +31,9 @@ public class Power implements Runnable {
"--command" }, required = true, description = "Command to measure energy consumption for")
String cmd;

private final PowerMeasurer measurer;
private final SamplingMeasurer measurer;

public Power(PowerMeasurer measurer) throws IOException {
public Power(SamplingMeasurer measurer) {
this.measurer = measurer;
}

Expand Down
5 changes: 0 additions & 5 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
<artifactId>power-server-backend</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.laprun.sustainability</groupId>
<artifactId>power-server-persistence</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
import io.quarkus.runtime.StartupEvent;
import io.smallrye.mutiny.Multi;
import net.laprun.sustainability.power.persistence.Measure;
import net.laprun.sustainability.power.persistence.Persistence;
import net.laprun.sustainability.power.sensors.SamplingMeasurer;

@Path("/power")
public class PowerResource {
@Inject
PowerMeasurer measurer;
SamplingMeasurer measurer;

public void onStartup(@Observes StartupEvent event) {
Log.info("\nConfigured sampling period: " + samplingPeriod() +
Expand All @@ -44,7 +46,7 @@ public Multi<SensorMeasure> streamMeasuresFor(@PathParam("pid") String pid) thro
@Path("start/{appName}/{pid}")
public void startMeasure(@PathParam("appName") String appName, @PathParam("pid") String pid) throws Exception {
try {
measurer.startTrackingApp(appName, measurer.validPIDOrFail(pid));
measurer.startTrackingApp(appName, measurer.validPIDOrFail(pid), Persistence.defaultSession(appName));
} catch (IllegalArgumentException e) {
throw new NotFoundException("Unknown process: " + pid);
}
Expand All @@ -59,7 +61,7 @@ public SensorMetadata metadata() {
@GET
@Path("sampling")
public Duration samplingPeriod() {
return measurer.getSamplingPeriod();
return measurer.samplingPeriod();
}

@GET
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package net.laprun.sustainability.power;

import io.quarkus.test.Mock;
import net.laprun.sustainability.power.sensors.SamplingMeasurer;

@Mock
@SuppressWarnings("unused")
public class MockPowerMeasurer extends PowerMeasurer {
public class MockSamplingMeasurer extends SamplingMeasurer {

@Override
public long validPIDOrFail(String pid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.test.junit.QuarkusTest;
import net.laprun.sustainability.power.sensors.SamplingMeasurer;

@QuarkusTest
public class PowerResourceTest {
Expand Down Expand Up @@ -60,7 +61,7 @@ public void samplingPeriod() {
.then()
.statusCode(200)
.extract().body().as(Duration.class);
assertEquals(Duration.parse(PowerMeasurer.DEFAULT_SAMPLING_PERIOD), duration);
assertEquals(Duration.parse(SamplingMeasurer.DEFAULT_SAMPLING_PERIOD), duration);
}

protected long getPid() {
Expand Down
Loading