You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2023/01/17 17:32:10 UTC

[GitHub] [ignite-3] alievmirza commented on a diff in pull request #1532: IGNITE-18540 Fixed processing of the default distribution zone.

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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org