ivanzlenko commented on code in PR #6549:
URL: https://github.com/apache/ignite-3/pull/6549#discussion_r2343931549


##########
modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/raft/CmgRaftService.java:
##########
@@ -148,10 +149,18 @@ public CompletableFuture<Void> 
startJoinCluster(ClusterTag clusterTag, NodeAttri
         return raftService.run(command, RaftCommandRunner.NO_TIMEOUT)
                 .thenAccept(response -> {
                     if (response instanceof ValidationErrorResponse) {
-                        throw new 
JoinDeniedException(((ValidationErrorResponse) response).reason());
+                        var validationErrorResponse = 
(ValidationErrorResponse) response;
+
+                        if (validationErrorResponse.isInvalidNodeConfig()) {
+                            var invalidNodeConfigurationException = new 
InvalidNodeConfigurationException(validationErrorResponse.reason());
+
+                            throw new 
JoinDeniedException(invalidNodeConfigurationException.code(), 
invalidNodeConfigurationException);

Review Comment:
   I'm not sure if it is a correct pattern to create such exception. 



##########
modules/cluster-management/src/integrationTest/java/org/apache/ignite/internal/cluster/management/ItClusterManagerTest.java:
##########
@@ -767,4 +768,27 @@ void 
testInitFailsOnDifferentEnabledColocationModesWithinCmgNodes(boolean coloca
                         + ", recipientColocationMode=" + !colocationEnabled + 
"]."
         );
     }
+
+    @ParameterizedTest
+    @ValueSource(booleans = {false, true})

Review Comment:
   Do not think this test should be parameterized



##########
modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/raft/ValidationResult.java:
##########
@@ -25,23 +25,32 @@
 public class ValidationResult {
     @Nullable
     private final String errorDescription;
+    private final boolean invalidNodeConfig;
 
-    private ValidationResult(@Nullable String errorDescription) {
+    private ValidationResult(@Nullable String errorDescription, boolean 
invalidNodeConfig) {
         this.errorDescription = errorDescription;
+        this.invalidNodeConfig = invalidNodeConfig;
     }
 
     /**
      * Creates a successful validation result.
      */
-    public static ValidationResult successfulResult() {
-        return new ValidationResult(null);
+    static ValidationResult successfulResult() {
+        return new ValidationResult(null, false);
+    }
+
+    /**
+     * Creates a failed validation result with a flag denoting whether caused 
by invalid node configuration.
+     */
+    static ValidationResult errorResult(String errorDescription, boolean 
invalidNodeConfig) {

Review Comment:
   Let's create a separate method configErrorResult, or something like that and 
hide work with raw boolean value. In that case it will be much easier to 
understand what is going on. 



##########
modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/raft/CmgRaftService.java:
##########
@@ -148,10 +149,18 @@ public CompletableFuture<Void> 
startJoinCluster(ClusterTag clusterTag, NodeAttri
         return raftService.run(command, RaftCommandRunner.NO_TIMEOUT)
                 .thenAccept(response -> {
                     if (response instanceof ValidationErrorResponse) {
-                        throw new 
JoinDeniedException(((ValidationErrorResponse) response).reason());
+                        var validationErrorResponse = 
(ValidationErrorResponse) response;
+
+                        if (validationErrorResponse.isInvalidNodeConfig()) {
+                            var invalidNodeConfigurationException = new 
InvalidNodeConfigurationException(validationErrorResponse.reason());
+
+                            throw new 
JoinDeniedException(invalidNodeConfigurationException.code(), 
invalidNodeConfigurationException);

Review Comment:
   Not to mention that parent exception should has it's own message. 



##########
modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/InvalidNodeConfigurationException.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.cluster.management;
+
+import static 
org.apache.ignite.lang.ErrorGroups.CommonConfiguration.CONFIGURATION_VALIDATION_ERR;
+
+import org.apache.ignite.internal.lang.IgniteInternalException;
+
+/**
+ * Exception representing invalid node configuration. This is used to 
differentiate from other errors.

Review Comment:
   let's remove this part: 'This is used to differentiate from other errors.'



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