ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [48/50] [abbrv] ignite git commit: IGNITE-5124 - Corrected metrics configuration - Fixes #2045.
Date Thu, 01 Jun 2017 13:24:03 GMT
IGNITE-5124 - Corrected metrics configuration - Fixes #2045.

Signed-off-by: Alexey Goncharuk <alexey.goncharuk@gmail.com>


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

Branch: refs/heads/ignite-5267
Commit: dc780268d750440769960c0e8882b483cc766d86
Parents: 98c05a2
Author: Sergey Chugunov <sergey.chugunov@gmail.com>
Authored: Thu Jun 1 13:10:30 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Thu Jun 1 13:10:30 2017 +0300

----------------------------------------------------------------------
 .../MemoryPolicyConfiguration.java              | 20 ++++++++++----------
 .../IgniteCacheDatabaseSharedManager.java       |  6 ++++++
 .../cache/database/MemoryMetricsImpl.java       | 20 +++++++++-----------
 .../cache/database/MemoryMetricsMXBeanImpl.java | 10 +++++++++-
 .../ignite/mxbean/MemoryMetricsMXBean.java      |  8 ++++----
 .../database/MemoryMetricsSelfTest.java         | 10 +++++-----
 6 files changed, 43 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dc780268/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
index be0877f..b496901 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
@@ -72,7 +72,7 @@ public final class MemoryPolicyConfiguration implements Serializable {
     public static final int DFLT_SUB_INTERVALS = 5;
 
     /** Default length of interval over which {@link MemoryMetrics#getAllocationRate()} metric
is calculated. */
-    public static final int DFLT_RATE_TIME_INTERVAL_SEC = 60;
+    public static final int DFLT_RATE_TIME_INTERVAL_MILLIS = 60_000;
 
     /** Memory policy name. */
     private String name = DFLT_MEM_PLC_DEFAULT_NAME;
@@ -103,7 +103,7 @@ public final class MemoryPolicyConfiguration implements Serializable {
      */
     private boolean metricsEnabled = DFLT_METRICS_ENABLED;
 
-    /** Number of sub-intervals the whole {@link #setRateTimeInterval(int)} will be split
into to calculate
+    /** Number of sub-intervals the whole {@link #setRateTimeInterval(long)} will be split
into to calculate
      * {@link MemoryMetrics#getAllocationRate()} and {@link MemoryMetrics#getEvictionRate()}
rates (5 by default).
      * <p>
      * Setting it to a bigger value will result in more precise calculation and smaller drops
of
@@ -112,13 +112,13 @@ public final class MemoryPolicyConfiguration implements Serializable
{
     private int subIntervals = DFLT_SUB_INTERVALS;
 
     /**
-     * Time interval for {@link MemoryMetrics#getAllocationRate()}
+     * Time interval (in milliseconds) for {@link MemoryMetrics#getAllocationRate()}
      * and {@link MemoryMetrics#getEvictionRate()} monitoring purposes.
      * <p>
-     * For instance, after setting the interval to 60 seconds, subsequent calls to {@link
MemoryMetrics#getAllocationRate()}
+     * For instance, after setting the interval to 60_000 milliseconds, subsequent calls
to {@link MemoryMetrics#getAllocationRate()}
      * will return average allocation rate (pages per second) for the last minute.
      */
-    private int rateTimeInterval = DFLT_RATE_TIME_INTERVAL_SEC;
+    private long rateTimeInterval = DFLT_RATE_TIME_INTERVAL_MILLIS;
 
     /**
      * Gets memory policy name.
@@ -315,13 +315,13 @@ public final class MemoryPolicyConfiguration implements Serializable
{
      * Gets time interval for {@link MemoryMetrics#getAllocationRate()}
      * and {@link MemoryMetrics#getEvictionRate()} monitoring purposes.
      * <p>
-     * For instance, after setting the interval to 60 seconds,
+     * For instance, after setting the interval to 60_000 milliseconds,
      * subsequent calls to {@link MemoryMetrics#getAllocationRate()}
      * will return average allocation rate (pages per second) for the last minute.
      *
      * @return Time interval over which allocation rate is calculated.
      */
-    public int getRateTimeInterval() {
+    public long getRateTimeInterval() {
         return rateTimeInterval;
     }
 
@@ -336,14 +336,14 @@ public final class MemoryPolicyConfiguration implements Serializable
{
      * @param rateTimeInterval Time interval used for allocation and eviction rates calculations.
      * @return {@code this} for chaining.
      */
-    public MemoryPolicyConfiguration setRateTimeInterval(int rateTimeInterval) {
+    public MemoryPolicyConfiguration setRateTimeInterval(long rateTimeInterval) {
         this.rateTimeInterval = rateTimeInterval;
 
         return this;
     }
 
     /**
-     * Gets a number of sub-intervals the whole {@link #setRateTimeInterval(int)}
+     * Gets a number of sub-intervals the whole {@link #setRateTimeInterval(long)}
      * will be split into to calculate {@link MemoryMetrics#getAllocationRate()}
      * and {@link MemoryMetrics#getEvictionRate()} rates (5 by default).
      * <p>
@@ -358,7 +358,7 @@ public final class MemoryPolicyConfiguration implements Serializable {
     }
 
     /**
-     * Sets a number of sub-intervals the whole {@link #setRateTimeInterval(int)} will be
split into to calculate
+     * Sets a number of sub-intervals the whole {@link #setRateTimeInterval(long)} will be
split into to calculate
      * {@link MemoryMetrics#getAllocationRate()} and {@link MemoryMetrics#getEvictionRate()}
rates (5 by default).
      * <p>
      * Setting it to a bigger value will result in more precise calculation and smaller drops
of

http://git-wip-us.apache.org/repos/asf/ignite/blob/dc780268/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
index e356f35..11c9b56 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
@@ -370,6 +370,12 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
                 "[name=" + plcCfg.getName() +
                 ", subIntervals=" + plcCfg.getSubIntervals() + "]"
             );
+
+        if (plcCfg.getRateTimeInterval() < 1_000)
+            throw new IgniteCheckedException("Rate time interval must be longer that 1 second
(1_000 milliseconds) " +
+                "(use MemoryPolicyConfiguration.rateTimeInterval property to adjust the interval)
" +
+                "[name=" + plcCfg.getName() +
+                ", rateTimeInterval=" + plcCfg.getRateTimeInterval() + "]");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/dc780268/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsImpl.java
index 3e3b690..2bd96e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsImpl.java
@@ -58,8 +58,8 @@ public class MemoryMetricsImpl implements MemoryMetrics {
     /** */
     private final MemoryPolicyConfiguration memPlcCfg;
 
-    /** Time interval (in seconds) when allocations/evictions are counted to calculate rate.
*/
-    private volatile int rateTimeInterval;
+    /** Time interval (in milliseconds) when allocations/evictions are counted to calculate
rate. */
+    private volatile long rateTimeInterval;
 
     /**
      * @param memPlcCfg MemoryPolicyConfiguration.
@@ -99,7 +99,7 @@ public class MemoryMetricsImpl implements MemoryMetrics {
         for (int i = 0; i < subInts; i++)
             res += allocRateCounters[i].floatValue();
 
-        return res / rateTimeInterval;
+        return res * 1000 / rateTimeInterval;
     }
 
     /** {@inheritDoc} */
@@ -200,8 +200,8 @@ public class MemoryMetricsImpl implements MemoryMetrics {
     /**
      * @param intervalNum Interval number.
      */
-    private int subInt(int intervalNum) {
-        return (rateTimeInterval * 1000 * intervalNum) / subInts;
+    private long subInt(int intervalNum) {
+        return (rateTimeInterval * intervalNum) / subInts;
     }
 
     /**
@@ -277,9 +277,9 @@ public class MemoryMetricsImpl implements MemoryMetrics {
     }
 
     /**
-     * @param rateTimeInterval Time interval used to calculate allocation/eviction rate.
+     * @param rateTimeInterval Time interval (in milliseconds) used to calculate allocation/eviction
rate.
      */
-    public void rateTimeInterval(int rateTimeInterval) {
+    public void rateTimeInterval(long rateTimeInterval) {
         this.rateTimeInterval = rateTimeInterval;
     }
 
@@ -294,10 +294,8 @@ public class MemoryMetricsImpl implements MemoryMetrics {
         if (this.subInts == subInts)
             return;
 
-        int rateIntervalMs = rateTimeInterval * 1000;
-
-        if (rateIntervalMs / subInts < 10)
-            subInts = rateIntervalMs / 10;
+        if (rateTimeInterval / subInts < 10)
+            subInts = (int) rateTimeInterval / 10;
 
         LongAdder8[] newCounters = new LongAdder8[subInts];
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/dc780268/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsMXBeanImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsMXBeanImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsMXBeanImpl.java
index 05c6677..d3ae378 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsMXBeanImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsMXBeanImpl.java
@@ -67,12 +67,20 @@ class MemoryMetricsMXBeanImpl implements MemoryMetricsMXBean {
     }
 
     /** {@inheritDoc} */
-    @Override public void rateTimeInterval(int rateTimeInterval) {
+    @Override public void rateTimeInterval(long rateTimeInterval) {
+        if (rateTimeInterval < 1000)
+            throw new IllegalArgumentException("rateTimeInterval property must be positive
" +
+                "and greater than 1_000 milliseconds (one second)");
+
         memMetrics.rateTimeInterval(rateTimeInterval);
     }
 
     /** {@inheritDoc} */
     @Override public void subIntervals(int subInts) {
+        if (subInts <= 1)
+            throw new IllegalArgumentException("subIntervals property must be positive "
+
+                "and greater than one");
+
         memMetrics.subIntervals(subInts);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/dc780268/modules/core/src/main/java/org/apache/ignite/mxbean/MemoryMetricsMXBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/mxbean/MemoryMetricsMXBean.java
b/modules/core/src/main/java/org/apache/ignite/mxbean/MemoryMetricsMXBean.java
index b371d2a..d0900f6 100644
--- a/modules/core/src/main/java/org/apache/ignite/mxbean/MemoryMetricsMXBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/mxbean/MemoryMetricsMXBean.java
@@ -91,7 +91,7 @@ public interface MemoryMetricsMXBean extends MemoryMetrics {
      * For instance, after setting the interval to 60 seconds, subsequent calls to {@link
#getAllocationRate()}
      * will return average allocation rate (pages per second) for the last minute.
      *
-     * @param rateTimeInterval Time interval used for allocation and eviction rates calculations.
+     * @param rateTimeInterval Time interval (in milliseconds) used for allocation and eviction
rates calculations.
      */
     @MXBeanDescription(
         "Sets time interval for pages allocation and eviction monitoring purposes."
@@ -100,12 +100,12 @@ public interface MemoryMetricsMXBean extends MemoryMetrics {
         "rateTimeInterval"
     )
     @MXBeanParametersDescriptions(
-        "Time interval (in seconds) to set."
+        "Time interval (in milliseconds) to set."
     )
-    public void rateTimeInterval(int rateTimeInterval);
+    public void rateTimeInterval(long rateTimeInterval);
 
     /**
-     * Sets a number of sub-intervals the whole {@link #rateTimeInterval(int)} will be split
into to calculate
+     * Sets a number of sub-intervals the whole {@link #rateTimeInterval(long)} will be split
into to calculate
      * {@link #getAllocationRate()} and {@link #getEvictionRate()} rates (5 by default).
      * <p>
      * Setting it to a bigger value will result in more precise calculation and smaller drops
of

http://git-wip-us.apache.org/repos/asf/ignite/blob/dc780268/modules/core/src/test/java/org/apache/ignite/internal/processors/database/MemoryMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/MemoryMetricsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/MemoryMetricsSelfTest.java
index cb5700f..706e717 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/MemoryMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/MemoryMetricsSelfTest.java
@@ -55,7 +55,7 @@ public class MemoryMetricsSelfTest extends GridCommonAbstractTest {
      */
     public void testAllocationRateSingleThreaded() throws Exception {
         threadsCnt = 1;
-        memMetrics.rateTimeInterval(10);
+        memMetrics.rateTimeInterval(10_000);
 
         CountDownLatch startLatch = new CountDownLatch(1);
 
@@ -75,7 +75,7 @@ public class MemoryMetricsSelfTest extends GridCommonAbstractTest {
      */
     public void testAllocationRateMultiThreaded() throws Exception {
         threadsCnt = 4;
-        memMetrics.rateTimeInterval(5);
+        memMetrics.rateTimeInterval(5_000);
 
         CountDownLatch startLatch = new CountDownLatch(1);
 
@@ -110,7 +110,7 @@ public class MemoryMetricsSelfTest extends GridCommonAbstractTest {
      */
     public void testAllocationRateTimeIntervalConcurrentChange() throws Exception {
         threadsCnt = 5;
-        memMetrics.rateTimeInterval(5);
+        memMetrics.rateTimeInterval(5_000);
 
         CountDownLatch startLatch = new CountDownLatch(1);
 
@@ -123,7 +123,7 @@ public class MemoryMetricsSelfTest extends GridCommonAbstractTest {
         for (int i = 0; i < 10; i++) {
             Thread.sleep(25);
 
-            memMetrics.rateTimeInterval((2 + i * 5) % 3 + 1);
+            memMetrics.rateTimeInterval(((2 + i * 5) % 3 + 1) * 1000);
         }
 
         joinAllThreads();
@@ -137,7 +137,7 @@ public class MemoryMetricsSelfTest extends GridCommonAbstractTest {
      */
     public void testAllocationRateSubintervalsConcurrentChange() throws Exception {
         threadsCnt = 5;
-        memMetrics.rateTimeInterval(5);
+        memMetrics.rateTimeInterval(5_000);
 
         CountDownLatch startLatch = new CountDownLatch(1);
 


Mime
View raw message