Skip to content

Commit

Permalink
Remove hack and update report management
Browse files Browse the repository at this point in the history
Signed-off-by: Ayoub LABIDI <[email protected]>
  • Loading branch information
ayolab committed Sep 6, 2024
1 parent 4d9293c commit 3785d6e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1,208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class BuildInfos {

private List<UUID> modificationGroupUuids = new ArrayList<>();

private List<String> reporterIds = new ArrayList<>();
private List<ReportInfos> reportsInfos = new ArrayList<>();

private Set<UUID> modificationsToExclude = new HashSet<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -126,7 +125,7 @@ private NetworkModificationResult processApplication(List<ModificationInfos> mod
* Note : it is possible that the rabbitmq consumer threads here will be blocked by modifications applied directly in the other applyModifications method
* and no more builds can go through. If this causes problems we should put them in separate rabbitmq queues.
*/
public NetworkModificationResult applyModifications(List<Pair<String, List<ModificationInfos>>> modificationInfosGroups, NetworkInfos networkInfos, UUID reportUuid) {
public NetworkModificationResult applyModifications(List<Pair<ReportInfos, List<ModificationInfos>>> modificationInfosGroups, NetworkInfos networkInfos) {
PreloadingStrategy preloadingStrategy = modificationInfosGroups.stream()
.map(Pair::getRight)
.flatMap(List::stream)
Expand All @@ -135,19 +134,19 @@ public NetworkModificationResult applyModifications(List<Pair<String, List<Modif
.map(ModificationType::getStrategy)
.orElse(PreloadingStrategy.NONE);
if (preloadingStrategy == PreloadingStrategy.ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW) {
CompletableFuture<NetworkModificationResult> future = CompletableFuture.supplyAsync(() -> processApplication(modificationInfosGroups, networkInfos, reportUuid), applicationExecutor);
CompletableFuture<NetworkModificationResult> future = CompletableFuture.supplyAsync(() -> processApplication(modificationInfosGroups, networkInfos), applicationExecutor);
return future.join();
} else {
return processApplication(modificationInfosGroups, networkInfos, reportUuid);
return processApplication(modificationInfosGroups, networkInfos);
}
}

// used for building a variant
private NetworkModificationResult processApplication(List<Pair<String, List<ModificationInfos>>> modificationInfosGroups, NetworkInfos networkInfos, UUID reportUuid) {
private NetworkModificationResult processApplication(List<Pair<ReportInfos, List<ModificationInfos>>> modificationInfosGroups, NetworkInfos networkInfos) {
NetworkStoreListener listener = NetworkStoreListener.create(networkInfos.getNetwork(), networkInfos.getNetworkUuuid(), networkStoreService, equipmentInfosService, collectionThreshold);
List<ApplicationStatus> groupsApplicationStatuses =
modificationInfosGroups.stream()
.map(g -> apply(g.getRight(), listener.getNetwork(), new ReportInfos(reportUuid, g.getLeft())))
.map(g -> apply(g.getRight(), listener.getNetwork(), g.getLeft()))
.toList();
List<AbstractBaseImpact> networkImpacts = listener.flushNetworkModifications();
return NetworkModificationResult.builder()
Expand All @@ -160,7 +159,7 @@ private NetworkModificationResult processApplication(List<Pair<String, List<Modi
private ApplicationStatus apply(List<ModificationInfos> modificationInfosList, Network network, ReportInfos reportInfos) {
ReportNode reportNode;
if (reportInfos.getReporterId() != null) {
String rootReporterId = reportInfos.getReporterId() + "@" + NETWORK_MODIFICATION_TYPE_REPORT;
String rootReporterId = reportInfos.getReporterId();
reportNode = ReportNode.newRootReportNode().withMessageTemplate(rootReporterId, rootReporterId).build();
} else {
reportNode = ReportNode.NO_OP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ public Network cloneNetworkVariant(UUID networkUuid,
@Transactional(readOnly = true)
public NetworkModificationResult buildVariant(@NonNull UUID networkUuid, @NonNull BuildInfos buildInfos) {
// Apply all modifications belonging to the modification groups uuids in buildInfos
List<Pair<String, List<ModificationInfos>>> modificationInfos = new ArrayList<>();
List<Pair<ReportInfos, List<ModificationInfos>>> modificationInfos = new ArrayList<>();

Streams.forEachPair(buildInfos.getModificationGroupUuids().stream(), buildInfos.getReporterIds().stream(),
Streams.forEachPair(buildInfos.getModificationGroupUuids().stream(), buildInfos.getReportsInfos().stream(),
(groupUuid, reporterId) -> {
List<ModificationInfos> modificationsByGroup = List.of();
try {
Expand Down Expand Up @@ -194,7 +194,7 @@ public NetworkModificationResult buildVariant(@NonNull UUID networkUuid, @NonNul
Network network = cloneNetworkVariant(networkUuid, buildInfos.getOriginVariantId(), buildInfos.getDestinationVariantId(), preloadingStrategy);
NetworkInfos networkInfos = new NetworkInfos(network, networkUuid, true);

return modificationApplicator.applyModifications(modificationInfos, networkInfos, buildInfos.getReportUuid());
return modificationApplicator.applyModifications(modificationInfos, networkInfos);
}

public void buildVariantRequest(UUID networkUuid, BuildInfos buildInfos, String receiver) {
Expand Down

This file was deleted.

Loading

0 comments on commit 3785d6e

Please sign in to comment.