ignite-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ignite] nizhikov commented on a change in pull request #6627: IGNITE-11925: QueryMetrics migration.
Date Fri, 12 Jul 2019 11:10:12 GMT
nizhikov commented on a change in pull request #6627: IGNITE-11925: QueryMetrics migration.
URL: https://github.com/apache/ignite/pull/6627#discussion_r302936862
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryMetricsAdapter.java
 ##########
 @@ -126,41 +125,106 @@ public void update(long duration, boolean fail) {
      *
      * @return Copy.
      */
-    public GridCacheQueryMetricsAdapter copy() {
-        GridCacheQueryMetricsAdapter m = new GridCacheQueryMetricsAdapter();
-
-        // Not synchronized because accuracy isn't critical.
-        m.fails.add(fails.sum());
-        m.minTime.set(minTime.get());
-        m.maxTime.set(maxTime.get());
-        m.execs.add(execs.sum());
-        m.completed.add(completed.sum());
-        m.sumTime.add(sumTime.sum());
-        m.avgTime = avgTime;
-
-        return m;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeLong(minTime.get());
-        out.writeLong(maxTime.get());
-        out.writeDouble(averageTime());
-        out.writeInt(execs.intValue());
-        out.writeInt(fails.intValue());
+    public QueryMetrics snapshot() {
+        long minTimeVal = minTime.longValue();
+
+        return new QueryMetricsSnapshot(
+            minTimeVal == Long.MAX_VALUE ? 0 : minTimeVal,
+            maxTime.longValue(),
+            averageTime(),
+            (int)execs.longValue(),
+            (int)fails.longValue());
     }
 
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
-        minTime.set(in.readLong());
-        maxTime.set(in.readLong());
-        avgTime = in.readDouble();
-        execs.add(in.readInt());
-        fails.add(in.readInt());
+    /** Resets query metrics. */
+    public void reset() {
+        minTime.value(Long.MAX_VALUE);
+        maxTime.reset();
+        sumTime.reset();
+        execs.reset();
+        completed.reset();
+        fails.reset();
     }
 
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridCacheQueryMetricsAdapter.class, this);
     }
+
+    /** Query metrics snapshot. */
+    public static class QueryMetricsSnapshot implements QueryMetrics, Externalizable {
 
 Review comment:
   I don't want to make it private for the case if some third-party tools want to aggregate
`QueryMetrics`(and creates own instance of `QueryMetricsSnapshot`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message