ignite-notifications mailing list archives

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

 ##########
 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 think this class can be private. Isn't it?

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