Skip to content

check optional computation service when sending computation status#1018

Open
EtienneLt wants to merge 13 commits into
mainfrom
check-optional-computation-service-when-sending-status
Open

check optional computation service when sending computation status#1018
EtienneLt wants to merge 13 commits into
mainfrom
check-optional-computation-service-when-sending-status

Conversation

@EtienneLt

Copy link
Copy Markdown
Contributor

PR Summary

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@EtienneLt EtienneLt self-assigned this Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: daca07fb-7d10-4653-9a3e-5484b472ef29

📥 Commits

Reviewing files that changed from the base of the PR and between b48a8a6 and 812529f.

📒 Files selected for processing (6)
  • src/main/java/org/gridsuite/study/server/service/RemoteServicesInspector.java
  • src/main/java/org/gridsuite/study/server/service/StudyService.java
  • src/main/java/org/gridsuite/study/server/service/client/RemoteServiceName.java
  • src/test/java/org/gridsuite/study/server/PccMinTest.java
  • src/test/java/org/gridsuite/study/server/ShortCircuitTest.java
  • src/test/java/org/gridsuite/study/server/StudyServiceTest.java

📝 Walkthrough

Walkthrough

Changes

Optional Service Status Handling

Layer / File(s) Summary
Optional services status aggregation
src/main/java/org/gridsuite/study/server/service/RemoteServicesInspector.java, src/main/java/org/gridsuite/study/server/service/client/RemoteServiceName.java, src/main/resources/application-local.yml
Adds running optional-service detection, recognizes dynamic margin calculation, and marks additional local services as optional.
StudyService conditional computation status
src/main/java/org/gridsuite/study/server/service/StudyService.java
Reports LOAD_FLOW unconditionally and resolves other computation statuses only for running optional services.
Computation status test coverage
src/test/java/org/gridsuite/study/server/PccMinTest.java, src/test/java/org/gridsuite/study/server/ShortCircuitTest.java, src/test/java/org/gridsuite/study/server/StudyServiceTest.java
Mocks optional-service availability and verifies computation status responses for enabled and unknown services.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant StudyService
  participant RemoteServicesInspector
  participant RootNetworkNodeInfoService
  Client->>StudyService: getAllComputationsStatus()
  StudyService->>RootNetworkNodeInfoService: resolve LOAD_FLOW status
  RootNetworkNodeInfoService-->>StudyService: LOAD_FLOW status
  StudyService->>RemoteServicesInspector: getRunningOptionalServices()
  RemoteServicesInspector-->>StudyService: running service names
  StudyService->>RootNetworkNodeInfoService: resolve matching computation statuses
  RootNetworkNodeInfoService-->>StudyService: selected statuses
  StudyService-->>Client: computation status map
Loading

Suggested reviewers: slimaneamar

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description is just a template placeholder and doesn't meaningfully describe the changes. Replace the placeholder with a short summary of the status-gating and test updates in this PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: conditioning computation-status sending on optional remote services.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.44.1)
src/main/java/org/gridsuite/study/server/service/StudyService.java

ast-grep timed out on this file

src/main/java/org/gridsuite/study/server/service/client/RemoteServiceName.java

ast-grep retry budget exhausted before isolating this batch

src/test/java/org/gridsuite/study/server/PccMinTest.java

ast-grep retry budget exhausted before isolating this batch

  • 2 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/main/java/org/gridsuite/study/server/service/StudyService.java (1)

144-144: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Declare remoteServicesInspector as final for consistency.

Every other constructor-injected collaborator in StudyService is private final; this new field breaks that convention and allows accidental reassignment.

♻️ Proposed fix
-    private RemoteServicesInspector remoteServicesInspector;
+    private final RemoteServicesInspector remoteServicesInspector;

