jinggou commented on code in PR #1976:
URL: https://github.com/apache/phoenix/pull/1976#discussion_r1755363105


##########
phoenix-core-client/src/main/java/org/apache/phoenix/schema/PMetaDataCache.java:
##########
@@ -52,6 +53,16 @@ public void onRemoval(RemovalNotification<PTableKey, 
PTableRef> notification) {
                         String key = notification.getKey().toString();
                         LOGGER.debug("Expiring " + key + " because of "
                                 + notification.getCause().name());
+                        if (notification.wasEvicted()) {
+                            
GlobalClientMetrics.GLOBAL_CLIENT_METADATA_CACHE_EVICTION_COUNTER.increment();
+                        } else {
+                            
GlobalClientMetrics.GLOBAL_CLIENT_METADATA_CACHE_REMOVAL_COUNTER.increment();
+                        }
+                        if (notification.getValue() != null) {
+                            long newSize =
+                                    
GlobalClientMetrics.GLOBAL_CLIENT_METADATA_CACHE_ESTIMATED_USED_SIZE.getMetric().getValue()
 - notification.getValue().getEstimatedSize();
+                            
GlobalClientMetrics.GLOBAL_CLIENT_METADATA_CACHE_ESTIMATED_USED_SIZE.update(newSize);

Review Comment:
   There is no `increment(long value)` method here as server side, but seems 
this `update(long value)` method is adding the given value to the current 
value. So the calculation here is wrong and we need to change to 
   ```
   
GlobalClientMetrics.GLOBAL_CLIENT_METADATA_CACHE_ESTIMATED_USED_SIZE.update(-notification.getValue().getEstimatedSize());
   ```
   Is that okay?



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