ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject incubator-ignite git commit: ignite-352 review
Date Mon, 02 Mar 2015 14:29:03 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/sprint-2 403d60fee -> b0e6ab17c


ignite-352 review


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

Branch: refs/heads/sprint-2
Commit: b0e6ab17c284850190012e7c120a95c34316b982
Parents: 403d60f
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Mon Mar 2 17:28:39 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Mon Mar 2 17:28:39 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheMetricsImpl.java      |  4 ++
 .../dht/atomic/GridDhtAtomicCache.java          |  2 +-
 .../dht/colocated/GridDhtColocatedCache.java    |  2 +-
 .../cache/transactions/IgniteTxManager.java     |  7 +++-
 .../cache/GridCacheAbstractMetricsSelfTest.java | 42 ++++++++++++++++++++
 5 files changed, 53 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b0e6ab17/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 0de039b..446070e 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
@@ -460,6 +460,8 @@ public class CacheMetricsImpl implements CacheMetrics {
 
     /**
      * Transaction commit callback.
+     *
+     * @param duration the time taken in nanoseconds.
      */
     public void onTxCommit(long duration) {
         txCommits.incrementAndGet();
@@ -472,6 +474,8 @@ public class CacheMetricsImpl implements CacheMetrics {
 
     /**
      * Transaction rollback callback.
+     *
+     * @param duration the time taken in nanoseconds.
      */
     public void onTxRollback(long duration) {
         txRollbacks.incrementAndGet();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b0e6ab17/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/b0e6ab17/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/b0e6ab17/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..af57ce4 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
@@ -1243,7 +1243,8 @@ public class IgniteTxManager<K, V> extends GridCacheSharedManagerAdapter<K,
V> {
                     GridCacheContext<K, V> cacheCtx = cctx.cacheContext(cacheId);
 
                     if (cacheCtx.cache().configuration().isStatisticsEnabled())
-                        cacheCtx.cache().metrics0().onTxCommit(System.nanoTime() - tx.startTime());
+                        // Convert start time from ms to ns.
+                        cacheCtx.cache().metrics0().onTxCommit((U.currentTimeMillis() - tx.startTime())
* 1000);
                 }
             }
 
@@ -1316,7 +1317,9 @@ 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())
+                        // Convert start time from ms to ns.
+                        cacheCtx.cache().metrics0().onTxRollback((U.currentTimeMillis() -
tx.startTime()) * 1000);
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b0e6ab17/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..a7fb34a 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