Skip to content
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

feat: plug on DLQs to handle computation and build failures #648

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private StudyConstants() {
public static final String HEADER_IMPORT_PARAMETERS = "importParameters";
public static final String HEADER_MESSAGE = "message";
public static final String HEADER_USER_ID = "userId";
public static final String HEADER_ERROR_MESSAGE = "x-exception-message";
public static final String QUERY_PARAM_ONLY_STASHED = "onlyStashed";
public static final String QUERY_PARAM_STASHED = "stashed";
public static final String QUERY_PARAM_ACTIVATED = "activated";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings;
import org.gridsuite.study.server.StudyConstants;
import org.gridsuite.study.server.dto.*;
import org.gridsuite.study.server.dto.caseimport.CaseImportAction;
import org.gridsuite.study.server.dto.caseimport.CaseImportReceiver;
Expand Down Expand Up @@ -164,7 +165,7 @@ public Consumer<Message<String>> consumeBuildFailed() {

// send notification
UUID studyUuid = networkModificationTreeService.getStudyUuidForNodeId(receiverObj.getNodeUuid());
notificationService.emitNodeBuildFailed(studyUuid, receiverObj.getNodeUuid(), message.getHeaders().get(HEADER_MESSAGE, String.class));
notificationService.emitNodeBuildFailed(studyUuid, receiverObj.getNodeUuid(), message.getHeaders().get(StudyConstants.HEADER_ERROR_MESSAGE, String.class));
} catch (JsonProcessingException e) {
LOGGER.error(e.toString());
}
Expand Down Expand Up @@ -409,7 +410,7 @@ public Consumer<Message<String>> consumeCaseImportFailed() {
*/
public void consumeCalculationFailed(Message<String> msg, ComputationType computationType) {
String receiver = msg.getHeaders().get(HEADER_RECEIVER, String.class);
String errorMessage = msg.getHeaders().get(HEADER_MESSAGE, String.class);
String errorMessage = msg.getHeaders().get(StudyConstants.HEADER_ERROR_MESSAGE, String.class);
String userId = msg.getHeaders().get(HEADER_USER_ID, String.class);
UUID resultUuid = null;
// resultUuid is only used for the voltage initialization computation, I don't know why
Expand Down
41 changes: 20 additions & 21 deletions src/main/resources/config/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ spring:
name: study-server
main:
allow-circular-references: true

cloud:
function:
definition: "consumeSaResult;consumeSaStopped;consumeSaFailed;consumeSaCancelFailed;\
Expand Down Expand Up @@ -32,35 +31,35 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sa.cancelfailed
group: studySaCancelFailedGroup
consumeSaFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sa.failed
group: studySaFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sa.run.dlx
group: dlq
consumeDsResult-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}ds.result
group: studyDsResultGroup
consumeDsStopped-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}ds.stopped
group: studyDsStoppedGroup
consumeDsFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}ds.failed
group: studyDsFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}ds.run.dlx
group: dlq
consumeBuildResult-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}build.result
group: studyBuildResultGroup
consumeBuildStopped-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}build.stopped
group: studyBuildStoppedGroup
consumeBuildFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}build.failed
group: studyBuildFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}build.run.dlx
group: dlq
consumeLoadFlowResult-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}loadflow.result
group: studyLoadFlowResultGroup
consumeLoadFlowStopped-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}loadflow.stopped
group: studyLoadFlowStoppedGroup
consumeLoadFlowFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}loadflow.failed
group: studyLoadFlowFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}loadflow.run.dlx
group: dlq
consumeLoadFlowCancelFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}loadflow.cancelfailed
group: studyLoadFlowCancelFailedGroup
Expand All @@ -71,8 +70,8 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sensitivityanalysis.stopped
group: studySensitivityAnalysisStoppedGroup
consumeSensitivityAnalysisFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sensitivityanalysis.failed
group: studySensitivityAnalysisFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sensitivityanalysis.run.dlx
group: dlq
consumeSensitivityAnalysisCancelFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sensitivityanalysis.cancelfailed
group: studySensitivityAnalysisCancelFailedGroup
Expand All @@ -83,8 +82,8 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}nonEvacuatedEnergy.stopped
group: studyNonEvacuatedEnergyStoppedGroup
consumeNonEvacuatedEnergyFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}nonEvacuatedEnergy.failed
group: studyNonEvacuatedEnergyFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}nonEvacuatedEnergy.run.dlx
group: dlq
consumeNonEvacuatedEnergyCancelFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}nonEvacuatedEnergy.cancelfailed
group: studyNonEvacuatedEnergyCancelFailedGroup
Expand All @@ -95,8 +94,8 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}shortcircuitanalysis.stopped
group: studyShortCircuitAnalysisStoppedGroup
consumeShortCircuitAnalysisFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}shortcircuitanalysis.failed
group: studyShortCircuitAnalysisFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}shortcircuitanalysis.run.dlx
group: dlq
consumeShortCircuitAnalysisCancelFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}shortcircuitanalysis.cancelfailed
group: studyShortCircuitAnalysisCancelFailedGroup
Expand All @@ -107,8 +106,8 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}voltageinit.stopped
group: studyVoltageInitStoppedGroup
consumeVoltageInitFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}voltageinit.failed
group: studyVoltageInitFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}voltageinit.run.dlx
group: dlq
consumeVoltageInitCancelFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}voltageinit.cancelfailed
group: studyVoltageInitCancelFailedGroup
Expand All @@ -119,14 +118,14 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}stateestimation.stopped
group: studyStateEstimationStoppedGroup
consumeStateEstimationFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}stateestimation.failed
group: studyStateEstimationFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}stateestimation.run.dlx
group: dlq
consumeCaseImportSucceeded-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}case.import.succeeded
group: studyCaseImportSucceededGroup
consumeCaseImportFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}case.import.failed
group: studyCaseImportFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}case.import.start.dlx
group: dlq
output-bindings: publishStudyUpdate-out-0;publishElementUpdate-out-0

