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



##########
File path: 
modules/configuration-annotation-processor/src/main/java/org/apache/ignite/configuration/processor/internal/Processor.java
##########
@@ -394,8 +393,8 @@ private ConfigurationFieldTypes getTypes(final 
VariableElement field) {
 
         final Value valueAnnotation = field.getAnnotation(Value.class);
         if (valueAnnotation != null) {
-            ClassName dynPropClass = ClassName.get(DynamicProperty.class);
-            ClassName confValueClass = ClassName.get(ConfigurationValue.class);
+            ClassName dynPropClass = 
ClassName.get("org.apache.ignite.configuration.internal", "DynamicProperty");

Review comment:
       Just being curious: why did you change this?

##########
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<>();
 
+    /** */
+    @FunctionalInterface
+    public interface Notificator {
+        /** */
+        @NotNull CompletableFuture<?> notify(SuperRoot oldRoot, SuperRoot 
newRoot, long storageRevision);

Review comment:
       why not `CompletableFuture<Void>`?

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/configuration/internal/util/ConfigurationUtil.java
##########
@@ -508,6 +509,45 @@ public static void addDefaults(InnerNode src, InnerNode 
dst) {
         };
     }
 
+    /**
+     * Nullifies values in {@code newNode} that 100% match with corresponding 
values in {@code curNode}.

Review comment:
       Sorry, I don't understand what you are trying to say here...

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/configuration/ConfigurationRegistry.java
##########
@@ -113,6 +124,38 @@ public void registerStorage(ConfigurationStorage 
configurationStorage) {
         return changer.changeX(path, changesSource, storage);
     }
 
+    /** */
+    public void stop() {
+        changer.stop();
+    }
+
+    /** */
+    private @NotNull CompletableFuture<?> notificator(SuperRoot oldSuperRoot, 
SuperRoot newSuperRoot, long storageRevision) {
+        List<CompletableFuture<?>> futures = new ArrayList<>();
+
+        newSuperRoot.traverseChildren(new ConfigurationVisitor<Void>() {
+            @Override public Void visitInnerNode(String key, InnerNode 
newRoot) {
+                InnerNode oldRoot = oldSuperRoot.traverseChild(key, 
innerNodeVisitor());
+
+                var cfg = (DynamicConfiguration<InnerNode, ?, 
?>)configs.get(key);
+
+                assert oldRoot != null && cfg != null : key;
+
+                if (oldRoot != newRoot)
+                    notifyListeners(oldRoot, newRoot, cfg, storageRevision, 
futures);
+
+                return null;
+            }
+        });
+
+        return CompletableFuture.allOf(futures.stream().map(listenerFut -> 
listenerFut.handle((res, throwable) -> {

Review comment:
       Please extract the inner stream into a variable, it's hard to read 
otherwise

##########
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.
+     */
+    public ConfigurationChanger(Notificator notificator) {
+        this.notificator = notificator;
+    }
+
+    /** Constructor for tests. */
+    @TestOnly
+    ConfigurationChanger(RootKey<?, ?>... rootKeys) {

Review comment:
       Can it be extracted somewhere?

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/configuration/storage/ConfigurationStorage.java
##########
@@ -59,4 +51,10 @@
      * @param listener Listener.
      */
     void removeListener(ConfigurationStorageListener listener);
+
+    /**
+     * Notify storage that this specific revision was successfully handled and 
there's no necessity to repeat the same

Review comment:
       ```suggestion
        * Notify storage that this specific revision was successfully handled 
and it is not necessary to repeat the same
   ```

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

Review comment:
       why do you need this class? It's only used in `ConfigurationRegistry`

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/configuration/ConfigurationChanger.java
##########
@@ -200,6 +224,11 @@ public void initialize(Class<? extends 
ConfigurationStorage> storageType) {
         return change(superRoot, storage.getClass());
     }
 
+    /** Stop component. */
+    public void stop() {
+        pool.shutdownNow();

Review comment:
       AFAIK, this is not a good way to shutdown an executor. Usually it is 
done in a much more complex way (see 
[guava](https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/MoreExecutors.java#L1068)
 for example)




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