alex-plekhanov commented on code in PR #10649:
URL: https://github.com/apache/ignite/pull/10649#discussion_r1166607397


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyRequest.java:
##########
@@ -38,6 +45,39 @@ public abstract class ClientCacheKeyRequest extends 
ClientCacheDataRequest imple
         key = reader.readObjectDetached();
     }
 
+    /** {@inheritDoc} */
+    @Override public final ClientResponse process(ClientConnectionContext ctx) 
{
+        if (!isTransactional()) {
+            // Calculate affinity metrics.
+            DynamicCacheDescriptor desc = cacheDescriptor(ctx);
+            CacheConfiguration<?, ?> cfg = desc.cacheConfiguration();
+
+            if (cfg.getCacheMode() == CacheMode.PARTITIONED && 
cfg.isStatisticsEnabled()) {
+                String cacheName = desc.cacheName();
+
+                try {
+                    GridKernalContext kctx = ctx.kernalContext();
+
+                    if 
(F.first(kctx.affinity().mapKeyToPrimaryAndBackups(cacheName, key, 
null)).isLocal())
+                        kctx.clientListener().metrics().onAffinityKeyHit();
+                    else
+                        kctx.clientListener().metrics().onAffinityKeyMiss();
+                }
+                catch (Exception ignored) {
+                    // No-op.
+                }
+            }
+        }
+
+        // Process request in overriden method.
+        return process0(ctx);
+    }
+
+    /** */
+    protected ClientResponse process0(ClientConnectionContext ctx) {
+        return super.process(ctx);

Review Comment:
   This logic was inherited from the previous implementation (common response 
was created by `super.process()` method), and such approach is used by some 
other requests. But I can change it and create response explicitly, there are 
only two usages of `super.process0` method now. 



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