ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: IGNITE-352 Added check on statisticsEnabled. Added tests.
Date Thu, 26 Feb 2015 08:38:28 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-352 [created] 7e5de11f7


IGNITE-352 Added check on statisticsEnabled. Added tests.


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

Branch: refs/heads/ignite-352
Commit: 7e5de11f77c711553b446238125f2d5dad51c6fd
Parents: e09b037
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Thu Feb 26 11:38:30 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Thu Feb 26 11:38:30 2015 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridDhtAtomicCache.java          |  2 +-
 .../dht/colocated/GridDhtColocatedCache.java    |  2 +-
 .../cache/transactions/IgniteTxManager.java     |  3 +-
 .../cache/GridCacheAbstractMetricsSelfTest.java | 42 ++++++++++++++++++++
 4 files changed, 46 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7e5de11f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 9f9af31..add51bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -990,7 +990,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
 
                 if (!success)
                     break;
-                else if (!skipVals)
+                else if (!skipVals && ctx.config().isStatisticsEnabled())
                     metrics0().onRead(true);
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7e5de11f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index a59b6aa..cdb1759 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -318,7 +318,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
 
                 if (!success)
                     break;
-                else if (!skipVals)
+                else if (!skipVals && ctx.config().isStatisticsEnabled())
                     ctx.cache().metrics0().onRead(true);
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7e5de11f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index cf32dcc..ae1df62 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -1316,7 +1316,8 @@ public class IgniteTxManager<K, V> extends GridCacheSharedManagerAdapter<K,
V> {
                 for (int cacheId : tx.activeCacheIds()) {
                     GridCacheContext<K, V> cacheCtx = cctx.cacheContext(cacheId);
 
-                    cacheCtx.cache().metrics0().onTxRollback(System.nanoTime() - tx.startTime());
+                    if (cacheCtx.cache().configuration().isStatisticsEnabled())
+                        cacheCtx.cache().metrics0().onTxRollback(System.nanoTime() - tx.startTime());
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7e5de11f/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 d1c5e12..69bb6d2 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
@@ -103,6 +103,48 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
     /**
      * @throws Exception If failed.
      */
+    public void testGetMetricsDisable() throws Exception {
+        // Disable statistics.
+        for (int i = 0; i < gridCount(); i++) {
+            Ignite g = grid(i);
+
+            g.jcache(null).getConfiguration(CacheConfiguration.class).setStatisticsEnabled(false);
+        }
+
+        IgniteCache<Object, Object> jcache = grid(0).jcache(null);
+
+        // Write to cache.
+        for (int i = 0; i < KEY_CNT; i++) 
+            jcache.put(i, i);
+
+        // Get from cache.
+        for (int i = 0; i < KEY_CNT; i++)
+            jcache.get(i);
+
+        // Remove from cache.
+        for (int i = 0; i < KEY_CNT; i++)
+            jcache.remove(i);
+
+        // Assert that statistics is clear.
+        for (int i = 0; i < gridCount(); i++) {
+            CacheMetrics m = grid(i).jcache(null).metrics();
+
+            assertEquals(m.getCacheGets(), 0);
+            assertEquals(m.getCachePuts(), 0);
+            assertEquals(m.getCacheRemovals(), 0);
+            assertEquals(m.getCacheHits(), 0);
+            assertEquals(m.getCacheMisses(), 0);
+            assertEquals(m.getAverageGetTime(), 0f);
+            assertEquals(m.getAverageRemoveTime(), 0f);
+            assertEquals(m.getAveragePutTime(), 0f);
+            assertEquals(m.getAverageTxCommitTime(), 0f);
+            assertEquals(m.getAverageTxRollbackTime(), 0f);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testGetMetricsSnapshot() throws Exception {
         IgniteCache<Object, Object> cache = grid(0).jcache(null);
 


Mime
View raw message