korlov42 commented on code in PR #7324:
URL: https://github.com/apache/ignite-3/pull/7324#discussion_r2652988978


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -589,25 +591,26 @@ public static boolean shouldCreateNewDefaultZone(Catalog 
catalog, @Nullable Stri
      */
     public static CatalogZoneDescriptor createDefaultZoneDescriptor(
             Catalog catalog,
+            PartitionCountProvider partitionCountProvider,
             int newDefaultZoneId,
             Collection<UpdateEntry> updateEntries
     ) throws CatalogValidationException {
         // TODO: Remove after 
https://issues.apache.org/jira/browse/IGNITE-26798
         checkDuplicateDefaultZoneName(catalog);
 
-        CatalogZoneDescriptor defaultZone = 
createDefaultZoneDescriptor(newDefaultZoneId);
+        CatalogZoneDescriptor defaultZone = 
createDefaultZoneDescriptor(partitionCountProvider, newDefaultZoneId);
 
         updateEntries.add(new NewZoneEntry(defaultZone));
         updateEntries.add(new SetDefaultZoneEntry(defaultZone.id()));
 
         return defaultZone;
     }
 
-    private static CatalogZoneDescriptor createDefaultZoneDescriptor(int 
newDefaultZoneId) {
+    private static CatalogZoneDescriptor 
createDefaultZoneDescriptor(PartitionCountProvider partitionCountProvider, int 
newDefaultZoneId) {
         return new CatalogZoneDescriptor(
                 newDefaultZoneId,
                 DEFAULT_ZONE_NAME,
-                DEFAULT_PARTITION_COUNT,
+                defaultZonePartitionCount(partitionCountProvider),

Review Comment:
   it's better to set parameters explicitly



##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/PartitionCountCalculationParameters.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * 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;
+
+import static java.util.Objects.requireNonNullElse;
+import static 
org.apache.ignite.internal.catalog.CatalogParamsValidationUtils.validateField;
+import static 
org.apache.ignite.internal.catalog.CatalogParamsValidationUtils.validateStorageProfileNames;
+import static 
org.apache.ignite.internal.catalog.CatalogParamsValidationUtils.validateZoneFilter;
+import static 
org.apache.ignite.internal.catalog.CatalogService.DEFAULT_STORAGE_PROFILE;
+import static 
org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_FILTER;
+import static 
org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_REPLICA_COUNT;
+
+import java.util.List;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Parameters container for {@link PartitionCountProvider#calculate}.
+ */
+public final class PartitionCountCalculationParameters {
+    /** Data nodes filter. */

Review Comment:
   such comments doesn't bring any value. Please provide meaningful one or just 
drop these



##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/PartitionCountProviderWrapper.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+/**
+ * Wrapper that allows to apply and use different partition count computing 
approaches.
+ */
+public final class PartitionCountProviderWrapper implements 
PartitionCountProvider {
+    /** Wrapped delegate to compute partition count. */
+    private PartitionCountProvider delegate;

Review Comment:
   let's have it `volatile`



##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogManagerImpl.java:
##########
@@ -114,19 +115,45 @@ public class CatalogManagerImpl extends 
AbstractEventProducer<CatalogEvent, Cata
     private final Object lastSaveUpdateFutureMutex = new Object();
 
     /**
-     * Constructor.
+     * Partition count provider for command update contexts.
+     */
+    private final PartitionCountProvider partitionCountProvider;
+
+    /**
+     * Test-only constructor.
      */
+    @TestOnly
     public CatalogManagerImpl(

Review Comment:
   let's have only one constructor. There are not so many usages



##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/PartitionCountProviderWrapper.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+/**
+ * Wrapper that allows to apply and use different partition count computing 
approaches.
+ */
+public final class PartitionCountProviderWrapper implements 
PartitionCountProvider {

Review Comment:
   wrapper should be moved to `runner` module. Also, what about tests for this 
class?



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

Reply via email to