sashapolo commented on code in PR #2066:
URL: https://github.com/apache/ignite-3/pull/2066#discussion_r1195257941


##########
modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/ClusterManagementGroupManager.java:
##########
@@ -389,46 +387,45 @@ private void onElectedAsLeader(long term) {
                     }
                 });
 
-        raftServiceAfterJoin().thenCompose(this::pushClusterConfigToCluster);
+        raftServiceAfterJoin().whenComplete((service, e) -> {
+            if (e != null) {
+                LOG.error("Error when joining to the raft service", e);
+                
updateDistributedConfigurationActionFuture.completeExceptionally(e);
+            } else {
+                service.readClusterState()
+                        .thenAccept(state -> 
updateDistributedConfigurationActionFuture.complete(

Review Comment:
   Why do we read the state here, then ignore it and read it again in 
`updateClusterConfigurationAndRemoveFromState`?



##########
modules/runner/src/main/java/org/apache/ignite/internal/configuration/DistributedConfigurationUpdater.java:
##########
@@ -31,37 +30,27 @@ public class DistributedConfigurationUpdater implements 
IgniteComponent {
 
     private static final IgniteLogger LOG = 
Loggers.forClass(DistributedConfigurationUpdater.class);
 
-    private final CompletableFuture<ConfigurationPresentation<String>> 
clusterCfgPresentation = new CompletableFuture<>();
+    private final ClusterManagementGroupManager cmgMgr;
 
-    public void 
setDistributedConfigurationPresentation(ConfigurationPresentation<String> 
presentation) {
-        clusterCfgPresentation.complete(presentation);
+    private final ConfigurationPresentation<String> presentation;
+
+    public DistributedConfigurationUpdater(ClusterManagementGroupManager 
cmgMgr, ConfigurationPresentation<String> presentation) {
+        this.cmgMgr = cmgMgr;
+        this.presentation = presentation;
     }
 
-    /**
-     * Applies changes to the cluster configuration when {@link 
DistributedConfigurationUpdater#clusterCfgPresentation}
-     * is complete.
-     *
-     * @param configurationToApply Cluster configuration that should be 
applied.
-     * @return Future that will be completed when cluster configuration is 
updated.
-     */
-    public CompletableFuture<Void> updateConfiguration(String 
configurationToApply) {
-        return clusterCfgPresentation.thenCompose(presentation -> 
presentation.update(configurationToApply))
+    @Override
+    public void start() {
+        cmgMgr.clusterConfigurationToUpdate()
+                .thenApply(action -> action.execute(presentation::update))

Review Comment:
   this must be `thenCompose`



##########
modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/UpdateDistributedConfigurationAction.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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 java.util.concurrent.CompletableFuture;
+import java.util.function.Function;
+
+/**
+ * Action to update the distributed configuration.
+ */
+public class UpdateDistributedConfigurationAction {
+
+    /**
+     * Action that should be executed.
+     */
+    private final Function<Function<String, CompletableFuture<Void>>, 
CompletableFuture<Void>> action;

Review Comment:
   Well, the code became worse since the last time, I think =) It's too 
complicated now. I would suggest to do the following:
   1. Have a `String` field, just as you had before.
   2. Change the action type to `Supplier<CompletableFuture<Void>>`, which will 
be used by the CMG manager to cleanup the configuration.



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