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

[GitHub] [ignite-3] valepakh commented on a diff in pull request #2207: IGNITE-19760 Create cluster status before deployment unit files uploading

valepakh commented on code in PR #2207:
URL: https://github.com/apache/ignite-3/pull/2207#discussion_r1238115550


##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/DeploymentManagerImpl.java:
##########
@@ -182,12 +159,12 @@ private CompletableFuture<Boolean> doDeploy(
             String id,
             Version version,
             boolean force,
-            DeploymentUnit deploymentUnit,
+            CompletableFuture<DeploymentUnit> unitFuture,
             Set<String> nodesToDeploy,
             Function<Boolean, CompletableFuture<Boolean>> retryDeploy

Review Comment:
   This function is not needed anymore and can be replaced with the direct call.



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/IgniteDeployment.java:
##########
@@ -33,16 +33,16 @@ public interface IgniteDeployment extends IgniteComponent {
      * @param id Unit identifier. Not empty and not null.
      * @param version Unit version.
      * @param deploymentUnit Unit content.
-     * @param deployMode Initial deploy mode.
+     * @param deployedNodes Initial deploy mode.

Review Comment:
   `Initial nodes to deploy`?



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/IgniteDeployment.java:
##########
@@ -53,53 +53,15 @@ default CompletableFuture<Boolean> deployAsync(
      * @param version Unit version.
      * @param force Force redeploy if unit with provided id and version exists.
      * @param deploymentUnit Unit content.
-     * @param deployMode Initial deploy mode.
+     * @param deployedNodes Initial deploy mode.

Review Comment:
   Same as above.



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/DeployedNodes.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.deployunit;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.cluster.management.ClusterManagementGroupManager;
+import org.apache.ignite.internal.deployunit.exception.InvalidNodesArgumentException;
+import org.apache.ignite.network.ClusterNode;
+
+/**
+ * Nodes for initial deploy.
+ */
+public class DeployedNodes {
+    /**
+     * Direct nodes list.
+     */
+    private final List<String> nodesList;
+
+    /**
+     * Deploy nodes mode.
+     */
+    private final InitialDeployMode deployMode;
+
+    public DeployedNodes(List<String> nodesList) {
+        this(null, nodesList);
+    }
+
+    public DeployedNodes(InitialDeployMode deployMode) {
+        this(deployMode, null);
+    }
+
+    private DeployedNodes(InitialDeployMode deployMode, List<String> nodesList) {
+        this.deployMode = deployMode;
+        this.nodesList = nodesList;
+    }
+
+    /**
+     * Returns a list of nodes for initial deployment.
+     *
+     * @param cmgManager Cluster management group.
+     * @return Set of nodes for initial deployment.
+     */
+    public CompletableFuture<Set<String>> extractNodes(ClusterManagementGroupManager cmgManager) {
+        return nodesList != null ? extractNodesFromList(cmgManager) : extractNodesFromMode(cmgManager);
+    }
+
+    private CompletableFuture<Set<String>> extractNodesFromMode(ClusterManagementGroupManager cmgManager) {
+        switch (deployMode) {
+            case ALL:
+                return cmgManager.logicalTopology()
+                        .thenApply(snapshot -> snapshot.nodes().stream()
+                                .map(ClusterNode::name)
+                                .collect(Collectors.toUnmodifiableSet()));
+            case MAJORITY:
+            default:
+                return cmgManager.majority();
+        }
+    }
+
+    private CompletableFuture<Set<String>> extractNodesFromList(ClusterManagementGroupManager cmgManager) {

Review Comment:
   Could you please move the comment as well?



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/DeployedNodes.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.deployunit;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.cluster.management.ClusterManagementGroupManager;
+import org.apache.ignite.internal.deployunit.exception.InvalidNodesArgumentException;
+import org.apache.ignite.network.ClusterNode;
+
+/**
+ * Nodes for initial deploy.
+ */
+public class DeployedNodes {

Review Comment:
   `DeployedNodes` sounds like something already done, maybe `NodesToDeploy` would be a better name?



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