ibessonov commented on a change in pull request #568:
URL: https://github.com/apache/ignite-3/pull/568#discussion_r789534406



##########
File path: 
modules/configuration/src/test/java/org/apache/ignite/internal/configuration/notifications/ConfigurationListenerTest.java
##########
@@ -1383,27 +1389,113 @@ void 
testNotificationEventForNamedConfigAfterNotifyListeners() throws Exception
 
     @Test
     void testGetErrorFromListener() {
-        configuration.child().listen(configListener(ctx -> {
+        config.child().listen(configListener(ctx -> {
             throw new RuntimeException("from test");
         }));
 
         ExecutionException ex = assertThrows(
                 ExecutionException.class,
-                () -> 
configuration.child().str().update(UUID.randomUUID().toString()).get(1, SECONDS)
+                () -> 
config.child().str().update(UUID.randomUUID().toString()).get(1, SECONDS)
         );
 
         assertTrue(hasCause(ex, RuntimeException.class, "from test"));
     }
 
     @Test
     void testGetErrorFromListenerFuture() {
-        configuration.child().listen(ctx -> CompletableFuture.failedFuture(new 
RuntimeException("from test")));
+        config.child().listen(ctx -> CompletableFuture.failedFuture(new 
RuntimeException("from test")));
 
         ExecutionException ex = assertThrows(
                 ExecutionException.class,
-                () -> 
configuration.child().str().update(UUID.randomUUID().toString()).get(1, SECONDS)
+                () -> 
config.child().str().update(UUID.randomUUID().toString()).get(1, SECONDS)
         );
 
         assertTrue(hasCause(ex, RuntimeException.class, "from test"));
     }
+
+    @Test
+    void testNotifyListenersOnCurrentConfigWithoutChange() throws Exception {
+        config.children().change(c -> c.create("0", 
doNothingConsumer())).get(1, SECONDS);
+
+        config.polyChildren().change(c -> c.create("0", 
doNothingConsumer())).get(1, SECONDS);
+
+        Set<String> events = new HashSet<>();
+
+        config.listen(configListener(ctx -> events.add("root")));
+
+        config.child().listen(configListener(ctx -> events.add("child")));
+        config.child().str().listen(configListener(ctx -> 
events.add("child.str")));
+
+        config.children().listen(configListener(ctx -> 
events.add("children")));
+        config.children().listenElements(configNamedListenerOnCreate(ctx -> 
events.add("children.onCreate")));
+        config.children().listenElements(configNamedListenerOnUpdate(ctx -> 
events.add("children.onUpdate")));
+        config.children().listenElements(configNamedListenerOnRename(ctx -> 
events.add("children.onRename")));
+        config.children().listenElements(configNamedListenerOnDelete(ctx -> 
events.add("children.onDelete")));
+
+        config.children().get("0").listen(configListener(ctx -> 
events.add("children.0")));
+        config.children().get("0").str().listen(configListener(ctx -> 
events.add("children.0.str")));
+
+        config.children().any().listen(configListener(ctx -> 
events.add("children.any")));
+        config.children().any().str().listen(configListener(ctx -> 
events.add("children.any.str")));
+
+        // Polymorphic configs.
+
+        config.polyChild().listen(configListener(ctx -> 
events.add("polyChild")));
+        config.polyChild().commonIntVal().listen(configListener(ctx -> 
events.add("polyChild.int")));
+        ((StringPolyConfiguration) 
config.polyChild()).specificVal().listen(configListener(ctx -> 
events.add("polyChild.str")));
+
+        config.polyChildren().listen(configListener(ctx -> 
events.add("polyChildren")));
+        config.polyChildren().listenElements(configNamedListenerOnCreate(ctx 
-> events.add("polyChildren.onCreate")));
+        config.polyChildren().listenElements(configNamedListenerOnUpdate(ctx 
-> events.add("polyChildren.onUpdate")));
+        config.polyChildren().listenElements(configNamedListenerOnRename(ctx 
-> events.add("polyChildren.onRename")));
+        config.polyChildren().listenElements(configNamedListenerOnDelete(ctx 
-> events.add("polyChildren.onDelete")));
+
+        config.polyChildren().get("0").listen(configListener(ctx -> 
events.add("polyChildren.0")));
+        
config.polyChildren().get("0").commonIntVal().listen(configListener(ctx -> 
events.add("polyChildren.0.int")));
+        ((StringPolyConfiguration) 
config.polyChildren().get("0")).specificVal()
+                .listen(configListener(ctx -> 
events.add("polyChildren.0.str")));
+
+        config.polyChildren().any().listen(configListener(ctx -> 
events.add("polyChildren.any")));
+        config.polyChildren().any().commonIntVal().listen(configListener(ctx 
-> events.add("polyChildren.any.int")));
+
+        Collection<CompletableFuture<?>> futs = notifyListeners(
+                null,
+                (InnerNode) config.value(),
+                (DynamicConfiguration) config,
+                0
+        );
+
+        for (CompletableFuture<?> fut : futs) {
+            fut.get(1, SECONDS);
+        }
+
+        assertEquals(
+                Set.of(

Review comment:
       Can this be a list, so that we also check the order?

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/internal/configuration/ConfigurationRegistry.java
##########
@@ -299,6 +314,15 @@ public Void visitInnerNode(String key, InnerNode newRoot) {
         return CompletableFuture.allOf(resultFutures);
     }
 
+    /**
+     * Notifies all listeners of the current configuration.
+     *
+     * @return Future that must signify when processing is completed.
+     */
+    public CompletableFuture<Void> notifyCurrentConfigurationListeners() {

Review comment:
       I think a better comment is required. That this method treats all old 
values as nulls and exists for node start routine exclusively.

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/internal/configuration/notifications/ConfigurationNotifier.java
##########
@@ -70,19 +74,23 @@
             DynamicConfiguration<InnerNode, ?> config,
             long storageRevision
     ) {
-        if (oldInnerNode == null || oldInnerNode == newInnerNode) {
+        if (oldInnerNode != null && oldInnerNode == newInnerNode) {

Review comment:
       First part of condition is excessive. `newInnerNode` can't be null

##########
File path: 
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
##########
@@ -352,14 +351,6 @@ private void onTableCreateInternal(@NotNull 
ConfigurationNotificationEvent<Table
                         return CompletableFuture.allOf(futures);
                     }
 
-                    @Override
-                    public @NotNull CompletableFuture<?> onRename(@NotNull 
String oldName, @NotNull String newName,
-                            @NotNull ConfigurationNotificationEvent<TableView> 
ctx) {
-                        // TODO: IGNITE-15485 Support table rename operation.

Review comment:
       This code had very important TODO, you should return it back




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