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-1071 IgniteCache.metrics() method returns local metrics
Date Fri, 25 Mar 2016 09:07:16 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1071 aa669cd30 -> 20ae3a21f


IGNITE-1071 IgniteCache.metrics() method returns local metrics


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

Branch: refs/heads/ignite-1071
Commit: 20ae3a21fe8a88000954c032748513f7ea8a8df7
Parents: aa669cd
Author: Anton Vinogradov <av@apache.org>
Authored: Fri Mar 25 12:07:01 2016 +0300
Committer: Anton Vinogradov <av@apache.org>
Committed: Fri Mar 25 12:07:01 2016 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteCache.java     | 20 ++++++++++++---
 .../processors/cache/IgniteCacheProxy.java      | 26 ++++++++++++++++++++
 .../cache/GridCacheAbstractMetricsSelfTest.java | 12 ++++-----
 ...cheTransactionalAbstractMetricsSelfTest.java |  2 +-
 .../multijvm/IgniteCacheProcessProxy.java       |  8 ++++++
 5 files changed, 58 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/20ae3a21/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index a791e38..581f091 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -715,14 +715,14 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K,
V>, IgniteAsyncS
     public IgniteFuture<?> rebalance();
 
     /**
-     * Gets snapshot metrics (statistics) for this cache.
+     * Gets whole cluster snapshot metrics (statistics) for this cache.
      *
      * @return Cache metrics.
      */
     public CacheMetrics metrics();
 
     /**
-     * Gets snapshot metrics for caches in cluster group.
+     * Gets cluster group snapshot metrics for caches in cluster group.
      *
      * @param grp Cluster group.
      * @return Cache metrics.
@@ -730,9 +730,23 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K,
V>, IgniteAsyncS
     public CacheMetrics metrics(ClusterGroup grp);
 
     /**
-     * Gets MxBean for this cache.
+     * Gets local snapshot metrics (statistics) for this cache.
+     *
+     * @return Cache metrics.
+     */
+    public CacheMetrics localMetrics();
+
+    /**
+     * Gets whole cluster MxBean for this cache.
      *
      * @return MxBean.
      */
     public CacheMetricsMXBean mxBean();
+
+    /**
+     * Gets local MxBean for this cache.
+     *
+     * @return MxBean.
+     */
+    public CacheMetricsMXBean localMxBean();
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/20ae3a21/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index d617d26..9cfa1c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -243,6 +243,19 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K,
V
         }
     }
 
+    @Override public CacheMetrics localMetrics() {
+        GridCacheGateway<K, V> gate = this.gate;
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return ctx.cache().localMetrics();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
     /** {@inheritDoc} */
     @Override public CacheMetricsMXBean mxBean() {
         GridCacheGateway<K, V> gate = this.gate;
@@ -257,6 +270,19 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K,
V
         }
     }
 
+    @Override public CacheMetricsMXBean localMxBean() {
+        GridCacheGateway<K, V> gate = this.gate;
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return ctx.cache().localMxBean();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
     /** {@inheritDoc} */
     @Override public <C extends Configuration<K, V>> C getConfiguration(Class<C>
clazz) {
         CacheConfiguration cfg = ctx.config();

http://git-wip-us.apache.org/repos/asf/ignite/blob/20ae3a21/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java
index 02f9322..00086a4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java
@@ -113,7 +113,7 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
         for (int i = 0; i < gridCount(); i++) {
             Ignite g = grid(i);
 
-            ((IgniteCacheProxy)g.cache(null)).context().cache().metrics0().clear();
+            g.cache(null).localMxBean().clear();
 
             g.transactions().resetMetrics();
         }
@@ -570,12 +570,12 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
             expReads += expectedReadsPerPut(isPrimary);
             expMisses += expectedMissesPerPut(isPrimary);
 
-            info("Puts: " + ((IgniteCacheProxy)cache0).context().cache().metrics0().getCachePuts());
+            info("Puts: " + cache0.localMetrics().getCachePuts());
 
             for (int j = 0; j < gridCount(); j++) {
                 IgniteCache<Integer, Integer> cache = grid(j).cache(null);
 
-                int cacheWrites = (int)((IgniteCacheProxy)cache).context().cache().metrics0().getCachePuts();
+                int cacheWrites = (int)cache.localMetrics().getCachePuts();
 
                 assertEquals("Wrong cache metrics [i=" + i + ", grid=" + j + ']', i + 1,
cacheWrites);
             }
@@ -592,7 +592,7 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
         int misses = 0;
 
         for (int i = 0; i < gridCount(); i++) {
-            CacheMetrics m = ((IgniteCacheProxy)grid(i).cache(null)).context().cache().metrics0();
+            CacheMetrics m = grid(i).cache(null).localMetrics();
 
             puts += m.getCachePuts();
             reads += m.getCacheGets();
@@ -620,12 +620,12 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
         for (int i = 0; i < keyCnt; i++) {
             cache0.getAndPut(i, i); // +1 read
 
-            info("Puts: " + ((IgniteCacheProxy)cache0).context().cache().metrics0().getCachePuts());
+            info("Puts: " + cache0.localMetrics().getCachePuts());
 
             for (int j = 0; j < gridCount(); j++) {
                 IgniteCache<Integer, Integer> cache = grid(j).cache(null);
 
-                long cacheWrites = ((IgniteCacheProxy)cache).context().cache().metrics0().getCachePuts();
+                long cacheWrites = cache.localMetrics().getCachePuts();
 
                 assertEquals("Wrong cache metrics [i=" + i + ", grid=" + j + ']', i + 1,
cacheWrites);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/20ae3a21/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java
index 6d69103..929a45c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java
@@ -231,7 +231,7 @@ public abstract class GridCacheTransactionalAbstractMetricsSelfTest extends
Grid
 
         for (int i = 0; i < gridCount(); i++) {
             TransactionMetrics metrics = grid(i).transactions().metrics();
-            CacheMetrics cacheMetrics = ((IgniteCacheProxy)grid(i).cache(null)).context().cache().localMetrics();
+            CacheMetrics cacheMetrics = grid(i).cache(null).localMetrics();
 
             if (i == 0) {
                 assertEquals(TX_CNT, metrics.txCommits());

http://git-wip-us.apache.org/repos/asf/ignite/blob/20ae3a21/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 7286fb3..205dc83 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -439,11 +439,19 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K,
V> {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
+    @Override public CacheMetrics localMetrics() {
+        throw new UnsupportedOperationException("Method should be supported.");
+    }
+
     /** {@inheritDoc} */
     @Override public CacheMetricsMXBean mxBean() {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
+    @Override public CacheMetricsMXBean localMxBean() {
+        throw new UnsupportedOperationException("Method should be supported.");
+    }
+
     /** {@inheritDoc} */
     @Override public <K1, V1> IgniteCache<K1, V1> withKeepBinary() {
         throw new UnsupportedOperationException("Method should be supported.");


Mime
View raw message