powsybl:
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/gridsuite/study/server/LoadFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class LoadFlowTest {
private static final String ELEMENT_UPDATE_DESTINATION = "element.update";
private static final String LOADFLOW_RESULT_DESTINATION = "loadflow.result";
private static final String LOADFLOW_STOPPED_DESTINATION = "loadflow.stopped";
private static final String LOADFLOW_FAILED_DESTINATION = "loadflow.failed";
private static final String LOADFLOW_FAILED_DESTINATION = "loadflow.run.dlx";

@Autowired
private MockMvc mockMvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import java.util.*;

import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.gridsuite.study.server.StudyConstants.HEADER_ERROR_MESSAGE;
import static org.gridsuite.study.server.StudyConstants.QUERY_PARAM_RECEIVER;
import static org.gridsuite.study.server.utils.ImpactUtils.createModificationResultWithElementImpact;
import static org.gridsuite.study.server.utils.MatcherCreatedStudyBasicInfos.createMatcherCreatedStudyBasicInfos;
Expand Down Expand Up @@ -263,7 +264,7 @@ void setup(final MockWebServer server) {
.withPostServeAction(POST_ACTION_SEND_INPUT, Map.of("payload", DEFAULT_BUILD_RESULT, "destination", "build.result"))
.willReturn(WireMock.ok())).getId();
buildFailedStubId = wireMockServer.stubFor(WireMock.post(WireMock.urlPathEqualTo("/v1/networks/" + NETWORK_UUID_2_STRING + "/build"))
.withPostServeAction(POST_ACTION_SEND_INPUT, Map.of("payload", "", "destination", "build.failed", "message", ERROR_MESSAGE))
.withPostServeAction(POST_ACTION_SEND_INPUT, Map.of("payload", "", "destination", "build.run.dlx", HEADER_ERROR_MESSAGE, ERROR_MESSAGE))
.willReturn(WireMock.ok())).getId();
buildErrorStubId = wireMockServer.stubFor(WireMock.post(WireMock.urlPathEqualTo("/v1/networks/" + NETWORK_UUID_3_STRING + "/build"))
.willReturn(WireMock.serverError())).getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class NonEvacuatedEnergyTest {
private static final String STUDY_UPDATE_DESTINATION = "study.update";
private static final String NON_EVACUATED_ENERGY_RESULT_DESTINATION = "nonEvacuatedEnergy.result";
private static final String NON_EVACUATED_ENERGY_STOPPED_DESTINATION = "nonEvacuatedEnergy.stopped";
private static final String NON_EVACUATED_ENERGY_FAILED_DESTINATION = "nonEvacuatedEnergy.failed";
private static final String NON_EVACUATED_ENERGY_FAILED_DESTINATION = "nonEvacuatedEnergy.run.dlx";
@Autowired
private RootNetworkNodeInfoService rootNetworkNodeInfoService;
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class SecurityAnalysisTest {
private final String studyUpdateDestination = "study.update";
private final String saResultDestination = "sa.result";
private final String saStoppedDestination = "sa.stopped";
private final String saFailedDestination = "sa.failed";
private final String saFailedDestination = "sa.run.dlx";
@Autowired
private RootNetworkNodeInfoService rootNetworkNodeInfoService;
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class SensitivityAnalysisTest {
private static final String ELEMENT_UPDATE_DESTINATION = "element.update";
private static final String SENSITIVITY_ANALYSIS_RESULT_DESTINATION = "sensitivityanalysis.result";
private static final String SENSITIVITY_ANALYSIS_STOPPED_DESTINATION = "sensitivityanalysis.stopped";
private static final String SENSITIVITY_ANALYSIS_FAILED_DESTINATION = "sensitivityanalysis.failed";
private static final String SENSITIVITY_ANALYSIS_FAILED_DESTINATION = "sensitivityanalysis.run.dlx";

private static final byte[] SENSITIVITY_RESULTS_AS_CSV = {0x00, 0x01};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class ShortCircuitTest implements WithAssertions {
private final String elementUpdateDestination = "element.update";
private final String shortCircuitAnalysisResultDestination = "shortcircuitanalysis.result";
private final String shortCircuitAnalysisStoppedDestination = "shortcircuitanalysis.stopped";
private final String shortCircuitAnalysisFailedDestination = "shortcircuitanalysis.failed";
private final String shortCircuitAnalysisFailedDestination = "shortcircuitanalysis.run.dlx";
@Autowired
private StudyService studyService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class StateEstimationTest {
private static final String STUDY_UPDATE_DESTINATION = "study.update";
private static final String ESTIM_RESULT_JSON_DESTINATION = "stateestimation.result";
private static final String ESTIM_STOPPED_DESTINATION = "stateestimation.stopped";
private static final String ESTIM_FAILED_DESTINATION = "stateestimation.failed";
private static final String ESTIM_FAILED_DESTINATION = "stateestimation.run.dlx";

@Autowired
private MockMvc mockMvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class StudyControllerDynamicSimulationTest {
private static final String STUDY_UPDATE_DESTINATION = "study.update";
private static final String DS_RESULT_DESTINATION = "ds.result";
private static final String DS_STOPPED_DESTINATION = "ds.stopped";
private static final String DS_FAILED_DESTINATION = "ds.failed";
private static final String DS_FAILED_DESTINATION = "ds.run.dlx";

@BeforeEach
public void setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/gridsuite/study/server/StudyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ private void sendCaseImportFailedMessage(String requestPath, String errorMessage
String receiverUrlString = matcher.group(1);
input.send(MessageBuilder.withPayload("").setHeader("receiver", URLDecoder.decode(receiverUrlString, StandardCharsets.UTF_8))
.setHeader("errorMessage", errorMessage)
.build(), "case.import.failed");
.build(), "case.import.start.dlx");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class VoltageInitTest {
private final String studyUpdateDestination = "study.update";
private final String voltageInitResultDestination = "voltageinit.result";
private final String voltageInitStoppedDestination = "voltageinit.stopped";
private final String voltageInitFailedDestination = "voltageinit.failed";
private final String voltageInitFailedDestination = "voltageinit.run.dlx";
private final String voltageInitCancelFailedDestination = "voltageinit.cancelfailed";
private final String elementUpdateDestination = "element.update";
@Autowired
Expand Down
Loading