ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ag...@apache.org
Subject ignite git commit: IGNITE-7951 Add metrics for remains to evict keys/partitions
Date Mon, 04 Jun 2018 17:42:13 GMT
Repository: ignite
Updated Branches:
  refs/heads/master d473b507f -> ee4df59e3


IGNITE-7951 Add metrics for remains to evict keys/partitions

Signed-off-by: Andrey Gura <agura@apache.org>


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

Branch: refs/heads/master
Commit: ee4df59e30e2189ba694f0a72914abb874f1f922
Parents: d473b50
Author: Aleksey Plekhanov <plehanov.alex@gmail.com>
Authored: Mon Jun 4 20:38:33 2018 +0300
Committer: Andrey Gura <agura@apache.org>
Committed: Mon Jun 4 20:38:33 2018 +0300

----------------------------------------------------------------------
 .../cache/CacheGroupMetricsMXBeanImpl.java      | 37 ++++++++++++++-
 .../ignite/mxbean/CacheGroupMetricsMXBean.java  | 16 +++++++
 .../cache/CacheGroupMetricsMBeanTest.java       | 49 +++++++++++++++++++-
 3 files changed, 99 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ee4df59e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMXBeanImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMXBeanImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMXBeanImpl.java
index e9a2736..a537e3d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMXBeanImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMXBeanImpl.java
@@ -229,14 +229,47 @@ public class CacheGroupMetricsMXBeanImpl implements CacheGroupMetricsMXBean
{
         return cnt;
     }
 
+    /**
+     * Count of partitions with a given state on the local node.
+     *
+     * @param state State.
+     */
+    private int localNodePartitionsCountByState(GridDhtPartitionState state) {
+        int cnt = 0;
+
+        for (GridDhtLocalPartition part : ctx.topology().localPartitions()) {
+            if (part.state() == state)
+                cnt++;
+        }
+
+        return cnt;
+    }
+
     /** {@inheritDoc} */
     @Override public int getLocalNodeOwningPartitionsCount() {
-        return nodePartitionsCountByState(ctx.shared().localNodeId(), GridDhtPartitionState.OWNING);
+        return localNodePartitionsCountByState(GridDhtPartitionState.OWNING);
     }
 
     /** {@inheritDoc} */
     @Override public int getLocalNodeMovingPartitionsCount() {
-        return nodePartitionsCountByState(ctx.shared().localNodeId(), GridDhtPartitionState.MOVING);
+        return localNodePartitionsCountByState(GridDhtPartitionState.MOVING);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getLocalNodeRentingPartitionsCount() {
+        return localNodePartitionsCountByState(GridDhtPartitionState.RENTING);
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getLocalNodeRentingEntriesCount() {
+        long entriesCnt = 0;
+
+        for (GridDhtLocalPartition part : ctx.topology().localPartitions()) {
+            if (part.state() == GridDhtPartitionState.RENTING)
+                entriesCnt += part.dataStore().fullSize();
+        }
+
+        return entriesCnt;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee4df59e/modules/core/src/main/java/org/apache/ignite/mxbean/CacheGroupMetricsMXBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/mxbean/CacheGroupMetricsMXBean.java
b/modules/core/src/main/java/org/apache/ignite/mxbean/CacheGroupMetricsMXBean.java
index 9973d84..2612a41 100644
--- a/modules/core/src/main/java/org/apache/ignite/mxbean/CacheGroupMetricsMXBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/mxbean/CacheGroupMetricsMXBean.java
@@ -100,6 +100,22 @@ public interface CacheGroupMetricsMXBean {
     public int getLocalNodeMovingPartitionsCount();
 
     /**
+     * Gets count of partitions with state RENTING for this cache group located on this node.
+     *
+     * @return Partitions count.
+     */
+    @MXBeanDescription("Count of partitions with state RENTING for this cache group located
on this node.")
+    public int getLocalNodeRentingPartitionsCount();
+
+    /**
+     * Gets count of entries remains to evict in RENTING partitions located on this node
for this cache group.
+     *
+     * @return Entries count.
+     */
+    @MXBeanDescription("Count of entries remains to evict in RENTING partitions located on
this node for this cache group.")
+    public long getLocalNodeRentingEntriesCount();
+
+    /**
      * Gets count of partitions with state OWNING for this cache group in the entire cluster.
      *
      * @return Partitions count.

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee4df59e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMBeanTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMBeanTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMBeanTest.java
index 26a504b..04ed008 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMBeanTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMBeanTest.java
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerInvocationHandler;
 import javax.management.MalformedObjectNameException;
@@ -37,9 +38,14 @@ import org.apache.ignite.cache.affinity.AffinityFunctionContext;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.events.EventType;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.mxbean.CacheGroupMetricsMXBean;
+import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 /**
@@ -258,7 +264,48 @@ public class CacheGroupMetricsMBeanTest extends GridCommonAbstractTest
implement
         // Check moving partitions while rebalancing.
         assertFalse(arrayToAllocationMap(new int[10][]).equals(mxBean0Grp1.getMovingPartitionsAllocationMap()));
 
-        assertTrue(mxBean0Grp1.getLocalNodeMovingPartitionsCount() > 0);
+        int movingCnt = mxBean0Grp1.getLocalNodeMovingPartitionsCount();
+
+        assertTrue(movingCnt > 0);
         assertTrue(mxBean0Grp1.getClusterMovingPartitionsCount() > 0);
+
+        final CountDownLatch evictLatch = new CountDownLatch(1);
+
+        // Block all evicting threads to count total renting partitions.
+        grid(0).events().localListen(new IgnitePredicate<Event>() {
+            @Override public boolean apply(Event evt) {
+                try {
+                    evictLatch.await();
+                }
+                catch (InterruptedException e) {
+                    log.error("Interrupted", e);
+                }
+
+                return true;
+            }
+        }, EventType.EVT_CACHE_REBALANCE_OBJECT_UNLOADED);
+
+        grid(0).rebalanceEnabled(true);
+        grid(1).rebalanceEnabled(true);
+
+        startGrid(2);
+
+        try {
+            assertTrue("Renting partitions count when node returns not equals to moved partitions
when node left",
+                GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                    @Override public boolean apply() {
+                        log.info("Renting partitions count: " + mxBean0Grp1.getLocalNodeRentingPartitionsCount());
+                        log.info("Renting entries count: " + mxBean0Grp1.getLocalNodeRentingEntriesCount());
+
+                        return mxBean0Grp1.getLocalNodeRentingPartitionsCount() == movingCnt;
+                    }
+                }, 10_000L)
+            );
+
+            assertTrue("Renting entries count is 0", mxBean0Grp1.getLocalNodeRentingEntriesCount()
> 0);
+        }
+        finally {
+            evictLatch.countDown();
+        }
     }
 }


Mime
View raw message