-
Notifications
You must be signed in to change notification settings - Fork 2
network load status #1067
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
base: main
Are you sure you want to change the base?
network load status #1067
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /** | ||
| * 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.study.server.dto; | ||
|
|
||
| /** | ||
| * @author Ghazwa Rehili <ghazwa.rehili at rte-france.com> | ||
| */ | ||
| public enum NetworkLoadStatus { | ||
| LOADED, | ||
| UNLOADED, | ||
| LOADING, | ||
| UNLOADING | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| import org.gridsuite.study.server.dto.*; | ||
| import org.gridsuite.study.server.dto.InvalidateNodeTreeParameters.ComputationsInvalidationMode; | ||
| import org.gridsuite.study.server.dto.InvalidateNodeTreeParameters.InvalidationMode; | ||
| import org.gridsuite.study.server.dto.NetworkLoadStatus; | ||
| import org.gridsuite.study.server.dto.caseimport.CaseImportAction; | ||
| import org.gridsuite.study.server.dto.computation.ComputationParameterUUIDs; | ||
| import org.gridsuite.study.server.dto.elasticsearch.EquipmentInfos; | ||
|
|
@@ -447,10 +448,16 @@ private void recreateNetwork(RootNetworkInfos rootNetworkInfos, UUID studyUuid, | |
| ? new HashMap<>(rootNetworkService.getImportParameters(rootNetworkInfos.getId())) | ||
| : importParameters; | ||
|
|
||
| self.updateNetworkLoadStatus(studyUuid, NetworkLoadStatus.LOADING); | ||
| persistNetwork(rootNetworkInfos, studyUuid, null, userId, importParametersToUse, CaseImportAction.NETWORK_RECREATION, reportId); | ||
| notificationService.emitElementUpdated(studyUuid, userId); | ||
| } | ||
|
|
||
| @Transactional | ||
| public void updateNetworkLoadStatus(UUID studyUuid, NetworkLoadStatus networkLoadStatus) { | ||
| getStudy(studyUuid).setNetworkLoadStatus(networkLoadStatus); | ||
| } | ||
|
|
||
| public UUID duplicateStudy(UUID sourceStudyUuid, String userId) { | ||
| Objects.requireNonNull(sourceStudyUuid); | ||
|
|
||
|
|
@@ -633,6 +640,7 @@ public CreatedStudyBasicInfos updateNetwork(UUID studyUuid, UUID rootNetworkUuid | |
| RootNetworkEntity rootNetworkEntity = rootNetworkService.getRootNetwork(rootNetworkUuid).orElseThrow(() -> new StudyException(NOT_FOUND, "Root network not found")); | ||
|
|
||
| rootNetworkService.updateNetwork(rootNetworkEntity, networkInfos); | ||
| studyEntity.setNetworkLoadStatus(NetworkLoadStatus.LOADED); | ||
|
|
||
| CreatedStudyBasicInfos createdStudyBasicInfos = toCreatedStudyBasicInfos(studyEntity); | ||
| studyInfosService.add(createdStudyBasicInfos); | ||
|
|
@@ -2705,6 +2713,7 @@ public Map<ComputationType, String> getAllComputationsStatus(@NonNull UUID study | |
|
|
||
| public void invalidateStudyRootNetwork(UUID studyUuid, UUID rootNetworkUuid, String userId, boolean updateCase) { | ||
| rootNetworkService.assertIsRootNetworkInStudy(studyUuid, rootNetworkUuid); | ||
| self.updateNetworkLoadStatus(studyUuid, NetworkLoadStatus.UNLOADING); | ||
| var rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); | ||
| // First we unbuild all nodes | ||
| doUnbuildNodeTree(studyUuid, rootNodeUuid, true, true, userId); | ||
|
|
@@ -2713,6 +2722,7 @@ public void invalidateStudyRootNetwork(UUID studyUuid, UUID rootNetworkUuid, Str | |
| if (!updateCase) { | ||
| rootNetworkService.updateRootNetworkIndexationStatus(studyUuid, rootNetworkUuid, RootNetworkIndexationStatus.NOT_INDEXED); | ||
| } | ||
| self.updateNetworkLoadStatus(studyUuid, NetworkLoadStatus.UNLOADED); | ||
| notificationService.emitRootNetworksUpdated(studyUuid); | ||
|
Comment on lines
+2716
to
2726
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those load status update might be better placed in one level above in invalidateStudy. Otherwise the study will switch to UNLOADING multiple times during an invalidation with multiple root networks. Also, in a multi root network situation, a study might have the UNLOADED status even if some root networks failed to unload
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plus it would avoid using self as a workaround for transaction proxy |
||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ | |
| import org.gridsuite.study.server.elasticsearch.EquipmentInfosService; | ||
| import org.gridsuite.study.server.elasticsearch.StudyInfosService; | ||
| import org.gridsuite.study.server.networkmodificationtree.entities.RootNetworkNodeInfoEntity; | ||
| import org.gridsuite.study.server.notification.NotificationService; | ||
| import org.gridsuite.study.server.repository.StudyEntity; | ||
| import org.gridsuite.study.server.repository.StudyRepository; | ||
| import org.gridsuite.study.server.repository.rootnetwork.RootNetworkEntity; | ||
|
|
@@ -97,8 +96,6 @@ public class SupervisionService { | |
|
|
||
| private final RootNetworkService rootNetworkService; | ||
|
|
||
| private final NotificationService notificationService; | ||
|
|
||
| private static final String SUPERVISION_USER = "Supervision"; | ||
|
|
||
| public SupervisionService(StudyService studyService, | ||
|
|
@@ -120,8 +117,7 @@ public SupervisionService(StudyService studyService, | |
| ElasticsearchOperations elasticsearchOperations, | ||
| StudyInfosService studyInfosService, | ||
| RootNetworkService rootNetworkService, | ||
| StudyRepository studyRepository, | ||
| NotificationService notificationService) { | ||
| StudyRepository studyRepository) { | ||
| this.studyService = studyService; | ||
| this.networkModificationTreeService = networkModificationTreeService; | ||
| this.loadFlowService = loadFlowService; | ||
|
|
@@ -143,7 +139,6 @@ public SupervisionService(StudyService studyService, | |
| this.studyInfosService = studyInfosService; | ||
| this.rootNetworkService = rootNetworkService; | ||
| this.studyRepository = studyRepository; | ||
| this.notificationService = notificationService; | ||
| } | ||
|
|
||
| @Transactional | ||
|
|
@@ -414,10 +409,16 @@ public void invalidateStudy(UUID studyUuid) { | |
| var rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); | ||
| studyService.unblockNodeTree(studyUuid, rootNodeUuid); | ||
| } | ||
| notificationService.emitElementUpdated(studyUuid, SUPERVISION_USER); | ||
| LOGGER.trace("Study {} nodes builds deleted and root node invalidated in : {} milliseconds", studyUuid, TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime.get())); | ||
| } | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public List<UUID> getLoadedStudyUuids(List<UUID> studyUuids) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better fitted in StudyService no ? It may have other usages outside of supervision scope |
||
| return studyRepository.findAllByIdInAndNetworkLoadStatus(studyUuids, NetworkLoadStatus.LOADED).stream() | ||
| .map(StudyEntity::getId) | ||
| .toList(); | ||
| } | ||
|
|
||
| @Transactional | ||
| public void recreateStudyIndices() { | ||
| recreateIndex(CreatedStudyBasicInfos.class); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.1" encoding="UTF-8" standalone="no"?> | ||
| <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
| <changeSet author="rehiligha (generated)" id="1855530442886-1"> | ||
| <addColumn tableName="study"> | ||
| <column name="network_load_status" type="varchar(255)" defaultValue="LOADED"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| </addColumn> | ||
| </changeSet> | ||
| </databaseChangeLog> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be moved to study controller as well no ?