You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "Cyrill (via GitHub)" <gi...@apache.org> on 2024/10/31 20:42:06 UTC

[PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Cyrill opened a new pull request, #4667:
URL: https://github.com/apache/ignite-3/pull/4667

   https://issues.apache.org/jira/browse/IGNITE-23449


-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "kgusakov (via GitHub)" <gi...@apache.org>.
kgusakov commented on code in PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667#discussion_r1829252414


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/descriptors/ConsistencyMode.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.catalog.descriptors;
+
+/**
+ * Specifies the consistency mode of the zone, determining how the system balances data consistency and availability.
+ */
+public enum ConsistencyMode {
+

Review Comment:
   Redundant empty line



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java:
##########
@@ -189,6 +193,20 @@ public DdlSqlToCommandConverter() {
         ));
     }
 
+    /**
+     * Parse string representation of consistency mode.
+     *
+     * @param consistencyMode String representation of consistency mode.
+     * @return Consistency mode
+     */
+    public static ConsistencyMode parseConsistencyMode(String consistencyMode) {
+        try {
+            return ConsistencyMode.valueOf(consistencyMode);
+        } catch (IllegalArgumentException e) {
+            throw new SqlException(STMT_VALIDATION_ERR, "Failed to parse consistency mode: " + consistencyMode);

Review Comment:
   It will be great from the UX point of view to list the valid values here.



##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CreateZoneCommand.java:
##########
@@ -245,6 +254,13 @@ public CreateZoneCommandBuilder storageProfilesParams(List<StorageProfileParams>
             return this;
         }
 
+        @Override
+        public CreateZoneCommandBuilder consistencyModeParams(@Nullable ConsistencyMode params) {

Review Comment:
   Appropriate test in the `CreateZoneCommandValidationTest` will be great. 



##########
modules/api/src/main/java/org/apache/ignite/catalog/definitions/ZoneDefinition.java:
##########
@@ -43,6 +43,8 @@ public class ZoneDefinition {
 
     private final String storageProfiles;
 
+    private final String consistencyMode;

Review Comment:
   Let's enrich `CreateFromDefinitionTest` with this field testing



##########
modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/CreateFromDefinitionImpl.java:
##########
@@ -84,6 +84,10 @@ CreateFromDefinitionImpl from(ZoneDefinition def) {
         if (!StringUtils.nullOrBlank(def.filter())) {
             createZone.filter(def.filter());
         }
+
+        if (!StringUtils.nullOrBlank(def.consistencyMode())) {

Review Comment:
   I see, that number properties checked by `isGreaterThanOrEqualToZero` here, shouldn't we check that the `consistencyMode` is a valid value from the enum here, too?



##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CreateZoneCommand.java:
##########
@@ -136,7 +142,8 @@ private CatalogZoneDescriptor descriptor(int objectId) {
                 ),
                 Objects.requireNonNullElse(dataNodesAutoAdjustScaleDown, INFINITE_TIMER_VALUE),
                 Objects.requireNonNullElse(filter, DEFAULT_FILTER),
-                fromParams(storageProfileParams)
+                fromParams(storageProfileParams),
+                Objects.requireNonNullElse(consistencyMode, STRONG_CONSISTENCY)

Review Comment:
   Shouldn't we validate that `consistencyMode` has only appropriate values and throw appropriate CatalogValidationException with detailed message otherwise?



##########
modules/catalog/src/test/java/org/apache/ignite/internal/catalog/descriptors/CatalogZoneDescriptorTest.java:
##########
@@ -39,7 +39,8 @@ void toStringContainsTypeAndFields() {
                 5,
                 6,
                 "the-filter",
-                fromParams(List.of(StorageProfileParams.builder().storageProfile(DEFAULT_STORAGE_PROFILE).build()))
+                fromParams(List.of(StorageProfileParams.builder().storageProfile(DEFAULT_STORAGE_PROFILE).build())),

Review Comment:
   Let's add appropriate `assertThat` in this test



##########
modules/api/src/main/java/org/apache/ignite/catalog/annotations/Zone.java:
##########
@@ -90,4 +90,11 @@
      * @return Nodes filter.
      */
     String filter() default "";
+
+    /**
+     * Consistency mode.
+     *
+     * @return Consistency mode.
+     */
+    String consistencyMode() default "";

Review Comment:
   Let's enrich `CreateFromAnnotationsTest` with this field testing



-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667#discussion_r1829303913


##########
modules/catalog/src/test/java/org/apache/ignite/internal/catalog/descriptors/CatalogZoneDescriptorTest.java:
##########
@@ -39,7 +39,8 @@ void toStringContainsTypeAndFields() {
                 5,
                 6,
                 "the-filter",
-                fromParams(List.of(StorageProfileParams.builder().storageProfile(DEFAULT_STORAGE_PROFILE).build()))
+                fromParams(List.of(StorageProfileParams.builder().storageProfile(DEFAULT_STORAGE_PROFILE).build())),

Review Comment:
   Done



-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667#discussion_r1829643033


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CreateZoneCommand.java:
##########
@@ -245,6 +254,13 @@ public CreateZoneCommandBuilder storageProfilesParams(List<StorageProfileParams>
             return this;
         }
 
+        @Override
+        public CreateZoneCommandBuilder consistencyModeParams(@Nullable ConsistencyMode params) {

Review Comment:
   Done



-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667#discussion_r1829647098


##########
modules/api/src/main/java/org/apache/ignite/catalog/definitions/ZoneDefinition.java:
##########
@@ -43,6 +43,8 @@ public class ZoneDefinition {
 
     private final String storageProfiles;
 
+    private final String consistencyMode;

Review Comment:
   Done



-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667#discussion_r1829668090


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CreateZoneCommand.java:
##########
@@ -136,7 +142,8 @@ private CatalogZoneDescriptor descriptor(int objectId) {
                 ),
                 Objects.requireNonNullElse(dataNodesAutoAdjustScaleDown, INFINITE_TIMER_VALUE),
                 Objects.requireNonNullElse(filter, DEFAULT_FILTER),
-                fromParams(storageProfileParams)
+                fromParams(storageProfileParams),
+                Objects.requireNonNullElse(consistencyMode, STRONG_CONSISTENCY)

Review Comment:
   done



-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667#discussion_r1829658796


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/descriptors/ConsistencyMode.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.catalog.descriptors;
+
+/**
+ * Specifies the consistency mode of the zone, determining how the system balances data consistency and availability.
+ */
+public enum ConsistencyMode {
+

Review Comment:
   done



-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667#discussion_r1829771783


##########
modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/CreateFromDefinitionImpl.java:
##########
@@ -84,6 +84,10 @@ CreateFromDefinitionImpl from(ZoneDefinition def) {
         if (!StringUtils.nullOrBlank(def.filter())) {
             createZone.filter(def.filter());
         }
+
+        if (!StringUtils.nullOrBlank(def.consistencyMode())) {

Review Comment:
   added



-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667#discussion_r1829310316


##########
modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/CreateFromDefinitionImpl.java:
##########
@@ -84,6 +84,10 @@ CreateFromDefinitionImpl from(ZoneDefinition def) {
         if (!StringUtils.nullOrBlank(def.filter())) {
             createZone.filter(def.filter());
         }
+
+        if (!StringUtils.nullOrBlank(def.consistencyMode())) {

Review Comment:
   Well, it's validated in DdlSqlToCommandConverter. 
   I see there are a few places where the validation is performed. Which of them are mandatory? 
   



-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667#discussion_r1829678777


##########
modules/api/src/main/java/org/apache/ignite/catalog/annotations/Zone.java:
##########
@@ -90,4 +90,11 @@
      * @return Nodes filter.
      */
     String filter() default "";
+
+    /**
+     * Consistency mode.
+     *
+     * @return Consistency mode.
+     */
+    String consistencyMode() default "";

Review Comment:
   Done



-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "vldpyatkov (via GitHub)" <gi...@apache.org>.
vldpyatkov merged PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667


-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "kgusakov (via GitHub)" <gi...@apache.org>.
kgusakov commented on code in PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667#discussion_r1831171168


##########
modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateFromAnnotationsTest.java:
##########
@@ -150,6 +151,29 @@ void createFromRecordClass() {
         );
     }
 
+    @Test
+    void testDefinitionInvalid() {
+        ZoneDefinition zoneDefinition = ZoneDefinition.builder("zone_test")
+                .ifNotExists()
+                .partitions(1)
+                .replicas(3)
+                .distributionAlgorithm("partitionDistribution")
+                .dataNodesAutoAdjust(1)
+                .dataNodesAutoAdjustScaleDown(2)
+                .dataNodesAutoAdjustScaleUp(3)
+                .filter("filter")
+                .storageProfiles("default")
+                .consistencyMode("MY_CONSISTENCY")
+                .build();
+
+        assertThrows(IllegalArgumentException.class, () -> new CreateFromDefinitionImpl(null).from(zoneDefinition));

Review Comment:
   The better place for this test is the `CreateFromDefinitionTest`, isn't it?



-- 
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


Re: [PR] IGNITE-23449 Add support of the new flag HA in zone description [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #4667:
URL: https://github.com/apache/ignite-3/pull/4667#discussion_r1829652358


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java:
##########
@@ -189,6 +193,20 @@ public DdlSqlToCommandConverter() {
         ));
     }
 
+    /**
+     * Parse string representation of consistency mode.
+     *
+     * @param consistencyMode String representation of consistency mode.
+     * @return Consistency mode
+     */
+    public static ConsistencyMode parseConsistencyMode(String consistencyMode) {
+        try {
+            return ConsistencyMode.valueOf(consistencyMode);
+        } catch (IllegalArgumentException e) {
+            throw new SqlException(STMT_VALIDATION_ERR, "Failed to parse consistency mode: " + consistencyMode);

Review Comment:
   Done



-- 
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