You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/05/14 10:46:46 UTC

[GitHub] [ignite] ololo3000 commented on a change in pull request #7771: IGNITE-12894 Adds ability to wait for the service topology initialization.

ololo3000 commented on a change in pull request #7771:
URL: https://github.com/apache/ignite/pull/7771#discussion_r425044202



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/service/IgniteServiceProcessor.java
##########
@@ -823,19 +823,26 @@ else if (prj.predicate() == F.<ClusterNode>alwaysTrue())
 
         long startTime = U.currentTimeMillis();
 
-        Map<UUID, Integer> top;
+        ServiceInfo desc;
 
         while (true) {
-            top = serviceTopology(name);
+             desc = lookupInRegisteredServices(name);

Review comment:
       I got it. If after [1] but before [2] service will be deleted and full message with requested service topology will be received, topology of the local ServiceDescriptor reference will never be updated. Is that what you mean? 
   
   ```
   while (true) {
       desc = lookupInRegisteredServices(name);
   
       if (timeout == 0 && desc == null) // [1]
           return null;
   
       synchronized (servicesTopsUpdateMux) { // [2]
           if (desc != null && desc.topologyInitialized())
               return desc.topologySnapshot();
   
           long wait = 0;
   
           if (timeout != 0) {
               wait = timeout - (U.currentTimeMillis() - startTime);
   
               if (wait <= 0)
                   return desc == null ? null : desc.topologySnapshot();
           }
   
           try {
               servicesTopsUpdateMux.wait(wait);
           }
           catch (InterruptedException e) {
               throw new IgniteInterruptedCheckedException(e);
           }
       }
   }
   ```
   
   It seems that it will be enough to only move 
   
   ```
   desc = lookupInRegisteredServices(name);
   
   if (timeout == 0 && desc == null) // [1]
       return null;
   ```
   
   inside the syncgronization block. 
   In that case if service is removed before synchronization block or full message is received no matter the order, we will retrurn on 
   
   ```
    if (timeout == 0 && desc == null) 
       return null;
   ```
   
   if service is removed during synchronization block execution, we anyway will receive the full message and stop waiting.




----------------------------------------------------------------
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:
users@infra.apache.org