You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by as...@apache.org on 2020/09/24 07:20:52 UTC

[ignite] branch master updated: IGNITE-13458 Added RebalancingPartitionsTotal metric. - Fixes #8254.

This is an automated email from the ASF dual-hosted git repository.

ascherbakov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new eabe50d  IGNITE-13458 Added RebalancingPartitionsTotal metric. - Fixes #8254.
eabe50d is described below

commit eabe50d90d5db2d363da36393cd957ff54a18d90
Author: mstepachev <ma...@gmail.com>
AuthorDate: Thu Sep 24 10:15:46 2020 +0300

    IGNITE-13458 Added RebalancingPartitionsTotal metric. - Fixes #8254.
    
    Signed-off-by: Alexey Scherbakov <al...@gmail.com>
---
 .../distributed/dht/preloader/GridDhtPartitionDemander.java  | 11 ++++++++++-
 .../processors/cache/CacheGroupsMetricsRebalanceTest.java    | 12 ++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 624ee06..bae41ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -164,6 +164,10 @@ public class GridDhtPartitionDemander {
         mreg.register("RebalancingPartitionsLeft", () -> rebalanceFut.partitionsLeft.get(),
             "The number of cache group partitions left to be rebalanced.");
 
+        mreg.register("RebalancingPartitionsTotal",
+            () -> rebalanceFut.partitionsTotal,
+            "The total number of cache group partitions to be rebalanced.");
+
         mreg.register("RebalancingReceivedKeys", () -> rebalanceFut.receivedKeys.get(),
             "The number of currently rebalanced keys for the whole cache group.");
 
@@ -1139,6 +1143,9 @@ public class GridDhtPartitionDemander {
         /** The number of cache group partitions left to be rebalanced. */
         private final AtomicLong partitionsLeft = new AtomicLong(0);
 
+        /** The number of cache group partitions total to be rebalanced. */
+        private final int partitionsTotal;
+
         /** Rebalancing start time. */
         private volatile long startTime = -1;
 
@@ -1192,7 +1199,7 @@ public class GridDhtPartitionDemander {
         ) {
             assert assignments != null : "Asiignments must not be null.";
 
-            this.rebalancingParts = U.newHashMap(assignments.size());
+            rebalancingParts = U.newHashMap(assignments.size());
             this.assignments = assignments;
             exchId = assignments.exchangeId();
             topVer = assignments.topologyVersion();
@@ -1229,6 +1236,7 @@ public class GridDhtPartitionDemander {
 
             this.routines = remaining.size();
 
+            partitionsTotal = rebalancingParts.values().stream().mapToInt(Set::size).sum();
             this.grp = grp;
             this.log = log;
             this.rebalanceId = rebalanceId;
@@ -1243,6 +1251,7 @@ public class GridDhtPartitionDemander {
          */
         RebalanceFuture() {
             this.rebalancingParts = null;
+            this.partitionsTotal = 0;
             this.assignments = null;
             this.exchId = null;
             this.topVer = null;
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 66e6ae2..43a873c 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
@@ -60,6 +60,7 @@ import org.apache.ignite.internal.visor.node.VisorNodeDataCollectorTaskResult;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.metric.IntMetric;
 import org.apache.ignite.spi.metric.LongMetric;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -270,6 +271,7 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
         LongMetric lastCancelledTime = mreg.findMetric("RebalancingLastCancelledTime");
         LongMetric endTime = mreg.findMetric("RebalancingEndTime");
         LongMetric partitionsLeft = mreg.findMetric("RebalancingPartitionsLeft");
+        IntMetric partitionsTotal = mreg.findMetric("RebalancingPartitionsTotal");
         LongMetric receivedKeys = mreg.findMetric("RebalancingReceivedKeys");
         LongMetric receivedBytes = mreg.findMetric("RebalancingReceivedBytes");
 
@@ -281,6 +283,9 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
         assertEquals("During the start of the rebalancing, the number of partitions in the metric should be " +
                 "equal to the number of partitions in the cache group.", DFLT_PARTITION_COUNT, partitionsLeft.value());
 
+        assertEquals("The total number of partitions in the metric should be " +
+                "equal to the number of partitions in the cache group.", DFLT_PARTITION_COUNT, partitionsTotal.value());
+
         long rebalancingStartTime = startTime.value();
 
         assertNotSame("During rebalancing start, the start time metric must be determined.",
@@ -316,6 +321,9 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
         assertEquals("After completion of rebalancing, there are no partitions of the cache group that are" +
             " left to rebalance.", 0, partitionsLeft.value());
 
+        assertEquals("After completion of rebalancing, the total number of partitions in the metric should be" +
+            " equal to the number of partitions in the cache group.", DFLT_PARTITION_COUNT, partitionsTotal.value());
+
         assertEquals("After the rebalancing is ended, the rebalancing start time must be equal to the start time " +
                 "measured immediately after the rebalancing start.", rebalancingStartTime, startTime.value());
 
@@ -381,10 +389,14 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
         LongMetric lastCancelledTime = mreg.findMetric("RebalancingLastCancelledTime");
         LongMetric endTime = mreg.findMetric("RebalancingEndTime");
         LongMetric partitionsLeft = mreg.findMetric("RebalancingPartitionsLeft");
+        IntMetric partitionsTotal = mreg.findMetric("RebalancingPartitionsTotal");
 
         assertEquals("During the start of the rebalancing, the number of partitions in the metric should be " +
             "equal to the number of partitions in the cache group.", DFLT_PARTITION_COUNT, partitionsLeft.value());
 
+        assertEquals("The total number of partitions in the metric should be " +
+            "equal to the number of partitions in the cache group.", DFLT_PARTITION_COUNT, partitionsTotal.value());
+
         long rebalancingStartTime = startTime.value();
 
         assertNotSame("During rebalancing start, the start time metric must be determined.",