sashapolo commented on a change in pull request #76:
URL: https://github.com/apache/ignite-3/pull/76#discussion_r604842133



##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/configuration/ConfigurationChanger.java
##########
@@ -63,6 +67,16 @@
     /** Annotation classes mapped to validator objects. */
     private Map<Class<? extends Annotation>, Set<Validator<?, ?>>> validators 
= new HashMap<>();
 
+    /** */

Review comment:
       This should be a proper javadoc)

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/configuration/ConfigurationChanger.java
##########
@@ -333,15 +369,25 @@ private void updateFromListener(
 
         compressDeletedEntries(dataValuesPrefixMap);
 
-        SuperRoot newSuperRoot = oldStorageRoots.roots.copy();
+        SuperRoot oldSuperRoot = oldStorageRoots.roots;
+        SuperRoot newSuperRoot = oldSuperRoot.copy();
 
         fillFromPrefixMap(newSuperRoot, dataValuesPrefixMap);
 
-        StorageRoots storageRoots = new StorageRoots(newSuperRoot, 
changedEntries.version());
+        StorageRoots newStorageRoots = new StorageRoots(newSuperRoot, 
changedEntries.cfgVersion());
+
+        storagesRootsMap.put(storageType, newStorageRoots);
+
+        ConfigurationStorage storage = storageInstances.get(storageType);
 
-        storagesRootsMap.put(storageType, storageRoots);
+        long storegeRevision = changedEntries.storageRevision();

Review comment:
       ```suggestion
           long storageRevision = changedEntries.storageRevision();
   ```

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/configuration/notifications/ConfigurationListener.java
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.configuration.notifications;
+
+import java.util.concurrent.CompletableFuture;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Configuration property change listener.
+ *
+ * @param <VIEW> VIEW type configuration.
+ */
+@FunctionalInterface
+public interface ConfigurationListener<VIEW> {
+    /**
+     * Called on property value update.
+     *
+     * @param ctx Notification context.
+     * @return Future that signifies end of listener execution. Can be {@code 
null}.

Review comment:
       What does `null` mean in this context?

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/configuration/ConfigurationChanger.java
##########
@@ -50,7 +54,7 @@
 /**
  * Class that handles configuration changes, by validating them, passing to 
storage and listening to storage updates.
  */
-public class ConfigurationChanger {
+public final class ConfigurationChanger {
     /** */
     private final ForkJoinPool pool = new ForkJoinPool(2);

Review comment:
       BTW, why is this a ForkJoinPool and not a regular fixed thread pool?

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/configuration/ConfigurationChanger.java
##########
@@ -313,8 +339,18 @@ private void change0(
                 fut.completeExceptionally(new 
ConfigurationChangeException("Failed to change configuration", throwable));
             else if (casResult)
                 fut.complete(null);
-            else
+            else {
+                try {
+                    // Is this ok to have a busy wait on concurrent 
configuration updates?
+                    // Maybe we'll fix it while implementing metastorage 
storage implementation.
+                    Thread.sleep(10);
+                }
+                catch (InterruptedException e) {
+                    fut.completeExceptionally(e);

Review comment:
       why do we have to pass the `fut` everywhere instead of using composition 
of CompletableFuture's? For example, instead of `pool.execute` you can use 
`CompletableFuture.supplyAsync` and then use `thenComposeAsync` to "flatmap` 
these futures

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/configuration/ConfigurationChanger.java
##########
@@ -86,8 +100,18 @@ private StorageRoots(SuperRoot roots, long version) {
     /** Storage instances by their classes. Comes in handy when all you have 
is {@link RootKey}. */
     private final Map<Class<? extends ConfigurationStorage>, 
ConfigurationStorage> storageInstances = new HashMap<>();
 
-    /** Constructor. */
-    public ConfigurationChanger(RootKey<?, ?>... rootKeys) {
+    /**
+     * @param notificator Closure to execute when update forom storage is 
received.

Review comment:
       ```suggestion
        * @param notificator Closure to execute when update from the storage is 
received.
   ```

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/configuration/internal/util/ConfigurationNotificationsUtil.java
##########
@@ -0,0 +1,184 @@
+/*
+ * 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.configuration.internal.util;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+import org.apache.ignite.configuration.ConfigurationProperty;
+import org.apache.ignite.configuration.internal.DynamicConfiguration;
+import org.apache.ignite.configuration.internal.DynamicProperty;
+import org.apache.ignite.configuration.internal.NamedListConfiguration;
+import 
org.apache.ignite.configuration.internal.notifications.ConfigurationNotificationEventImpl;
+import org.apache.ignite.configuration.notifications.ConfigurationListener;
+import 
org.apache.ignite.configuration.notifications.ConfigurationNotificationEvent;
+import org.apache.ignite.configuration.tree.ConfigurationVisitor;
+import org.apache.ignite.configuration.tree.InnerNode;
+import org.apache.ignite.configuration.tree.NamedListNode;
+import org.apache.ignite.configuration.tree.NamedListView;
+
+import static 
org.apache.ignite.configuration.internal.util.ConfigurationUtil.innerNodeVisitor;
+import static 
org.apache.ignite.configuration.internal.util.ConfigurationUtil.leafNodeVisitor;
+import static 
org.apache.ignite.configuration.internal.util.ConfigurationUtil.namedListNodeVisitor;
+
+/** */
+public class ConfigurationNotificationsUtil {
+    /**
+     * Recursively notifies all public configuration listeners, accumulating 
resulting futures in {@code futures} list.
+     * @param oldInnerNode Old configuration values root.
+     * @param newInnerNode New configuration values root.
+     * @param cfgNode Public configuration tree node corresponding to the 
current inner nodes.
+     * @param storageRevision Storage revision.
+     * @param futures Write-only list of futures to accumulate results.
+     */
+    public static void notifyListeners(
+        InnerNode oldInnerNode,
+        InnerNode newInnerNode,
+        DynamicConfiguration<InnerNode, ?, ?> cfgNode,
+        long storageRevision,
+        List<CompletableFuture<?>> futures

Review comment:
       Can we make it a return value?




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to