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-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org