ignite-973-2 - metrics 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/4902e8f6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4902e8f6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4902e8f6 Branch: refs/heads/ignite-950 Commit: 4902e8f657b02531afb72b097a85ffc951e61f9d Parents: 108788b Author: S.Vladykin <svlady...@gridgain.com> Authored: Wed Jun 24 18:41:38 2015 +0300 Committer: S.Vladykin <svlady...@gridgain.com> Committed: Wed Jun 24 18:41:38 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheSwapManager.java | 31 +++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4902e8f6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java index 7595a1d..9e9c958 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java @@ -584,14 +584,14 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter { ClassLoader ldr = cctx.deploy().globalLoader(); - GridCacheQueryManager qryMgr = cctx.queries(); + final GridCacheQueryManager qryMgr = cctx.queries(); if (qryMgr != null && !readSwapBeforeRemove(key, swapKey, ldr)) return null; // Not found. swapMgr.remove(spaceName, swapKey, new CI1<byte[]>() { @Override public void apply(byte[] rmv) { - if (cctx.config().isStatisticsEnabled()) + if (qryMgr == null && cctx.config().isStatisticsEnabled()) cctx.cache().metrics0().onSwapRead(rmv != null); if (rmv != null) { @@ -748,14 +748,14 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter { else { byte[] entryBytes = offheap.remove(spaceName, part, key, keyBytes); - if (entryBytes != null) { - if (cctx.config().isStatisticsEnabled()) - cctx.cache().metrics0().onOffHeapRemove(); + if (cctx.config().isStatisticsEnabled()) { + cctx.cache().metrics0().onOffHeapRead(entryBytes != null); - entry = swapEntry(unmarshalSwapEntry(entryBytes)); + if (entryBytes != null) + cctx.cache().metrics0().onOffHeapRemove(); } - else - entry = null; + + entry = entryBytes == null ? null : swapEntry(unmarshalSwapEntry(entryBytes)); } return entry; @@ -857,6 +857,9 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter { unprocessedKeys, new IgniteBiInClosure<SwapKey, byte[]>() { @Override public void apply(SwapKey swapKey, byte[] rmv) { + if (qryMgr == null && cctx.config().isStatisticsEnabled()) + cctx.cache().metrics0().onSwapRead(rmv != null); + if (rmv != null) { try { GridCacheSwapEntry entry = swapEntry(unmarshalSwapEntry(rmv)); @@ -974,10 +977,13 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter { throws IgniteCheckedException { assert cctx.queries() != null; - byte[] val = offheap.get(spaceName, part, key, keyBytes); + byte[] entryBytes = offheap.get(spaceName, part, key, keyBytes); + + if (cctx.config().isStatisticsEnabled()) + cctx.cache().metrics0().onOffHeapRead(entryBytes != null); - if (val != null) { - GridCacheSwapEntry entry = swapEntry(unmarshalSwapEntry(val)); + if (entryBytes != null) { + GridCacheSwapEntry entry = swapEntry(unmarshalSwapEntry(entryBytes)); if (entry != null) { cctx.queries().onUnswap(key, entry.value()); @@ -1004,6 +1010,9 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter { byte[] entryBytes = swapMgr.read(spaceName, swapKey, ldr); + if (cctx.config().isStatisticsEnabled()) + cctx.cache().metrics0().onSwapRead(entryBytes != null); + if (entryBytes == null) return false;