ivandasch commented on code in PR #10187:
URL: https://github.com/apache/ignite/pull/10187#discussion_r943653595


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java:
##########
@@ -221,11 +222,21 @@ boolean onCustomEvent(CacheAffinityChangeMessage msg) {
             return false;
         }
 
+        boolean isClient = cctx.discovery().localNode().isClient();
+
+        if (cctx.kernalContext().config().getDiscoverySpi() instanceof 
TcpDiscoverySpi)
+            isClient &= 
!((TcpDiscoverySpi)cctx.kernalContext().config().getDiscoverySpi()).isForceServerMode();
+
         // Skip message if affinity was already recalculated.
-        boolean exchangeNeeded = lastAffVer == null || 
lastAffVer.equals(msg.topologyVersion());
+        // Client node should just accept the flag from the mutated message.
+        boolean exchangeNeeded = (isClient) ? msg.exchangeNeeded() :

Review Comment:
   Is there any need of parenthesis for `isClient`? May be convert this two 
lines to one?



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java:
##########
@@ -221,11 +222,21 @@ boolean onCustomEvent(CacheAffinityChangeMessage msg) {
             return false;
         }
 
+        boolean isClient = cctx.discovery().localNode().isClient();
+
+        if (cctx.kernalContext().config().getDiscoverySpi() instanceof 
TcpDiscoverySpi)
+            isClient &= 
!((TcpDiscoverySpi)cctx.kernalContext().config().getDiscoverySpi()).isForceServerMode();

Review Comment:
   Just a cosmetic change -- may be define local variable `TcpDiscoverySpi`
   Currently it is quite hard to read the code, too many casts



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java:
##########
@@ -221,11 +222,21 @@ boolean onCustomEvent(CacheAffinityChangeMessage msg) {
             return false;
         }
 
+        boolean isClient = cctx.discovery().localNode().isClient();
+
+        if (cctx.kernalContext().config().getDiscoverySpi() instanceof 
TcpDiscoverySpi)
+            isClient &= 
!((TcpDiscoverySpi)cctx.kernalContext().config().getDiscoverySpi()).isForceServerMode();
+
         // Skip message if affinity was already recalculated.
-        boolean exchangeNeeded = lastAffVer == null || 
lastAffVer.equals(msg.topologyVersion());
+        // Client node should just accept the flag from the mutated message.
+        boolean exchangeNeeded = (isClient) ? msg.exchangeNeeded() :
+            lastAffVer == null || lastAffVer.equals(msg.topologyVersion());
 
         msg.exchangeNeeded(exchangeNeeded);
 
+        if (!cctx.discovery().mutableCustomMessages() && !isClient)
+            msg.stopProcess(true);

Review Comment:
   So if node is not a client and is coordinator (leader), then it will create 
an ackMessage with a changed value of the flag. Ok, it seems that I understand 
it



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