Skip to content

check optional computation service when sending computation status#1018

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

check optional computation service when sending computation status#1018
EtienneLt wants to merge 12 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

Warning

Review limit reached

@EtienneLt, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 22 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b54c0e74-903f-4778-bc97-203f3abe4719

📥 Commits

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

📒 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

Adds a getOptionalServicesAsMap() method to RemoteServicesInspector that asynchronously aggregates UP/DOWN status for optional services. StudyService is updated to inject this inspector and conditionally compute getAllComputationsStatus based on service availability. application-local.yml marks additional services as optional: true.

Changes

Optional Service Status Handling

Layer / File(s) Summary
Optional services status aggregation
src/main/java/org/gridsuite/study/server/service/RemoteServicesInspector.java
Adds getOptionalServicesAsMap(), which asynchronously checks all services marked optional: true, maps results to ServiceStatusInfos, and returns a Map<String, ServiceStatusInfos> keyed by service name.
StudyService conditional computation status
src/main/java/org/gridsuite/study/server/service/StudyService.java, src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java
Injects RemoteServicesInspector into StudyService via constructor, adds a checkOptionalServiceIsUp(...) helper, and reworks getAllComputationsStatus to only query and report status for computation types whose backing optional service is UP; adds a missing Autowired import in RootNetworkNodeInfoService.
Mark additional services as optional
src/main/resources/application-local.yml
Marks security-analysis-server, sensitivity-analysis-server, shortcircuit-server, dynamic-simulation-server, dynamic-security-analysis-server, dynamic-margin-calculation-server, voltage-init-server, state-estimation-server, and pcc-min-server entries with optional: true.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant StudyService
  participant RemoteServicesInspector
  participant RootNetworkNodeInfoService

  Client->>StudyService: getAllComputationsStatus()
  StudyService->>RemoteServicesInspector: getOptionalServicesAsMap()
  RemoteServicesInspector->>RemoteServicesInspector: isOptionalServiceUp(service) for each optional service
  RemoteServicesInspector-->>StudyService: Map<String, ServiceStatusInfos>
  StudyService->>StudyService: checkOptionalServiceIsUp(computationType)
  alt service available and UP
    StudyService->>RootNetworkNodeInfoService: query computation status
    RootNetworkNodeInfoService-->>StudyService: status
  else service unavailable
    StudyService->>StudyService: omit computation type from result
  end
  StudyService-->>Client: computation statuses map
Loading

Suggested reviewers: AbdelHedhili

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is just a template placeholder and does not describe the changeset. Replace the placeholder with a brief summary of what changed and why it matters.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: it checks optional computation services before sending status.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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 added 11 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.

1 participant