nizhikov commented on code in PR #11616:
URL: https://github.com/apache/ignite/pull/11616#discussion_r1816389862


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/configuration/distributed/DistributedConfigurationProcessor.java:
##########
@@ -94,12 +98,64 @@ public DistributedConfigurationProcessor(GridKernalContext 
ctx) {
                 //Switch to cluster wide update action and do it on already 
registered properties.
                 switchCurrentActionTo(CLUSTER_WIDE_UPDATE);
 
-                isp.getDistributedConfigurationListeners()
-                    
.forEach(DistributedConfigurationLifecycleListener::onReadyToWrite);
+                IgniteInternalFuture<Void> initFut = 
initDefaultPropertiesValues();
+
+                // Notify registered listeners only after propagation of 
default values.
+                // Can't wait for initFut in the current thread, since it can 
block discovery and deadlock is possible.
+                initFut.listen(fut -> 
isp.getDistributedConfigurationListeners()
+                    
.forEach(DistributedConfigurationLifecycleListener::onReadyToWrite));
             }
         });
     }
 
+    /** Init default values for distributed properties. */
+    private IgniteInternalFuture<Void> initDefaultPropertiesValues() {
+        Map<String, ?> dfltVals = 
ctx.config().getDistributedPropertiesDefaultValues();
+
+        if (F.isEmpty(dfltVals))
+            return new GridFinishedFuture<>();
+
+        GridCompoundFuture<Void, Void> compFut = new GridCompoundFuture<>() {
+            @Override protected boolean ignoreFailure(Throwable err) {
+                // Do not complete the entire compound future if any property 
failed.
+                return true;
+            }
+        };
+
+        for (Map.Entry<String, ?> entry : dfltVals.entrySet()) {
+            DistributedChangeableProperty<Serializable> prop = 
props.get(entry.getKey());
+
+            if (prop == null) {
+                log.warning("Cannot set default value for distributed property 
'" + entry.getKey() +
+                    "', property is not registered");
+
+                continue;
+            }
+
+            if (prop.get() != null)

Review Comment:
   Let's add som debug logging here to provide ablility to overcome any issues:
   
   ```
   if (prop.get() != null) {
       log.debug("Skip set default value for porperty[name=" + entry.getKey() + 
", clusterValue=" + prop.get() + ", configValue=" + entry.getValue() + ']');
   }



-- 
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-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to