Repository: ignite
Updated Branches:
  refs/heads/ignite-3443 71433a503 -> 7de38e733


IGNITE-3443 WIP.


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

Branch: refs/heads/ignite-3443
Commit: 7de38e73379a872780925cb4faee7829e01b818b
Parents: 71433a5
Author: Alexey Kuznetsov <akuznet...@apache.org>
Authored: Fri Aug 26 18:27:40 2016 +0700
Committer: Alexey Kuznetsov <akuznet...@apache.org>
Committed: Fri Aug 26 18:27:40 2016 +0700

----------------------------------------------------------------------
 .../cache/query/GridCacheQueryAdapter.java      |  8 +-
 .../query/GridCacheQueryBaseMetricsAdapter.java |  2 +-
 .../visor/cache/VisorCacheQueryBaseMetrics.java | 99 ++++++++++++++++++++
 .../cache/VisorCacheQueryDetailsMetrics.java    | 62 +++---------
 .../visor/cache/VisorCacheQueryMetrics.java     | 66 +++----------
 .../visor/cache/VisorCacheQueryMetricsV2.java   | 45 ---------
 6 files changed, 132 insertions(+), 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7de38e73/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
index 6183c2b..6897f35 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
@@ -156,7 +156,9 @@ public class GridCacheQueryAdapter<T> implements 
CacheQuery<T> {
 
         log = cctx.logger(getClass());
 
-        metrics = new GridCacheQueryMetricsAdapter(5); // TODO: IGNITE-3443 
take from cfg.;
+        int histSize = cctx.config().getQueryMetricsHistorySize();
+
+        metrics = new GridCacheQueryMetricsAdapter(histSize);
     }
 
     /**
@@ -424,7 +426,9 @@ public class GridCacheQueryAdapter<T> implements 
CacheQuery<T> {
 
     /** {@inheritDoc} */
     @Override public void resetMetrics() {
-        metrics = new GridCacheQueryMetricsAdapter(5); // TODO: IGNITE-3443 
take from cfg.
+        int histSize = cctx.config().getQueryMetricsHistorySize();
+
+        metrics = new GridCacheQueryMetricsAdapter(histSize);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/7de38e73/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryBaseMetricsAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryBaseMetricsAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryBaseMetricsAdapter.java
index e75b43c..672ef19 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryBaseMetricsAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryBaseMetricsAdapter.java
@@ -84,7 +84,7 @@ public abstract class GridCacheQueryBaseMetricsAdapter 
implements Externalizable
         if (avgTime > 0)
             return avgTime;
         else {
-            long val = completed.sum();
+            double val = completed.sum();
 
             return val > 0 ? sumTime.sum() / val : 0;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7de38e73/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryBaseMetrics.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryBaseMetrics.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryBaseMetrics.java
new file mode 100644
index 0000000..d4ef43d
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryBaseMetrics.java
@@ -0,0 +1,99 @@
+/*
+ * 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 java.io.Serializable;
+import org.apache.ignite.internal.LessNamingBean;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Base class for data transfer object with cache query metrics.
+ */
+public abstract class VisorCacheQueryBaseMetrics implements Serializable, 
LessNamingBean {
+    /** Minimum execution time of query. */
+    private long minTime;
+
+    /** Maximum execution time of query. */
+    private long maxTime;
+
+    /** Average execution time of query. */
+    private double avgTime;
+
+    /** Number of executions. */
+    private int execs;
+
+    /** Number of executions failed. */
+    private int fails;
+
+    /**
+     * Initialize metrics.
+     *
+     * @param minTime Minimum execution time of query.
+     * @param maxTime Maximum execution time of query.
+     * @param avgTime Average execution time of query.
+     * @param execs Number of executions.
+     * @param fails Number of executions failed.
+     */
+    protected void init(long minTime, long maxTime, double avgTime, int execs, 
int fails) {
+        this.minTime = minTime;
+        this.maxTime = maxTime;
+        this.avgTime = avgTime;
+        this.execs = execs;
+        this.fails = fails;
+    }
+
+    /**
+     * @return Minimum execution time of query.
+     */
+    public long minimumTime() {
+        return minTime;
+    }
+
+    /**
+     * @return Maximum execution time of query.
+     */
+    public long maximumTime() {
+        return maxTime;
+    }
+
+    /**
+     * @return Average execution time of query.
+     */
+    public double averageTime() {
+        return avgTime;
+    }
+
+    /**
+     * @return Number of executions.
+     */
+    public int executions() {
+        return execs;
+    }
+
+    /**
+     * @return Total number of times a query execution failed.
+     */
+    public int fails() {
+        return fails;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(VisorCacheQueryBaseMetrics.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7de38e73/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryDetailsMetrics.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryDetailsMetrics.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryDetailsMetrics.java
index 7fcbc24..ef8eeb8 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryDetailsMetrics.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryDetailsMetrics.java
@@ -17,17 +17,14 @@
 
 package org.apache.ignite.internal.visor.cache;
 
-import java.io.Serializable;
 import org.apache.ignite.cache.query.QueryDetailsMetrics;
-import org.apache.ignite.cache.query.QueryMetrics;
-import org.apache.ignite.internal.LessNamingBean;
 import org.apache.ignite.internal.processors.cache.query.CacheQueryType;
 import org.apache.ignite.internal.util.typedef.internal.S;
 
 /**
  * Data transfer object for cache query metrics.
  */
-public class VisorCacheQueryDetailsMetrics implements Serializable, 
LessNamingBean {
+public class VisorCacheQueryDetailsMetrics extends VisorCacheQueryBaseMetrics {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -37,68 +34,31 @@ public class VisorCacheQueryDetailsMetrics implements 
Serializable, LessNamingBe
     /** Textual representation of query. */
     private String qry;
 
-    /** Minimum execution time of query. */
-    private long minTime;
-
-    /** Maximum execution time of query. */
-    private long maxTime;
-
-    /** Average execution time of query. */
-    private double avgTime;
-
-    /** Number of executions. */
-    private int execs;
-
-    /** Total number of times a query execution failed. */
-    private int fails;
-
     /**
      * @param m Cache query metrics.
      * @return Data transfer object for given cache metrics.
      */
     public VisorCacheQueryDetailsMetrics from(QueryDetailsMetrics m) {
-        this.minTime = m.minimumTime();
-        this.maxTime = m.maximumTime();
-        this.avgTime = m.averageTime();
-        this.execs = m.executions();
-        this.fails = m.fails();
-
-        return this;
-    }
-
-    /**
-     * @return Minimum execution time of query.
-     */
-    public long minimumTime() {
-        return minTime;
-    }
+        init(m.minimumTime(), m.maximumTime(), m.averageTime(), 
m.executions(), m.fails());
 
-    /**
-     * @return Maximum execution time of query.
-     */
-    public long maximumTime() {
-        return maxTime;
-    }
+        qryType = m.queryType();
+        qry = m.query();
 
-    /**
-     * @return Average execution time of query.
-     */
-    public double averageTime() {
-        return avgTime;
+        return this;
     }
 
     /**
-     * @return Number of executions.
+     * @return Query type.
      */
-    public int executions() {
-        return execs;
+    public CacheQueryType queryType() {
+        return qryType;
     }
 
     /**
-     * @return Total number of times a query execution failed.
+     * @return Textual representation of query.
      */
-    public int fails() {
-        return fails;
+    public String query() {
+        return qry;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/7de38e73/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryMetrics.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryMetrics.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryMetrics.java
index 0635f31..a7e1deb 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryMetrics.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryMetrics.java
@@ -17,80 +17,44 @@
 
 package org.apache.ignite.internal.visor.cache;
 
-import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.cache.query.QueryDetailsMetrics;
 import org.apache.ignite.cache.query.QueryMetrics;
-import org.apache.ignite.internal.LessNamingBean;
 import org.apache.ignite.internal.util.typedef.internal.S;
 
 /**
  * Data transfer object for cache query metrics.
  */
-public class VisorCacheQueryMetrics implements Serializable, LessNamingBean {
+public class VisorCacheQueryMetrics extends VisorCacheQueryBaseMetrics {
     /** */
     private static final long serialVersionUID = 0L;
 
-    /** Minimum execution time of query. */
-    private long minTime;
-
-    /** Maximum execution time of query. */
-    private long maxTime;
-
-    /** Average execution time of query. */
-    private double avgTime;
-
-    /** Number of executions. */
-    private int execs;
-
-    /** Total number of times a query execution failed. */
-    private int fails;
+    /** List of query metrics aggregated by query type and textual 
representation. */
+    private List<VisorCacheQueryDetailsMetrics> details;
 
     /**
      * @param m Cache query metrics.
      * @return Data transfer object for given cache metrics.
      */
     public VisorCacheQueryMetrics from(QueryMetrics m) {
-        this.minTime = m.minimumTime();
-        this.maxTime = m.maximumTime();
-        this.avgTime = m.averageTime();
-        this.execs = m.executions();
-        this.fails = m.fails();
+        init(m.minimumTime(), m.maximumTime(), m.averageTime(), 
m.executions(), m.fails());
 
-        return this;
-    }
+        List<QueryDetailsMetrics> mds = m.details();
 
-    /**
-     * @return Minimum execution time of query.
-     */
-    public long minimumTime() {
-        return minTime;
-    }
+        details = new ArrayList<>(mds.size());
 
-    /**
-     * @return Maximum execution time of query.
-     */
-    public long maximumTime() {
-        return maxTime;
-    }
+        for (QueryDetailsMetrics md : mds)
+            details.add(new VisorCacheQueryDetailsMetrics().from(md));
 
-    /**
-     * @return Average execution time of query.
-     */
-    public double averageTime() {
-        return avgTime;
-    }
-
-    /**
-     * @return Number of executions.
-     */
-    public int executions() {
-        return execs;
+        return this;
     }
 
     /**
-     * @return Total number of times a query execution failed.
+     * @return List of query metrics aggregated by query type and textual 
representation.
      */
-    public int fails() {
-        return fails;
+    public List<VisorCacheQueryDetailsMetrics> details() {
+        return details;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/7de38e73/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryMetricsV2.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryMetricsV2.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryMetricsV2.java
deleted file mode 100644
index a08a52f..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryMetricsV2.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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 java.io.Serializable;
-import org.apache.ignite.cache.query.QueryMetrics;
-import org.apache.ignite.internal.LessNamingBean;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Data transfer object for cache query metrics.
- */
-public class VisorCacheQueryMetricsV2 extends VisorCacheQueryMetrics {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** {@inheritDoc} */
-    @Override public VisorCacheQueryMetrics from(QueryMetrics m) {
-        VisorCacheQueryMetrics vm = super.from(m);
-
-        // TODO IGNITE-3443 implement.
-
-        return vm;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(VisorCacheQueryMetricsV2.class, this);
-    }
-}

Reply via email to