shishkovilja commented on code in PR #13661:
URL: https://github.com/apache/ignite/pull/13661#discussion_r4357226795


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProcessor.java:
##########
@@ -853,4 +910,36 @@ public class ClientProcessorMXBeanImpl implements 
ClientProcessorMXBean {
             }
         }
     }
+
+    /** Maximum value over the time interval, but not less than the current 
value. */
+    private static class PeakWithCurrentMetric extends MaxValueMetric {
+        /** Upper limit of the value. */
+        private final long limit;
+
+        /** Current value supplier. */
+        private final LongSupplier cur;
+
+        /**
+         * @param name Name.
+         * @param desc Description.
+         * @param timeInterval Time interval in milliseconds.
+         * @param size Number of buckets.
+         * @param limit Upper limit of the value.
+         * @param cur Current value supplier.
+         */
+        PeakWithCurrentMetric(String name, String desc, long timeInterval, int 
size, long limit, LongSupplier cur) {
+            super(name, desc, timeInterval, size);
+
+            this.limit = limit;
+            this.cur = cur;
+        }
+
+        /** {@inheritDoc} */
+        @Override public long value() {
+            long peak = super.value();
+
+            // The current value can not exceed the limit, so there is no need 
to calculate it.
+            return peak >= limit ? peak : Math.max(peak, cur.getAsLong());

Review Comment:
   # Limit
   Limit is required currently because we should not re-calculate metric from 
sessions values:
   1. When limit is <=0 - in case when compute taks are disabled for thin 
client. In fact,  zero is the current value.
   2. When value is >= limit - in this case no new tasks will be executed. In 
fact, limit is the current value.
   
   # Current and zero
   > cur can be more than max only when metric is not updated more than time 
interval
   
   No, it can be such situation:
   1) Session 1 starts Task1, Task2
   2) Interval was exceeded
   3) Task1, Task2 are still running, but metric is zero.
   4) Session 2 starts Task2
   5) Metric value will be updated to 1 -> not zero, so `value()` will return 
incorrect value.
   ---
   However, I'll try to reduce re-calculations.



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