alievmirza commented on code in PR #1532:
URL: https://github.com/apache/ignite-3/pull/1532#discussion_r1072283593
##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -590,6 +584,32 @@ private void updateMetaStorageOnZoneDelete(int zoneId,
long revision) {
}
}
+ /**
+ * Updates {@link DistributionZoneChange} according to distribution zone
configuration.
+ *
+ * @param zoneChange Zone change.
+ * @param distributionZoneCfg Distribution zone configuration.
+ */
+ private void updateZoneChange(DistributionZoneChange zoneChange,
DistributionZoneConfigurationParameters distributionZoneCfg) {
Review Comment:
May be static.
##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -289,54 +290,43 @@ public CompletableFuture<Void> alterZone(String name,
DistributionZoneConfigurat
try {
CompletableFuture<Void> fut = new CompletableFuture<>();
- zonesConfiguration.change(zonesChange ->
zonesChange.changeDistributionZones(zonesListChange -> {
- NamedListChange<DistributionZoneView, DistributionZoneChange>
renameChange;
+ CompletableFuture<Void> change;
- try {
- renameChange = zonesListChange.rename(name,
distributionZoneCfg.name());
- } catch (IllegalArgumentException e) {
- throw new DistributionZoneRenameException(name,
distributionZoneCfg.name(), e);
- }
+ if (DEFAULT_ZONE_NAME.equals(name)) {
+ change = zonesConfiguration.change(zonesChange -> zonesChange
Review Comment:
I would use formatting like this
```
change = zonesConfiguration.change(
zonesChange ->
zonesChange.changeDefaultDistributionZone(
zoneChange -> updateZoneChange(zoneChange,
distributionZoneCfg)
)
);
```
##########
modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/DistributionZoneManagerTest.java:
##########
@@ -226,59 +226,87 @@ public void testDropZoneIfNotExists() {
}
@Test
- public void testUpdateZone() throws Exception {
- distributionZoneManager.createZone(
- new
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).dataNodesAutoAdjust(100).build()
- )
- .get(5, TimeUnit.SECONDS);
+ public void testUpdateDefaultZone() throws Exception {
+ testUpdateZone(DEFAULT_ZONE_NAME);
+ }
- DistributionZoneConfiguration zone1 =
registry.getConfiguration(DistributionZonesConfiguration.KEY).distributionZones()
- .get(ZONE_NAME);
+ @Test
+ public void testUpdateNotDefaultZone() throws Exception {
+ testUpdateZone(ZONE_NAME);
+ }
- assertNotNull(zone1, "Zone was not created.");
- assertEquals(ZONE_NAME, zone1.name().value(), "Zone name is wrong.");
- assertEquals(Integer.MAX_VALUE,
zone1.dataNodesAutoAdjustScaleUp().value(), "dataNodesAutoAdjustScaleUp is
wrong.");
- assertEquals(Integer.MAX_VALUE,
zone1.dataNodesAutoAdjustScaleDown().value(), "dataNodesAutoAdjustScaleDown is
wrong.");
- assertEquals(100, zone1.dataNodesAutoAdjust().value(),
"dataNodesAutoAdjust is wrong.");
+ public void testUpdateZone(String zoneName) throws Exception {
Review Comment:
```suggestion
private void testUpdateZone(String zoneName) throws Exception {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]