Skip to content

Commit

Permalink
chore: format, add formatting configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
metacosm committed Apr 2, 2024
1 parent a548fea commit b709dfd
Show file tree
Hide file tree
Showing 16 changed files with 484 additions and 37 deletions.
428 changes: 428 additions & 0 deletions contributing/eclipse-format.xml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions contributing/eclipse.importorder
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Organize Import Order
#Wed Jan 23 12:03:29 AEDT 2019
0=java
1=javax
2=jakarta
3=org
4=com
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package net.laprun.sustainability.power.quarkus.deployment.devui.commands;

import net.laprun.sustainability.power.quarkus.runtime.PowerMeasurer;
import java.util.List;

import org.aesh.command.Command;
import org.aesh.command.CommandResult;
import org.aesh.command.GroupCommand;
import org.aesh.command.GroupCommandDefinition;
import org.aesh.command.invocation.CommandInvocation;

import java.util.List;
import net.laprun.sustainability.power.quarkus.runtime.PowerMeasurer;

@GroupCommandDefinition(name = "power", description = "Power consumption commands", generateHelp = true)
@SuppressWarnings("rawtypes")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package net.laprun.sustainability.power.quarkus.deployment.devui.commands;

import io.quarkus.deployment.console.QuarkusCommand;
import net.laprun.sustainability.power.quarkus.runtime.PowerMeasure;
import net.laprun.sustainability.power.quarkus.runtime.PowerMeasurer;
import org.aesh.command.CommandDefinition;
import org.aesh.command.CommandResult;
import org.aesh.command.invocation.CommandInvocation;
import org.aesh.command.option.Option;

import io.quarkus.deployment.console.QuarkusCommand;
import net.laprun.sustainability.power.quarkus.runtime.PowerMeasure;
import net.laprun.sustainability.power.quarkus.runtime.PowerMeasurer;

@CommandDefinition(name = "start", description = "Starts measuring power consumption of the current application")
public class StartCommand extends QuarkusCommand {
private final PowerMeasurer sensor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package net.laprun.sustainability.power.quarkus.deployment.devui.commands;

import io.quarkus.deployment.console.QuarkusCommand;
import net.laprun.sustainability.power.quarkus.runtime.PowerMeasurer;
import org.aesh.command.CommandDefinition;
import org.aesh.command.CommandResult;
import org.aesh.command.invocation.CommandInvocation;

import io.quarkus.deployment.console.QuarkusCommand;
import net.laprun.sustainability.power.quarkus.runtime.PowerMeasurer;

@CommandDefinition(name = "stop", description = "Stops power measurement and outputs accumulated power since measures were started")
public class StopCommand extends QuarkusCommand {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package net.laprun.sustainability.power.quarkus.deployment;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.net.URI;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.quarkus.test.common.http.TestHTTPResource;
import net.laprun.sustainability.power.PowerResource;
import net.laprun.sustainability.power.quarkus.runtime.PowerMeasurer;
import net.laprun.sustainability.power.quarkus.runtime.ServerSampler;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.net.URI;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class PowerMeasurerTest {
@TestHTTPResource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package net.laprun.sustainability.power.quarkus.test;

import io.quarkus.test.QuarkusDevModeTest;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusDevModeTest;

@Disabled
public class PowerDevModeTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package net.laprun.sustainability.power.quarkus.test;

import io.quarkus.test.QuarkusUnitTest;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;

public class PowerTest {

// Start unit test with your extension loaded
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package net.laprun.sustainability.power.quarkus.it;

import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.is;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
public class PowerResourceTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package net.laprun.sustainability.power.quarkus.runtime;

import net.laprun.sustainability.power.SensorMetadata;

import java.util.List;

import net.laprun.sustainability.power.SensorMetadata;

abstract class AbstractPowerMeasure implements PowerMeasure {
private final SensorMetadata sensorMetadata;
private final List<double[]> measures;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.laprun.sustainability.power.quarkus.runtime;

import net.laprun.sustainability.power.SensorMetadata;

import java.util.ArrayList;
import java.util.Arrays;

import net.laprun.sustainability.power.SensorMetadata;

public class OngoingPowerMeasure extends AbstractPowerMeasure {
private final long startedAt;
private double minTotal = Double.MAX_VALUE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.laprun.sustainability.power.quarkus.runtime;

import net.laprun.sustainability.power.SensorMetadata;

import java.util.List;
import java.util.stream.IntStream;

import net.laprun.sustainability.power.SensorMetadata;

public interface PowerMeasure {
int numberOfSamples();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package net.laprun.sustainability.power.quarkus.runtime;

import com.sun.management.OperatingSystemMXBean;

import java.lang.management.ManagementFactory;
import java.util.Optional;
import java.util.concurrent.Executors;
Expand All @@ -10,6 +8,8 @@
import java.util.function.BiConsumer;
import java.util.function.Consumer;

import com.sun.management.OperatingSystemMXBean;

public class PowerMeasurer {
private static final OperatingSystemMXBean osBean;

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

import io.smallrye.mutiny.Multi;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import io.smallrye.mutiny.Multi;
import net.laprun.sustainability.power.SensorMetadata;

@Path("/power")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package net.laprun.sustainability.power.quarkus.runtime;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.quarkus.rest.client.reactive.jackson.runtime.serialisers.ClientJacksonMessageBodyReader;
import java.net.ConnectException;
import java.net.URI;
import java.util.Arrays;
import java.util.function.Consumer;

import jakarta.ws.rs.ProcessingException;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.sse.SseEventSource;
import net.laprun.sustainability.power.SensorMeasure;
import net.laprun.sustainability.power.SensorMetadata;

import org.eclipse.microprofile.config.inject.ConfigProperty;

import java.net.ConnectException;
import java.net.URI;
import java.util.Arrays;
import java.util.function.Consumer;
import com.fasterxml.jackson.databind.ObjectMapper;

import io.quarkus.rest.client.reactive.jackson.runtime.serialisers.ClientJacksonMessageBodyReader;
import net.laprun.sustainability.power.SensorMeasure;
import net.laprun.sustainability.power.SensorMetadata;

public class ServerSampler implements Sampler {
private final SseEventSource powerAPI;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package net.laprun.sustainability.power.quarkus.runtime;

import net.laprun.sustainability.power.SensorMetadata;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import net.laprun.sustainability.power.SensorMetadata;

public class OngoingPowerMeasureTest {

Expand Down

0 comments on commit b709dfd

Please sign in to comment.