Also applies to: 209-210, 248-248

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/org/gridsuite/study/server/service/StudyService.java` at line
144, Declare the remoteServicesInspector field in StudyService as private final,
matching the other constructor-injected collaborators, and ensure it is
initialized through the constructor without reassignment.
src/main/java/org/gridsuite/study/server/service/RemoteServicesInspector.java (1)

85-109: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate async aggregation logic between getOptionalServices() and getOptionalServicesAsMap().

Both methods run the identical parallel health-check/join logic, differing only in the terminal collector. Simplify by having the map variant delegate to the list variant.

♻️ Proposed refactor
     public Map<String, ServiceStatusInfos> getOptionalServicesAsMap() {
-        List<CompletableFuture<ServiceStatusInfos>> results = remoteServicesProperties.getServices().stream()
-                .filter(RemoteServicesProperties.Service::isOptional)
-                .map(service -> asyncSelf.isOptionalServiceUp(service).thenApply(isUp -> ServiceStatusInfos.builder()
-                        .name(service.getName())
-                        .status(Boolean.TRUE.equals(isUp) ? ServiceStatus.UP : ServiceStatus.DOWN)
-                        .build()))
-                .toList();
-        CompletableFuture.allOf(results.toArray(CompletableFuture[]::new)).join();
-        return results.stream().map(CompletableFuture::join).collect(Collectors.toMap(ServiceStatusInfos::name, Function.identity()));
+        return getOptionalServices().stream().collect(Collectors.toMap(ServiceStatusInfos::name, Function.identity()));
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/gridsuite/study/server/service/RemoteServicesInspector.java`
around lines 85 - 109, Remove the duplicated asynchronous health-check pipeline
from getOptionalServicesAsMap() by delegating to getOptionalServices() and
collecting its returned ServiceStatusInfos with
Collectors.toMap(ServiceStatusInfos::name, Function.identity()). Preserve the
existing optional-service filtering, status construction, and map key behavior
through the list method.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/org/gridsuite/study/server/service/StudyService.java`:
- Around line 3715-3720: The getAllComputationsStatus method triggers uncached
optional-service health checks on every request. Add a short-TTL cache for the
result of RemoteServicesInspector.getOptionalServicesAsMap(), ensuring
concurrent requests reuse an in-flight or recently completed lookup while
retaining refresh behavior after expiration; update getAllComputationsStatus to
use this cached path.
- Around line 3726-3728: The dynamic margin calculation status is guarded by the
wrong optional-service constant in the surrounding status-building logic. In the
`allComputationStatus` block, replace `DYNAMIC_MAPPING_SERVER` with the service
key/constant corresponding to `DYNAMIC_MARGIN_CALCULATION` when calling
`checkOptionalServiceIsUp`.

---

Nitpick comments:
In
`@src/main/java/org/gridsuite/study/server/service/RemoteServicesInspector.java`:
- Around line 85-109: Remove the duplicated asynchronous health-check pipeline
from getOptionalServicesAsMap() by delegating to getOptionalServices() and
collecting its returned ServiceStatusInfos with
Collectors.toMap(ServiceStatusInfos::name, Function.identity()). Preserve the
existing optional-service filtering, status construction, and map key behavior
through the list method.

In `@src/main/java/org/gridsuite/study/server/service/StudyService.java`:
- Line 144: Declare the remoteServicesInspector field in StudyService as private
final, matching the other constructor-injected collaborators, and ensure it is
initialized through the constructor without reassignment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d27a72fe-4de4-4771-8c3b-1a3434dc6e3c

📥 Commits

Reviewing files that changed from the base of the PR and between 600be82 and b48a8a6.

📒 Files selected for processing (4)
  • src/main/java/org/gridsuite/study/server/service/RemoteServicesInspector.java
  • src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java
  • src/main/java/org/gridsuite/study/server/service/StudyService.java
  • src/main/resources/application-local.yml

Comment thread src/main/java/org/gridsuite/study/server/service/StudyService.java Outdated
Comment thread src/main/java/org/gridsuite/study/server/service/StudyService.java Outdated
EtienneLt and others added 12 commits July 10, 2026 13:30
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants