-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize temporary and permanent limits db writings and db reading (#82)
We do this slow data migration asynchronously in parallel to the server normal operations over the coming weeks. We force the migration when writing new data. In a few weeks, we will force the migration at startup of the server of all the remaining data that has not been migrated yet. Signed-off-by: Etienne Homer <[email protected]> Co-authored-by: Etienne LESOT <[email protected]>
- Loading branch information
Showing
15 changed files
with
1,229 additions
and
110 deletions.
There are no files selected for viewing
This file contains 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
179 changes: 123 additions & 56 deletions
179
...k-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreRepository.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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
51 changes: 51 additions & 0 deletions
51
...ore-server/src/main/java/com/powsybl/network/store/server/json/PermanentLimitSqlData.java
This file contains 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,51 @@ | ||
/** | ||
* Copyright (c) 2024, 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 com.powsybl.network.store.server.json; | ||
|
||
import com.powsybl.iidm.network.LimitType; | ||
import com.powsybl.network.store.server.dto.PermanentLimitAttributes; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
/** | ||
* @author Etienne Lesot <etienne.lesot at rte-france.com> | ||
*/ | ||
@ToString | ||
@Builder | ||
@AllArgsConstructor | ||
@Getter | ||
public class PermanentLimitSqlData { | ||
|
||
private String operationalLimitsGroupId; | ||
private double value; | ||
private Integer side; | ||
private LimitType limitType; | ||
|
||
public PermanentLimitSqlData() { | ||
// empty constructor for Jackson | ||
} | ||
|
||
public static PermanentLimitSqlData of(PermanentLimitAttributes permanentLimitAttributes) { | ||
return PermanentLimitSqlData.builder() | ||
.operationalLimitsGroupId(permanentLimitAttributes.getOperationalLimitsGroupId()) | ||
.value(permanentLimitAttributes.getValue()) | ||
.side(permanentLimitAttributes.getSide()) | ||
.limitType(permanentLimitAttributes.getLimitType()) | ||
.build(); | ||
} | ||
|
||
public PermanentLimitAttributes toPermanentLimitAttributes() { | ||
return PermanentLimitAttributes.builder() | ||
.operationalLimitsGroupId(operationalLimitsGroupId) | ||
.value(value) | ||
.side(side) | ||
.limitType(limitType) | ||
.build(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ore-server/src/main/java/com/powsybl/network/store/server/json/TemporaryLimitSqlData.java
This file contains 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,59 @@ | ||
/** | ||
* Copyright (c) 2024, 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 com.powsybl.network.store.server.json; | ||
|
||
import com.powsybl.iidm.network.LimitType; | ||
import com.powsybl.network.store.model.TemporaryLimitAttributes; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
/** | ||
* @author Etienne Lesot <etienne.lesot at rte-france.com> | ||
*/ | ||
@ToString | ||
@Builder | ||
@AllArgsConstructor | ||
@Getter | ||
public class TemporaryLimitSqlData { | ||
private String operationalLimitsGroupId; | ||
private Integer side; | ||
private LimitType limitType; | ||
private String name; | ||
private double value; | ||
private Integer acceptableDuration; | ||
private boolean fictitious; | ||
|
||
public TemporaryLimitSqlData() { | ||
// empty constructor for Jackson | ||
} | ||
|
||
public static TemporaryLimitSqlData of(TemporaryLimitAttributes temporaryLimit) { | ||
return TemporaryLimitSqlData.builder() | ||
.operationalLimitsGroupId(temporaryLimit.getOperationalLimitsGroupId()) | ||
.side(temporaryLimit.getSide()) | ||
.limitType(temporaryLimit.getLimitType()) | ||
.name(temporaryLimit.getName()) | ||
.value(temporaryLimit.getValue()) | ||
.acceptableDuration(temporaryLimit.getAcceptableDuration()) | ||
.fictitious(temporaryLimit.isFictitious()) | ||
.build(); | ||
} | ||
|
||
public TemporaryLimitAttributes toTemporaryLimitAttributes() { | ||
return TemporaryLimitAttributes.builder() | ||
.operationalLimitsGroupId(operationalLimitsGroupId) | ||
.side(side) | ||
.limitType(limitType) | ||
.name(name) | ||
.value(value) | ||
.acceptableDuration(acceptableDuration) | ||
.fictitious(fictitious) | ||
.build(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...-server/src/main/java/com/powsybl/network/store/server/migration/MigrationController.java
This file contains 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,42 @@ | ||
/** | ||
* Copyright (c) 2024, 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 com.powsybl.network.store.server.migration; | ||
|
||
import com.powsybl.network.store.model.*; | ||
import com.powsybl.network.store.server.NetworkStoreRepository; | ||
import com.powsybl.network.store.server.migration.v211limits.V211LimitsMigration; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.*; | ||
|
||
/** | ||
* @author Etienne Homer <etienne.homer at rte-france.com> | ||
*/ | ||
@RestController | ||
@RequestMapping(value = "/" + NetworkStoreApi.VERSION + "/migration") | ||
@Tag(name = "Network store migration") | ||
public class MigrationController { | ||
|
||
@Autowired | ||
private NetworkStoreRepository repository; | ||
|
||
@PutMapping(value = "/v211limits/{networkId}/{variantNum}") | ||
@Operation(summary = "Migrate limits of a network") | ||
@ApiResponses(@ApiResponse(responseCode = "200", description = "Successfully migrated limits from V2.11.0 to new model")) | ||
public ResponseEntity<Void> migrateV211Limits(@Parameter(description = "Network ID", required = true) @PathVariable("networkId") UUID networkId, | ||
@Parameter(description = "Variant num", required = true) @PathVariable("variantNum") int variantNum) { | ||
V211LimitsMigration.migrateV211Limits(repository, networkId, variantNum); | ||
return ResponseEntity.ok().build(); | ||
} | ||
} |
Oops, something went wrong.