You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by yz...@apache.org on 2015/05/29 17:42:27 UTC

[3/3] incubator-ignite git commit: # regenerated PDF

# regenerated PDF


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

Branch: refs/heads/ignite-sprint-5
Commit: 5c30f9cf5c490b0d6c065e89557a8b8f3040eda5
Parents: 6cd1a6e 3f012b7
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Fri May 29 18:42:16 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Fri May 29 18:42:16 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cache/CacheMetrics.java   | 187 +++++++--
 .../internal/managers/GridManagerAdapter.java   |  59 +--
 .../processors/cache/CacheMetricsImpl.java      | 305 +++++++++++++-
 .../cache/CacheMetricsMXBeanImpl.java           | 100 +++++
 .../processors/cache/CacheMetricsSnapshot.java  | 380 +++++++++++++----
 .../processors/cache/GridCacheSwapManager.java  | 118 ++++--
 .../ignite/mxbean/CacheMetricsMXBean.java       |  80 ++++
 .../org/apache/ignite/spi/IgniteSpiAdapter.java |  35 +-
 .../org/apache/ignite/spi/IgniteSpiContext.java |  47 ---
 .../spi/swapspace/file/FileSwapSpaceSpi.java    |   8 +-
 ...CacheLocalOffHeapAndSwapMetricsSelfTest.java | 412 +++++++++++++++++++
 .../testframework/GridSpiTestContext.java       |  25 +-
 .../IgniteCacheMetricsSelfTestSuite.java        |   1 +
 13 files changed, 1457 insertions(+), 300 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5c30f9cf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
index af19077,3dcda3c..4e6a447
--- 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
@@@ -129,24 -161,162 +164,168 @@@ public class CacheMetricsImpl implement
      }
  
      /** {@inheritDoc} */
