Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
Signed-off-by: Slimane AMAR <amarsli@gm0winl104.bureau.si.interne>
  • Loading branch information
Slimane AMAR committed Jan 3, 2025
1 parent a6181a1 commit 68a392f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
9 changes: 2 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!-- Runtime dependencies -->
Expand All @@ -141,11 +141,6 @@
<artifactId>powsybl-config-classic</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,25 @@ class NetworkAreaDiagramService {

private final NetworkStoreService networkStoreService;
private final GeoDataService geoDataService;
private final NetworkAreaExecutionService diagramExecutionService;

private final ObjectMapper objectMapper;

public NetworkAreaDiagramService(NetworkStoreService networkStoreService, GeoDataService geoDataService, ObjectMapper objectMapper) {
public NetworkAreaDiagramService(NetworkStoreService networkStoreService, GeoDataService geoDataService,
NetworkAreaExecutionService diagramExecutionService, ObjectMapper objectMapper) {
this.networkStoreService = networkStoreService;
this.geoDataService = geoDataService;
this.diagramExecutionService = diagramExecutionService;
this.objectMapper = objectMapper;
}

public String getNetworkAreaDiagramSvg(UUID networkUuid, String variantId, List<String> voltageLevelsIds, int depth, boolean withGeoData) {
public String getNetworkAreaDiagramSvgAsync(UUID networkUuid, String variantId, List<String> voltageLevelsIds, int depth, boolean withGeoData) {
return diagramExecutionService
.supplyAsync(() -> getNetworkAreaDiagramSvg(networkUuid, variantId, voltageLevelsIds, depth, withGeoData))
.join();
}

private String getNetworkAreaDiagramSvg(UUID networkUuid, String variantId, List<String> voltageLevelsIds, int depth, boolean withGeoData) {
try {
SvgAndMetadata svgAndMetadata = generateNetworkAreaDiagramSvg(networkUuid, variantId, voltageLevelsIds, depth, withGeoData);
String svg = svgAndMetadata.getSvg();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
* @author Slimane Amar <slimane.amar at rte-france.com>
*/
@Service
public class DiagramGenerationExecutionService {
public class NetworkAreaExecutionService {

private ThreadPoolExecutor executorService;

public DiagramGenerationExecutionService(@Value("${max-concurrent-nad-generations}") int maxConcurrentNadGenerations,
@NonNull DiagramGenerationObserver diagramGenerationObserver) {
public NetworkAreaExecutionService(@Value("${max-concurrent-nad-generations}") int maxConcurrentNadGenerations,
@NonNull DiagramGenerationObserver diagramGenerationObserver) {
executorService = (ThreadPoolExecutor) Executors.newFixedThreadPool(maxConcurrentNadGenerations);
diagramGenerationObserver.createThreadPoolMetric(executorService);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;

import static com.powsybl.sld.server.NetworkAreaDiagramService.*;
import static com.powsybl.ws.commons.LogUtils.sanitizeParam;
Expand All @@ -52,14 +51,10 @@ public class SingleLineDiagramController {

private final NetworkAreaDiagramService networkAreaDiagramService;

private final DiagramGenerationExecutionService diagramExecutionService;

public SingleLineDiagramController(SingleLineDiagramService singleLineDiagramService,
NetworkAreaDiagramService networkAreaDiagramService,
DiagramGenerationExecutionService diagramExecutionService) {
NetworkAreaDiagramService networkAreaDiagramService) {
this.singleLineDiagramService = singleLineDiagramService;
this.networkAreaDiagramService = networkAreaDiagramService;
this.diagramExecutionService = diagramExecutionService;
}

// voltage levels
Expand Down Expand Up @@ -272,12 +267,10 @@ public ResponseEntity<Collection<String>> getAvailableSvgComponentLibraries() {
@Parameter(description = "Voltage levels ids") @RequestParam(name = "voltageLevelsIds", required = false) List<String> voltageLevelsIds,
@Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId,
@Parameter(description = "depth") @RequestParam(name = "depth", required = false) int depth,
@Parameter(description = "Initialize NAD with Geographical Data") @RequestParam(name = "withGeoData", defaultValue = "true") boolean withGeoData) throws InterruptedException, ExecutionException {
@Parameter(description = "Initialize NAD with Geographical Data") @RequestParam(name = "withGeoData", defaultValue = "true") boolean withGeoData) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("getNetworkAreaDiagramSvg request received with parameter networkUuid = {}, voltageLevelsIds = {}, depth = {}", networkUuid, sanitizeParam(voltageLevelsIds.toString()), depth);
}
return diagramExecutionService
.supplyAsync(() -> networkAreaDiagramService.getNetworkAreaDiagramSvg(networkUuid, variantId, voltageLevelsIds, depth, withGeoData))
.get();
return networkAreaDiagramService.getNetworkAreaDiagramSvgAsync(networkUuid, variantId, voltageLevelsIds, depth, withGeoData);
}
}

0 comments on commit 68a392f

Please sign in to comment.