ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject ignite git commit: IGNITE-6985 Wrong value of RebalancingStartTime cache metric
Date Thu, 23 Nov 2017 13:54:20 GMT
Repository: ignite
Updated Branches:
  refs/heads/master ed1ff82a9 -> 5a4c6e097


IGNITE-6985 Wrong value of RebalancingStartTime cache metric

Signed-off-by: Anton Vinogradov <av@apache.org>


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

Branch: refs/heads/master
Commit: 5a4c6e097726be9feb994f95d42ecff45339d7f3
Parents: ed1ff82
Author: Aleksey Plekhanov <Plehanov.Alex@gmail.com>
Authored: Thu Nov 23 16:54:01 2017 +0300
Committer: Anton Vinogradov <av@apache.org>
Committed: Thu Nov 23 16:54:01 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheMetricsImpl.java      |  2 +-
 .../cache/CacheGroupsMetricsRebalanceTest.java  | 44 +++++++++++++++++++-
 2 files changed, 44 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5a4c6e09/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
index c98d51f..4e6b279 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
@@ -803,7 +803,7 @@ public class CacheMetricsImpl implements CacheMetrics {
      *
      */
     public void startRebalance(long delay){
-        rebalanceStartTime.addAndGet(delay + U.currentTimeMillis());
+        rebalanceStartTime.set(delay + U.currentTimeMillis());
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/5a4c6e09/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
index eb7c3a8..89c8236 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
@@ -57,6 +57,12 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest
{
     private static final String CACHE2 = "cache2";
 
     /** */
+    private static final String CACHE3 = "cache3";
+
+    /** */
+    private static final long REBALANCE_DELAY = 5_000;
+
+    /** */
     private static final String GROUP = "group1";
 
     /** {@inheritDoc} */
@@ -90,7 +96,16 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest
{
         CacheConfiguration cfg2 = new CacheConfiguration(cfg1)
             .setName(CACHE2);
 
-        cfg.setCacheConfiguration(cfg1, cfg2);
+        CacheConfiguration cfg3 = new CacheConfiguration()
+            .setName(CACHE3)
+            .setCacheMode(CacheMode.PARTITIONED)
+            .setAtomicityMode(CacheAtomicityMode.ATOMIC)
+            .setRebalanceMode(CacheRebalanceMode.ASYNC)
+            .setRebalanceBatchSize(100)
+            .setStatisticsEnabled(true)
+            .setRebalanceDelay(REBALANCE_DELAY);
+
+        cfg.setCacheConfiguration(cfg1, cfg2, cfg3);
 
         return cfg;
     }
@@ -199,6 +214,7 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest
{
 
         assertTrue(startTime > 0);
         assertTrue((U.currentTimeMillis() - startTime) < 5000);
+        assertTrue((U.currentTimeMillis() - startTime) > 0);
 
         final CountDownLatch latch = new CountDownLatch(1);
 
@@ -260,4 +276,30 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest
{
 
         assertTrue("Expected less 5000, Actual:" + diff, Math.abs(diff) < 10_000);
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRebalanceDelay() throws Exception {
+        Ignite ig1 = startGrid(1);
+
+        final IgniteCache<Object, Object> cache = ig1.cache(CACHE3);
+
+        for (int i = 0; i < 10000; i++)
+            cache.put(i, CACHE3 + "-" + i);
+
+        long beforeStartTime = U.currentTimeMillis();
+
+        startGrid(2);
+        startGrid(3);
+
+        waitForCondition(new PA() {
+            @Override public boolean apply() {
+                return cache.localMetrics().getRebalancingStartTime() != -1L;
+            }
+        }, 5_000);
+
+        assert(cache.localMetrics().getRebalancingStartTime() < U.currentTimeMillis()
+ REBALANCE_DELAY);
+        assert(cache.localMetrics().getRebalancingStartTime() > beforeStartTime + REBALANCE_DELAY);
+    }
 }


Mime
View raw message