+     @Override public long getOffHeapGets() {
+         return offHeapGets.get();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getOffHeapPuts() {
+         return offHeapPuts.get();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getOffHeapRemovals() {
+         return offHeapRemoves.get();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getOffHeapEvictions() {
+         return offHeapEvicts.get();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getOffHeapHits() {
+         return offHeapHits.get();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public float getOffHeapHitPercentage() {
+         long hits0 = offHeapHits.get();
+         long gets0 = offHeapGets.get();
+ 
+         if (hits0 == 0)
+             return 0;
+ 
+         return (float) hits0 / gets0 * 100.0f;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getOffHeapMisses() {
+         return offHeapMisses.get();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public float getOffHeapMissPercentage() {
+         long misses0 = offHeapMisses.get();
+         long reads0 = offHeapGets.get();
+ 
+         if (misses0 == 0)
+             return 0;
+ 
+         return (float) misses0 / reads0 * 100.0f;
+     }
+ 
+     /** {@inheritDoc} */
      @Override public long getOffHeapEntriesCount() {
 -        return cctx.cache().offHeapEntriesCount();
 +        GridCacheAdapter<?, ?> cache = cctx.cache();
 +
 +        return cache != null ? cache.offHeapEntriesCount() : -1;
      }
  
      /** {@inheritDoc} */
+     @Override public long getOffHeapPrimaryEntriesCount() {
+         try {
+             return cctx.swap().offheapEntriesCount(true, false, NONE);
+         }
+         catch (IgniteCheckedException e) {
+             return 0;
+         }
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getOffHeapBackupEntriesCount() {
+         try {
+             return cctx.swap().offheapEntriesCount(false, true, NONE);
+         }
+         catch (IgniteCheckedException e) {
+             return 0;
+         }
+     }
+ 
+     /** {@inheritDoc} */
      @Override public long getOffHeapAllocatedSize() {
 -        return cctx.cache().offHeapAllocatedSize();
 +        GridCacheAdapter<?, ?> cache = cctx.cache();
 +
 +        return cache != null ? cache.offHeapAllocatedSize() : -1;
      }
  
      /** {@inheritDoc} */
+     @Override public long getOffHeapMaxSize() {
+         return cctx.config().getOffHeapMaxMemory();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getSwapGets() {
+         return swapGets.get();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getSwapPuts() {
+         return swapPuts.get();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getSwapRemovals() {
+         return swapRemoves.get();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getSwapHits() {
+         return swapHits.get();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getSwapMisses() {
+         return swapMisses.get();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getSwapEntriesCount() {
+         try {
+             return cctx.cache().swapKeys();
+         }
+         catch (IgniteCheckedException e) {
+             return 0;
+         }
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public long getSwapSize() {
+         try {
+             return cctx.cache().swapSize();
+         }
+         catch (IgniteCheckedException e) {
+             return 0;
+         }
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public float getSwapHitPercentage() {
+         long hits0 = swapHits.get();
+         long gets0 = swapGets.get();
+ 
+         if (hits0 == 0)
+             return 0;
+ 
+         return (float) hits0 / gets0 * 100.0f;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public float getSwapMissPercentage() {
+         long misses0 = swapMisses.get();
+         long reads0 = swapGets.get();
+ 
+         if (misses0 == 0)
+             return 0;
+ 
+         return (float) misses0 / reads0 * 100.0f;
+     }
+ 
+     /** {@inheritDoc} */
      @Override public int getSize() {
 -        return cctx.cache().size();
 +        GridCacheAdapter<?, ?> cache = cctx.cache();
 +
 +        return cache != null ? cache.size() : 0;
      }
  
      /** {@inheritDoc} */
@@@ -606,11 -769,111 +797,113 @@@
  
      /** {@inheritDoc} */
      @Override public boolean isManagementEnabled() {
 -        return cctx.config().isManagementEnabled();
 +        CacheConfiguration ccfg = cctx.config();
 +
 +        return ccfg != null && ccfg.isManagementEnabled();
      }
  
+     /**
+      * Off-heap read callback.
+      *
+      * @param hit Hit or miss flag.
+      */
+     public void onOffHeapRead(boolean hit) {
+         offHeapGets.incrementAndGet();
+ 
+         if (hit)
+             offHeapHits.incrementAndGet();
+         else
+             offHeapMisses.incrementAndGet();
+ 
+         if (delegate != null)
+             delegate.onOffHeapRead(hit);
+     }
+ 
+     /**
+      * Off-heap write callback.
+      */
+     public void onOffHeapWrite() {
+         offHeapPuts.incrementAndGet();
+ 
+         if (delegate != null)
+             delegate.onOffHeapWrite();
+     }
+ 
+     /**
+      * Off-heap remove callback.
+      */
+     public void onOffHeapRemove() {
+         offHeapRemoves.incrementAndGet();
+ 
+         if (delegate != null)
+             delegate.onOffHeapRemove();
+     }
+ 
+     /**
+      * Off-heap evict callback.
+      */
+     public void onOffHeapEvict() {
+         offHeapEvicts.incrementAndGet();
+ 
+         if (delegate != null)
+             delegate.onOffHeapRemove();
+     }
+ 
+     /**
+      * Swap read callback.
+      *
+      * @param hit Hit or miss flag.
+      */
+     public void onSwapRead(boolean hit) {
+         swapGets.incrementAndGet();
+ 
+         if (hit)
+             swapHits.incrementAndGet();
+         else
+             swapMisses.incrementAndGet();
+ 
+         if (delegate != null)
+             delegate.onSwapRead(hit);
+     }
+ 
+     /**
+      * Swap write callback.
+      */
+     public void onSwapWrite() {
+         onSwapWrite(1);
+     }
+ 
+     /**
+      * Swap write callback.
+      *
+      * @param cnt Amount of entries.
+      */
+     public void onSwapWrite(int cnt) {
+         swapPuts.addAndGet(cnt);
+ 
+         if (delegate != null)
+             delegate.onSwapWrite(cnt);
+     }
+ 
+     /**
+      * Swap remove callback.
+      */
+     public void onSwapRemove() {
+         onSwapRemove(1);
+     }
+ 
+     /**
+      * Swap remove callback.
+      *
+      * @param cnt Amount of entries.
+      */
+     public void onSwapRemove(int cnt) {
+         swapRemoves.addAndGet(cnt);
+ 
+         if (delegate != null)
+             delegate.onSwapRemove(cnt);
+     }
+ 
      /** {@inheritDoc} */
      @Override public String toString() {
          return S.toString(CacheMetricsImpl.class, this);