-
Notifications
You must be signed in to change notification settings - Fork 1
extract step execution to commons #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
e948dcf
extract step execution to commons
benrejebmoh 2cb2968
extract step execution to commons
benrejebmoh 46ec906
Merge remote-tracking branch 'origin/extract-step-execution-to-common…
benrejebmoh d74468d
Merge remote-tracking branch 'origin/extract-step-execution-to-common…
benrejebmoh e33e3c3
Merge remote-tracking branch 'origin/extract-step-execution-to-common…
benrejebmoh b9ad2dd
use abstract class intead of interface
benrejebmoh 4bd8df6
Merge remote-tracking branch 'origin/main' into extract-step-executio…
benrejebmoh 092d188
merge with main
benrejebmoh e345a58
resolve change request
benrejebmoh 5f3529f
Merge branch 'main' into extract-step-execution-to-commons
benrejebmoh d9df308
merge with main
benrejebmoh f21a5ff
add unit tests
benrejebmoh e0a4e9b
add unit tests and fix sonar issues
benrejebmoh 939a427
set Step and report publishers in the constructor of the parent class
benrejebmoh 52e6c9e
activate gpg
benrejebmoh b522536
retry gpg
benrejebmoh 1954243
extract step execution to commons
benrejebmoh 6ba3d44
activate gpg
benrejebmoh 4fc49c6
finishing rebase properly
benrejebmoh ac06bc1
extract step execution to commons
benrejebmoh 76fbd0e
use abstract class intead of interface
benrejebmoh 260bca0
Add debug mode to process execution (#40)
klesaulnier 9c292e2
Implement state estimation result provider and service (#44)
achour94 ecc04fd
merge with main
benrejebmoh 09a3315
resolve change request
benrejebmoh d03aaf9
Add endpoint to get all process configs of a given type (#42)
FranckLecuyer 51bcf54
refactor: move modificationUuids from ProcessConfig to ModifyingProce…
KoloMenek eb9b4a0
Code improvements (#52)
antoinebhs 81d7229
update to gridsuite-dependencies 49 (#53)
klesaulnier 9dbd43e
Add copyright and author comments to SecurityAnalysisService (#54)
antoinebhs daed7f4
merge with main
benrejebmoh 4c2fc29
add unit tests
benrejebmoh cc9e831
add unit tests and fix sonar issues
benrejebmoh 5c0fb8e
set Step and report publishers in the constructor of the parent class
benrejebmoh 262dfc4
activate gpg
benrejebmoh 6a89f1d
retry gpg
benrejebmoh 36fc0b6
extract step execution to commons
benrejebmoh 6ae08fb
activate gpg
benrejebmoh d658a75
finishing rebase properly
benrejebmoh 25e19ea
Merge remote-tracking branch 'origin/extract-step-execution-to-common…
benrejebmoh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
monitor-commons/src/main/java/org/gridsuite/monitor/commons/steps/AbstractStepExecutor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| /** | ||
| * Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
| package org.gridsuite.monitor.commons.steps; | ||
|
|
||
| import org.gridsuite.monitor.commons.ProcessExecutionStep; | ||
| import org.gridsuite.monitor.commons.ReportInfos; | ||
| import org.gridsuite.monitor.commons.ResultInfos; | ||
| import org.gridsuite.monitor.commons.StepStatus; | ||
|
|
||
| import java.time.Instant; | ||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * @author Mohamed Ben-rejeb <mohamed.ben-rejeb at rte-france.com> | ||
| */ | ||
| public abstract class AbstractStepExecutor { | ||
|
|
||
| protected final StepStatusPublisher stepStatusPublisher; | ||
| protected final ReportPublisher reportPublisher; | ||
|
|
||
| protected AbstractStepExecutor(StepStatusPublisher stepStatusPublisher, ReportPublisher reportPublisher) { | ||
| this.stepStatusPublisher = stepStatusPublisher; | ||
| this.reportPublisher = reportPublisher; | ||
| } | ||
|
|
||
| public void skipStep( | ||
| UUID processExecutionId, | ||
| UUID stepExecutionId, | ||
| String stepTypeName, | ||
| int stepOrder, | ||
| Instant startedAt | ||
| ) { | ||
| ProcessExecutionStep executionStep = ProcessExecutionStep.builder() | ||
| .id(stepExecutionId) | ||
| .stepType(stepTypeName) | ||
| .stepOrder(stepOrder) | ||
| .status(StepStatus.SKIPPED) | ||
| .startedAt(startedAt) | ||
| .completedAt(Instant.now()) | ||
| .build(); | ||
| stepStatusPublisher.updateStepStatus(processExecutionId, executionStep); | ||
| } | ||
|
|
||
| public void executeStep( | ||
| UUID processExecutionId, | ||
| UUID stepExecutionId, | ||
| String stepTypeName, | ||
| int stepOrder, | ||
| Instant startedAt, | ||
| UUID reportUuid, | ||
| ReportInfos reportInfos, | ||
| ResultInfos resultInfos, | ||
| Runnable stepExecution | ||
| ) { | ||
| ProcessExecutionStep executionStep = ProcessExecutionStep.builder() | ||
| .id(stepExecutionId) | ||
| .stepType(stepTypeName) | ||
| .stepOrder(stepOrder) | ||
| .status(StepStatus.RUNNING) | ||
| .reportId(reportUuid) | ||
| .startedAt(startedAt) | ||
| .build(); | ||
| stepStatusPublisher.updateStepStatus(processExecutionId, executionStep); | ||
|
|
||
| try { | ||
| stepExecution.run(); | ||
| reportPublisher.sendReport(reportInfos); | ||
| updateStepStatus( | ||
| processExecutionId, | ||
| stepExecutionId, | ||
| stepTypeName, | ||
| stepOrder, | ||
| startedAt, | ||
| reportUuid, | ||
| resultInfos, | ||
| StepStatus.COMPLETED); | ||
| } catch (Exception e) { | ||
| updateStepStatus( | ||
| processExecutionId, | ||
| stepExecutionId, | ||
| stepTypeName, | ||
| stepOrder, | ||
| startedAt, | ||
| reportUuid, | ||
| resultInfos, | ||
| StepStatus.FAILED); | ||
| throw e; | ||
| } | ||
| } | ||
|
|
||
| private void updateStepStatus( | ||
| UUID processExecutionId, | ||
| UUID stepExecutionId, | ||
| String stepTypeName, | ||
| int stepOrder, | ||
| Instant startedAt, | ||
benrejebmoh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| UUID reportUuid, | ||
| ResultInfos resultInfos, | ||
| StepStatus status | ||
| ) { | ||
| ProcessExecutionStep updated = ProcessExecutionStep.builder() | ||
| .id(stepExecutionId) | ||
| .stepType(stepTypeName) | ||
| .stepOrder(stepOrder) | ||
| .status(status) | ||
| .resultId(resultInfos != null ? resultInfos.resultUUID() : null) | ||
| .resultType(resultInfos != null ? resultInfos.resultType() : null) | ||
| .reportId(reportUuid) | ||
| .startedAt(startedAt) | ||
| .completedAt(Instant.now()) | ||
| .build(); | ||
| stepStatusPublisher.updateStepStatus(processExecutionId, updated); | ||
| } | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
monitor-commons/src/main/java/org/gridsuite/monitor/commons/steps/ReportPublisher.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /** | ||
| * Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
| package org.gridsuite.monitor.commons.steps; | ||
|
|
||
| import org.gridsuite.monitor.commons.ReportInfos; | ||
|
|
||
| /** | ||
| * @author Mohamed Ben-rejeb <mohamed.ben-rejeb at rte-france.com> | ||
| */ | ||
| @FunctionalInterface | ||
| public interface ReportPublisher { | ||
|
|
||
| void sendReport(ReportInfos reportInfos); | ||
|
|
||
| } |
20 changes: 20 additions & 0 deletions
20
monitor-commons/src/main/java/org/gridsuite/monitor/commons/steps/StepStatusPublisher.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /** | ||
| * Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
| package org.gridsuite.monitor.commons.steps; | ||
|
|
||
| import org.gridsuite.monitor.commons.ProcessExecutionStep; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * @author Mohamed Ben-rejeb <mohamed.ben-rejeb at rte-france.com> | ||
| */ | ||
| @FunctionalInterface | ||
| public interface StepStatusPublisher { | ||
|
|
||
| void updateStepStatus(UUID executionId, ProcessExecutionStep processExecutionStep); | ||
| } |
33 changes: 33 additions & 0 deletions
33
monitor-commons/src/test/java/org/gridsuite/monitor/commons/steps/ReportPublisherTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /** | ||
| * Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
| package org.gridsuite.monitor.commons.steps; | ||
|
|
||
| import com.powsybl.commons.report.ReportNode; | ||
| import org.gridsuite.monitor.commons.ReportInfos; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.UUID; | ||
| import java.util.concurrent.atomic.AtomicReference; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertSame; | ||
|
|
||
| /** | ||
| * @author Mohamed Ben-rejeb <mohamed.ben-rejeb at rte-france.com> | ||
| */ | ||
| class ReportPublisherTest { | ||
|
|
||
| @Test | ||
| void sendReportShouldForwardReportInfosToImplementation() { | ||
| AtomicReference<ReportInfos> published = new AtomicReference<>(); | ||
| ReportPublisher reportPublisher = published::set; | ||
| ReportInfos reportInfos = new ReportInfos(UUID.randomUUID(), ReportNode.NO_OP); | ||
|
|
||
| reportPublisher.sendReport(reportInfos); | ||
|
|
||
| assertSame(reportInfos, published.get()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.