You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "nizhikov (via GitHub)" <gi...@apache.org> on 2023/04/14 09:07:47 UTC

[GitHub] [ignite] nizhikov commented on a diff in pull request #10649: IGNITE-17345 Thin client: Add affinity hits/misses metric

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


##########
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:
   Do we really should call `super.process` here? Looks very suspicious and fragile for me.



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

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