ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shro...@apache.org
Subject [18/50] [abbrv] ignite git commit: IGNITE-4007 Fixed update of QueryMetrics.minimumTime() metric. Tests added. Added Visor reset metrics task.
Date Mon, 07 Nov 2016 04:30:05 GMT
IGNITE-4007 Fixed update of QueryMetrics.minimumTime() metric.  Tests added. Added Visor reset
metrics task.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c32082fe
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c32082fe
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c32082fe

Branch: refs/heads/ignite-2788
Commit: c32082fe8b1e02758179c1b7bb61a75be53534fe
Parents: f447559
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Fri Sep 30 15:20:11 2016 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri Sep 30 15:20:11 2016 +0700

----------------------------------------------------------------------
 .../query/GridCacheQueryMetricsAdapter.java     | 12 ++--
 .../cache/VisorCacheResetQueryMetricsTask.java  | 69 ++++++++++++++++++++
 .../CacheAbstractQueryMetricsSelfTest.java      |  6 +-
 3 files changed, 80 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c32082fe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryMetricsAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryMetricsAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryMetricsAdapter.java
index 1928ea5..e70ea9f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryMetricsAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryMetricsAdapter.java
@@ -34,7 +34,7 @@ public class GridCacheQueryMetricsAdapter implements QueryMetrics, Externalizabl
     private static final long serialVersionUID = 0L;
 
     /** Minimum time of execution. */
-    private final GridAtomicLong minTime = new GridAtomicLong();
+    private final GridAtomicLong minTime = new GridAtomicLong(Long.MAX_VALUE);
 
     /** Maximum time of execution. */
     private final GridAtomicLong maxTime = new GridAtomicLong();
@@ -58,7 +58,9 @@ public class GridCacheQueryMetricsAdapter implements QueryMetrics, Externalizabl
 
     /** {@inheritDoc} */
     @Override public long minimumTime() {
-        return minTime.get();
+        long min = minTime.get();
+
+        return min == Long.MAX_VALUE ? 0 : min;
     }
 
     /** {@inheritDoc} */
@@ -71,9 +73,9 @@ public class GridCacheQueryMetricsAdapter implements QueryMetrics, Externalizabl
         if (avgTime > 0)
             return avgTime;
         else {
-            long val = completed.sum();
+            double val = completed.sum();
 
-            return val > 0 ? sumTime.sum() / val : 0;
+            return val > 0 ? sumTime.sum() / val : 0.0;
         }
     }
 
@@ -170,4 +172,4 @@ public class GridCacheQueryMetricsAdapter implements QueryMetrics, Externalizabl
     @Override public String toString() {
         return S.toString(GridCacheQueryMetricsAdapter.class, this);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c32082fe/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetQueryMetricsTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetQueryMetricsTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetQueryMetricsTask.java
new file mode 100644
index 0000000..96d9857
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetQueryMetricsTask.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.visor.cache;
+
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+
+/**
+ * Reset compute grid query metrics.
+ */
+@GridInternal
+public class VisorCacheResetQueryMetricsTask extends VisorOneNodeTask<String, Void>
{
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorCacheResetQueryMetricsJob job(String arg) {
+        return new VisorCacheResetQueryMetricsJob(arg, debug);
+    }
+
+    /**
+     * Job that reset cache query metrics.
+     */
+    private static class VisorCacheResetQueryMetricsJob extends VisorJob<String, Void>
{
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * @param arg Cache name to reset query metrics for.
+         * @param debug Debug flag.
+         */
+        private VisorCacheResetQueryMetricsJob(String arg, boolean debug) {
+            super(arg, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected Void run(String cacheName) {
+            IgniteInternalCache cache = ignite.cachex(cacheName);
+
+            if (cache != null)
+                cache.context().queries().resetMetrics();
+
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(VisorCacheResetQueryMetricsJob.class, this);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c32082fe/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
index d2d8c4d..10f7612 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
@@ -236,6 +236,7 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra
         assertTrue(m.averageTime() >= 0);
         assertTrue(m.maximumTime() >= 0);
         assertTrue(m.minimumTime() >= 0);
+        assertTrue("On first execution minTime == maxTime", m.minimumTime() == m.maximumTime());
 
         // Execute again with the same parameters.
         cache.query(qry).getAll();
@@ -274,6 +275,7 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra
         assertTrue(m.averageTime() >= 0);
         assertTrue(m.maximumTime() >= 0);
         assertTrue(m.minimumTime() >= 0);
+        assertTrue("On first execution minTime == maxTime", m.minimumTime() == m.maximumTime());
 
         // Execute again with the same parameters.
         cache.query(qry).iterator().next();
@@ -301,7 +303,7 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra
         try {
             cache.query(qry).getAll();
         }
-        catch (Exception e) {
+        catch (Exception ignored) {
             // No-op.
         }
 
@@ -320,7 +322,7 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra
         try {
             cache.query(qry).getAll();
         }
-        catch (Exception e) {
+        catch (Exception ignored) {
             // No-op.
         }
 


Mime
View raw message