ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/3] incubator-ignite git commit: IGNITE-49 Changed CacheMetrics and IgniteCacheMxBean API
Date Fri, 23 Jan 2015 13:08:20 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-49 4277989bb -> 8d338c0c5


IGNITE-49 Changed CacheMetrics and IgniteCacheMxBean API


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

Branch: refs/heads/ignite-49
Commit: 669f3a916f51d835bcfef849b3a4663a59919018
Parents: 4277989
Author: nikolay tikhonov <ntikhonov@gridgain.com>
Authored: Fri Jan 23 14:32:02 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Fri Jan 23 14:32:02 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/CacheMXBeanImpl.java |   4 +-
 .../java/org/apache/ignite/IgniteCache.java     |   7 +
 .../org/apache/ignite/IgniteCacheManager.java   |  20 +-
 .../processors/cache/IgniteCacheProxy.java      |  12 +
 .../org/gridgain/grid/cache/CacheMetrics.java   |   5 -
 .../java/org/gridgain/grid/cache/GridCache.java |   8 +
 .../processors/cache/CacheMetricsImpl.java      |  44 +--
 .../processors/cache/CacheMetricsSnapshot.java  | 215 ++++++++++++++
 .../processors/cache/CacheMxBeanAdapter.java    | 296 ------------------
 .../processors/cache/CacheMxBeanImpl.java       | 297 +++++++++++++++++++
 .../processors/cache/GridCacheAdapter.java      |  12 +-
 .../processors/cache/GridCacheProcessor.java    |  37 ---
 .../processors/cache/GridCacheProxyImpl.java    |  12 +
 .../visor/cache/VisorCacheResetMetricsTask.java |   2 +-
 .../cache/GridCacheAbstractMetricsSelfTest.java |  11 +-
 ...ePartitionedNearDisabledMetricsSelfTest.java |   2 +-
 .../near/GridCacheNearMetricsSelfTest.java      |   2 +-
 17 files changed, 592 insertions(+), 394 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/apache/ignite/CacheMXBeanImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/CacheMXBeanImpl.java b/modules/core/src/main/java/org/apache/ignite/CacheMXBeanImpl.java
index fe4f93d..626ea0f 100644
--- a/modules/core/src/main/java/org/apache/ignite/CacheMXBeanImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/CacheMXBeanImpl.java
@@ -25,14 +25,14 @@ import javax.cache.management.*;
  * Implementation of {@link CacheMXBean}.
  *
  */
-public class CacheMXBeanImpl implements CacheMXBean {
+public class CacheMxBeanImpl implements CacheMXBean {
     /** */
     private final Cache<?, ?> cache;
 
     /**
      * @param cache Cache.
      */
-    public CacheMXBeanImpl(Cache<?, ?> cache) {
+    public CacheMxBeanImpl(Cache<?, ?> cache) {
         this.cache = cache;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/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 db210c0..d71c96f 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -361,4 +361,11 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
      * @return Cache metrics.
      */
     public CacheMetrics metrics();
+
+    /**
+     * Gets MxBean for this cache.
+     *
+     * @return MxBean.
+     */
+    public IgniteCacheMxBean mxBean();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java b/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
index 7a52af8..21a390d 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
@@ -41,7 +41,7 @@ public class IgniteCacheManager implements CacheManager {
     private static final String CACHE_CONFIGURATION = "CacheConfiguration";
 
     /** */
-    private final Map<String, IgniteBiTuple<Ignite, CacheMXBeanImpl>> igniteMap = new HashMap<>();
+    private final Map<String, IgniteBiTuple<Ignite, CacheMxBeanImpl>> igniteMap = new HashMap<>();
 
     /** */
     private final URI uri;
@@ -147,7 +147,7 @@ public class IgniteCacheManager implements CacheManager {
 
             res = ignite.jcache(cacheName);
 
-            igniteMap.put(cacheName, new T2<>(ignite, new CacheMXBeanImpl(res)));
+            igniteMap.put(cacheName, new T2<>(ignite, new CacheMxBeanImpl(res)));
         }
 
         if (((CompleteConfiguration)cacheCfg).isManagementEnabled())
@@ -163,7 +163,7 @@ public class IgniteCacheManager implements CacheManager {
      * @param cacheName Cache name.
      */
     private <K, V> IgniteCache<K, V> findCache(String cacheName) {
-        IgniteBiTuple<Ignite, CacheMXBeanImpl> tuple;
+        IgniteBiTuple<Ignite, CacheMxBeanImpl> tuple;
 
         synchronized (igniteMap) {
             tuple = igniteMap.get(cacheName);
@@ -229,7 +229,7 @@ public class IgniteCacheManager implements CacheManager {
      */
     public boolean isManagedIgnite(Ignite ignite) {
         synchronized (igniteMap) {
-            for (IgniteBiTuple<Ignite, CacheMXBeanImpl> tuple : igniteMap.values()) {
+            for (IgniteBiTuple<Ignite, CacheMxBeanImpl> tuple : igniteMap.values()) {
                 if (ignite.equals(tuple.get1()))
                     return true;
             }
@@ -245,7 +245,7 @@ public class IgniteCacheManager implements CacheManager {
         if (cacheName == null)
             throw new NullPointerException();
 
-        IgniteBiTuple<Ignite, CacheMXBeanImpl> tuple;
+        IgniteBiTuple<Ignite, CacheMxBeanImpl> tuple;
 
         synchronized (igniteMap) {
             tuple = igniteMap.remove(cacheName);
@@ -290,7 +290,7 @@ public class IgniteCacheManager implements CacheManager {
         if (cacheName == null)
             throw new NullPointerException();
 
-        IgniteBiTuple<Ignite, CacheMXBeanImpl> tuple;
+        IgniteBiTuple<Ignite, CacheMxBeanImpl> tuple;
 
         synchronized (igniteMap) {
             tuple = igniteMap.get(cacheName);
@@ -318,7 +318,7 @@ public class IgniteCacheManager implements CacheManager {
         if (cacheName == null)
             throw new NullPointerException();
 
-        IgniteBiTuple<Ignite, CacheMXBeanImpl> tuple;
+        IgniteBiTuple<Ignite, CacheMxBeanImpl> tuple;
 
         synchronized (igniteMap) {
             tuple = igniteMap.get(cacheName);
@@ -333,7 +333,7 @@ public class IgniteCacheManager implements CacheManager {
         MBeanServer mBeanSrv = ignite.configuration().getMBeanServer();
 
         if (enabled) {
-            registerCacheObject(mBeanSrv, cache.metrics(), cacheName, CACHE_STATISTICS);
+            registerCacheObject(mBeanSrv, cache.mxBean(), cacheName, CACHE_STATISTICS);
 
             cfg.setStatisticsEnabled(true);
         }
@@ -403,13 +403,13 @@ public class IgniteCacheManager implements CacheManager {
     /** {@inheritDoc} */
     @Override public void close() {
         if (closed.compareAndSet(false, true)) {
-            IgniteBiTuple<Ignite, CacheMXBeanImpl>[] ignites;
+            IgniteBiTuple<Ignite, CacheMxBeanImpl>[] ignites;
 
             synchronized (igniteMap) {
                 ignites = igniteMap.values().toArray(new IgniteBiTuple[igniteMap.values().size()]);
             }
 
-            for (IgniteBiTuple<Ignite, CacheMXBeanImpl> tuple : ignites) {
+            for (IgniteBiTuple<Ignite, CacheMxBeanImpl> tuple : ignites) {
                 try {
                     tuple.get1().close();
                 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/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 c16e899..321d09b 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
@@ -101,6 +101,18 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
     }
 
     /** {@inheritDoc} */
+    @Override public IgniteCacheMxBean mxBean() {
+        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+        try {
+            return ctx.cache().mxBean();
+        }
+        finally {
+            gate.leave(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/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/gridgain/grid/cache/CacheMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/CacheMetrics.java b/modules/core/src/main/java/org/gridgain/grid/cache/CacheMetrics.java
index 1794897..1713b8f 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/CacheMetrics.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/CacheMetrics.java
@@ -25,11 +25,6 @@ import org.apache.ignite.*;
  */
 public interface CacheMetrics {
     /**
-     * Clears the statistics counters to 0 for the associated Cache.
-     */
-    void clear();
-
-    /**
      * The number of get requests that were satisfied by the cache.
      *
      * @return the number of hits

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java
index c3b093b..ceba8d8 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java
@@ -118,6 +118,14 @@ public interface GridCache<K, V> extends GridCacheProjection<K, V> {
      */
     public CacheMetrics metrics();
 
+
+    /**
+     * Gets metrics (statistics) for this cache.
+     *
+     * @return Cache metrics.
+     */
+    public IgniteCacheMxBean mxBean();
+
     /**
      * Gets size (in bytes) of all entries swapped to disk.
      *

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsImpl.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsImpl.java
index cb98ed7..bfff87b 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsImpl.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsImpl.java
@@ -27,7 +27,7 @@ import java.util.concurrent.atomic.*;
 /**
  * Adapter for cache metrics.
  */
-public class CacheMetricsImpl implements CacheMetrics, Externalizable {
+public class CacheMetricsImpl implements CacheMetrics {
     /** */
     private static final long NANOS_IN_MICROSECOND = 1000L;
 
@@ -123,8 +123,10 @@ public class CacheMetricsImpl implements CacheMetrics, Externalizable {
         return txRollbacks.get();
     }
 
-    /** {@inheritDoc} */
-    @Override public void clear() {
+    /**
+     * Clear metrics.
+     */
+    public void clear() {
         reads.set(0);
         writes.set(0);
         rmCnt.set(0);
@@ -362,42 +364,6 @@ public class CacheMetricsImpl implements CacheMetrics, Externalizable {
     }
 
     /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeLong(reads.get());
-        out.writeLong(writes.get());
-        out.writeLong(hits.get());
-        out.writeLong(misses.get());
-        out.writeLong(txCommits.get());
-        out.writeLong(txRollbacks.get());
-        out.writeLong(rmCnt.get());
-        out.writeLong(evictCnt.get());
-
-        out.writeLong(putTimeNanos.get());
-        out.writeLong(getTimeNanos.get());
-        out.writeLong(removeTimeNanos.get());
-        out.writeLong(commitTimeNanos.get());
-        out.writeLong(rollbackTimeNanos.get());
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        reads = new AtomicLong(in.readLong());
-        writes = new AtomicLong(in.readLong());
-        hits = new AtomicLong(in.readLong());
-        misses = new AtomicLong(in.readLong());
-        txCommits = new AtomicLong(in.readLong());
-        txRollbacks = new AtomicLong(in.readLong());
-        rmCnt = new AtomicLong(in.readLong());
-        evictCnt = new AtomicLong(in.readLong());
-
-        putTimeNanos = new AtomicLong(in.readLong());
-        getTimeNanos = new AtomicLong(in.readLong());
-        removeTimeNanos = new AtomicLong(in.readLong());
-        commitTimeNanos = new AtomicLong(in.readLong());
-        rollbackTimeNanos = new AtomicLong(in.readLong());
-    }
-
-    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(CacheMetricsImpl.class, this);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsSnapshot.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsSnapshot.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsSnapshot.java
new file mode 100644
index 0000000..3d8723d
--- /dev/null
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsSnapshot.java
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.gridgain.grid.kernal.processors.cache;
+
+import org.gridgain.grid.cache.*;
+import org.gridgain.grid.util.typedef.internal.*;
+
+import java.io.*;
+
+/**
+ * Metrics snapshot.
+ */
+class CacheMetricsSnapshot implements CacheMetrics, Externalizable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Number of reads. */
+    private long reads = 0;
+
+    /** Number of puts. */
+    private long puts = 0;
+
+    /** Number of hits. */
+    private long hits = 0;
+
+    /** Number of misses. */
+    private long misses = 0;
+
+    /** Number of transaction commits. */
+    private long txCommits = 0;
+
+    /** Number of transaction rollbacks. */
+    private long txRollbacks = 0;
+
+    /** Number of evictions. */
+    private long evicts = 0;
+
+    /** Number of removed entries. */
+    private long removes = 0;
+
+    /** Put time taken nanos. */
+    private float putAvgTimeNanos = 0;
+
+    /** Get time taken nanos. */
+    private float getAvgTimeNanos = 0;
+
+    /** Remove time taken nanos. */
+    private float removeAvgTimeNanos = 0;
+
+    /** Commit transaction time taken nanos. */
+    private float commitAvgTimeNanos = 0;
+
+    /** Commit transaction time taken nanos. */
+    private float rollbackAvgTimeNanos = 0;
+
+    /**
+     * Create snapshot for given metrics.
+     *
+     * @param m Cache metrics.
+     */
+    public CacheMetricsSnapshot(CacheMetrics m) {
+        reads = m.getCacheGets();
+        puts = m.getCachePuts();
+        hits = m.getCacheHits();
+        misses = m.getCacheMisses();
+        txCommits = m.getCacheTxCommits();
+        txRollbacks = m.getCacheTxRollbacks();
+        evicts = m.getCacheEvictions();
+        removes = m.getCacheRemovals();
+
+        putAvgTimeNanos = m.getAveragePutTime();
+        getAvgTimeNanos = m.getAverageGetTime();
+        removeAvgTimeNanos = m.getAverageRemoveTime();
+        commitAvgTimeNanos = m.getAverageTxCommitTime();
+        rollbackAvgTimeNanos = m.getAverageTxRollbackTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheHits() {
+        return hits;
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getCacheHitPercentage() {
+        if (hits == 0 || reads == 0)
+            return 0;
+
+        return (float) hits / reads * 100.0f;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheMisses() {
+        return misses;
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getCacheMissPercentage() {
+        if (misses == 0 || reads == 0) {
+            return 0;
+        }
+
+        return (float) misses / reads * 100.0f;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheGets() {
+        return reads;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCachePuts() {
+        return puts;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheRemovals() {
+        return removes;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheEvictions() {
+        return evicts;
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageGetTime() {
+        return getAvgTimeNanos;
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAveragePutTime() {
+        return putAvgTimeNanos;
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageRemoveTime() {
+        return removeAvgTimeNanos;
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageTxCommitTime() {
+        return commitAvgTimeNanos;
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageTxRollbackTime() {
+        return rollbackAvgTimeNanos;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheTxCommits() {
+        return txCommits;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheTxRollbacks() {
+        return txRollbacks;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeLong(reads);
+        out.writeLong(puts);
+        out.writeLong(hits);
+        out.writeLong(misses);
+        out.writeLong(txCommits);
+        out.writeLong(txRollbacks);
+        out.writeLong(removes);
+        out.writeLong(evicts);
+
+        out.writeFloat(putAvgTimeNanos);
+        out.writeFloat(getAvgTimeNanos);
+        out.writeFloat(removeAvgTimeNanos);
+        out.writeFloat(commitAvgTimeNanos);
+        out.writeFloat(rollbackAvgTimeNanos);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        reads = in.readLong();
+        puts = in.readLong();
+        hits = in.readLong();
+        misses = in.readLong();
+        txCommits = in.readLong();
+        txRollbacks = in.readLong();
+        removes = in.readLong();
+        evicts = in.readLong();
+
+        putAvgTimeNanos = in.readFloat();
+        getAvgTimeNanos = in.readFloat();
+        removeAvgTimeNanos = in.readFloat();
+        commitAvgTimeNanos = in.readFloat();
+        rollbackAvgTimeNanos = in.readFloat();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(CacheMetricsSnapshot.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMxBeanAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMxBeanAdapter.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMxBeanAdapter.java
deleted file mode 100644
index 199b417..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMxBeanAdapter.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.gridgain.grid.kernal.processors.cache;
-
-import org.apache.ignite.*;
-import org.gridgain.grid.cache.*;
-
-/**
- * Management bean that provides access to {@link GridCache}.
- */
-class CacheMxBeanAdapter implements IgniteCacheMxBean {
-    /** Cache context. */
-    private GridCacheContext<?, ?> cctx;
-
-    /** DHT context. */
-    private GridCacheContext<?, ?> dhtCtx;
-
-    /** Write-behind store, if configured. */
-    private GridCacheWriteBehindStore store;
-
-    /**
-     * Creates MBean;
-     *
-     * @param cctx Cache context.
-     */
-    CacheMxBeanAdapter(GridCacheContext<?, ?> cctx) {
-        assert cctx != null;
-
-        this.cctx = cctx;
-
-        if (cctx.isNear())
-            dhtCtx = cctx.near().dht().context();
-
-        if (cctx.store().store() instanceof GridCacheWriteBehindStore)
-            store = (GridCacheWriteBehindStore)cctx.store().store();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String name() {
-        return cctx.name();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String metricsFormatted() {
-        return String.valueOf(cctx.cache().metrics());
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getOverflowSize() {
-        try {
-            return cctx.cache().overflowSize();
-        }
-        catch (IgniteCheckedException ignored) {
-            return -1;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getOffHeapEntriesCount() {
-        return cctx.cache().offHeapEntriesCount();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getOffHeapAllocatedSize() {
-        return cctx.cache().offHeapAllocatedSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getSize() {
-        return cctx.cache().size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getKeySize() {
-        return cctx.cache().size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isEmpty() {
-        return cctx.cache().isEmpty();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getDhtEvictQueueCurrentSize() {
-        return cctx.isNear() ? dhtCtx.evicts().evictQueueSize() : cctx.evicts().evictQueueSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxCommitQueueSize() {
-        return cctx.tm().commitQueueSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxThreadMapSize() {
-        return cctx.tm().threadMapSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxXidMapSize() {
-        return cctx.tm().idMapSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxPrepareQueueSize() {
-        return cctx.tm().prepareQueueSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxStartVersionCountsSize() {
-        return cctx.tm().startVersionCountsSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxCommittedVersionsSize() {
-        return cctx.tm().committedVersionsSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxRolledbackVersionsSize() {
-        return cctx.tm().rolledbackVersionsSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtThreadMapSize() {
-        return cctx.isNear() ? dhtCtx.tm().threadMapSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtXidMapSize() {
-        return cctx.isNear() ? dhtCtx.tm().idMapSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtCommitQueueSize() {
-        return cctx.isNear() ? dhtCtx.tm().commitQueueSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtPrepareQueueSize() {
-        return cctx.isNear() ? dhtCtx.tm().prepareQueueSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtStartVersionCountsSize() {
-        return cctx.isNear() ? dhtCtx.tm().startVersionCountsSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtCommittedVersionsSize() {
-        return cctx.isNear() ? dhtCtx.tm().committedVersionsSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtRolledbackVersionsSize() {
-        return cctx.isNear() ? dhtCtx.tm().rolledbackVersionsSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isWriteBehindEnabled() {
-        return store != null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getWriteBehindFlushSize() {
-        return store != null ? store.getWriteBehindFlushSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getWriteBehindFlushThreadCount() {
-        return store != null ? store.getWriteBehindFlushThreadCount() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getWriteBehindFlushFrequency() {
-        return store != null ? store.getWriteBehindFlushFrequency() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getWriteBehindStoreBatchSize() {
-        return store != null ? store.getWriteBehindStoreBatchSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getWriteBehindTotalCriticalOverflowCount() {
-        return store != null ? store.getWriteBehindTotalCriticalOverflowCount() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getWriteBehindCriticalOverflowCount() {
-        return store != null ? store.getWriteBehindCriticalOverflowCount() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getWriteBehindErrorRetryCount() {
-        return store != null ? store.getWriteBehindErrorRetryCount() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getWriteBehindBufferSize() {
-        return store != null ? store.getWriteBehindBufferSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear() {
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheHits() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getCacheHitPercentage() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheMisses() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getCacheMissPercentage() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheGets() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCachePuts() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheRemovals() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheEvictions() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageGetTime() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAveragePutTime() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageRemoveTime() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageTxCommitTime() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageTxRollbackTime() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheTxCommits() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheTxRollbacks() {
-        return 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMxBeanImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMxBeanImpl.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMxBeanImpl.java
new file mode 100644
index 0000000..c3837f2
--- /dev/null
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMxBeanImpl.java
@@ -0,0 +1,297 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.gridgain.grid.kernal.processors.cache;
+
+import org.apache.ignite.*;
+import org.gridgain.grid.cache.*;
+
+/**
+ * Management bean that provides access to {@link GridCache}.
+ */
+class CacheMxBeanImpl implements IgniteCacheMxBean {
+    /** Cache context. */
+    private GridCacheContext<?, ?> cctx;
+
+    /** DHT context. */
+    private GridCacheContext<?, ?> dhtCtx;
+
+    /** Write-behind store, if configured. */
+    private GridCacheWriteBehindStore store;
+
+    /**
+     * Creates MBean;
+     *
+     * @param cctx Cache context.
+     */
+    CacheMxBeanImpl(GridCacheContext<?, ?> cctx) {
+        assert cctx != null;
+
+        this.cctx = cctx;
+
+        if (cctx.isNear())
+            dhtCtx = cctx.near().dht().context();
+
+        if (cctx.store().store() instanceof GridCacheWriteBehindStore)
+            store = (GridCacheWriteBehindStore)cctx.store().store();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String name() {
+        return cctx.name();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String metricsFormatted() {
+        return String.valueOf(cctx.cache().metrics());
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getOverflowSize() {
+        try {
+            return cctx.cache().overflowSize();
+        }
+        catch (IgniteCheckedException ignored) {
+            return -1;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getOffHeapEntriesCount() {
+        return cctx.cache().offHeapEntriesCount();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getOffHeapAllocatedSize() {
+        return cctx.cache().offHeapAllocatedSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getSize() {
+        return cctx.cache().size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getKeySize() {
+        return cctx.cache().size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isEmpty() {
+        return cctx.cache().isEmpty();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getDhtEvictQueueCurrentSize() {
+        return cctx.isNear() ? dhtCtx.evicts().evictQueueSize() : cctx.evicts().evictQueueSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxCommitQueueSize() {
+        return cctx.tm().commitQueueSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxThreadMapSize() {
+        return cctx.tm().threadMapSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxXidMapSize() {
+        return cctx.tm().idMapSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxPrepareQueueSize() {
+        return cctx.tm().prepareQueueSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxStartVersionCountsSize() {
+        return cctx.tm().startVersionCountsSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxCommittedVersionsSize() {
+        return cctx.tm().committedVersionsSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxRolledbackVersionsSize() {
+        return cctx.tm().rolledbackVersionsSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtThreadMapSize() {
+        return cctx.isNear() ? dhtCtx.tm().threadMapSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtXidMapSize() {
+        return cctx.isNear() ? dhtCtx.tm().idMapSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtCommitQueueSize() {
+        return cctx.isNear() ? dhtCtx.tm().commitQueueSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtPrepareQueueSize() {
+        return cctx.isNear() ? dhtCtx.tm().prepareQueueSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtStartVersionCountsSize() {
+        return cctx.isNear() ? dhtCtx.tm().startVersionCountsSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtCommittedVersionsSize() {
+        return cctx.isNear() ? dhtCtx.tm().committedVersionsSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtRolledbackVersionsSize() {
+        return cctx.isNear() ? dhtCtx.tm().rolledbackVersionsSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isWriteBehindEnabled() {
+        return store != null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getWriteBehindFlushSize() {
+        return store != null ? store.getWriteBehindFlushSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getWriteBehindFlushThreadCount() {
+        return store != null ? store.getWriteBehindFlushThreadCount() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getWriteBehindFlushFrequency() {
+        return store != null ? store.getWriteBehindFlushFrequency() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getWriteBehindStoreBatchSize() {
+        return store != null ? store.getWriteBehindStoreBatchSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getWriteBehindTotalCriticalOverflowCount() {
+        return store != null ? store.getWriteBehindTotalCriticalOverflowCount() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getWriteBehindCriticalOverflowCount() {
+        return store != null ? store.getWriteBehindCriticalOverflowCount() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getWriteBehindErrorRetryCount() {
+        return store != null ? store.getWriteBehindErrorRetryCount() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getWriteBehindBufferSize() {
+        return store != null ? store.getWriteBehindBufferSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear() {
+        cctx.cache().metrics0().clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheHits() {
+        return cctx.cache().metrics0().getCacheHits();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getCacheHitPercentage() {
+        return cctx.cache().metrics0().getCacheHitPercentage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheMisses() {
+        return cctx.cache().metrics0().getCacheMisses();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getCacheMissPercentage() {
+        return cctx.cache().metrics0().getCacheMissPercentage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheGets() {
+        return cctx.cache().metrics0().getCacheGets();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCachePuts() {
+        return cctx.cache().metrics0().getCachePuts();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheRemovals() {
+        return cctx.cache().metrics0().getCacheRemovals();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheEvictions() {
+        return cctx.cache().metrics0().getCacheEvictions();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageGetTime() {
+        return cctx.cache().metrics0().getAverageGetTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAveragePutTime() {
+        return cctx.cache().metrics0().getAveragePutTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageRemoveTime() {
+        return cctx.cache().metrics0().getAverageRemoveTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageTxCommitTime() {
+        return cctx.cache().metrics0().getAverageTxCommitTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageTxRollbackTime() {
+        return cctx.cache().metrics0().getAverageTxRollbackTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheTxCommits() {
+        return cctx.cache().metrics0().getCacheTxCommits();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheTxRollbacks() {
+        return cctx.cache().metrics0().getCacheTxRollbacks();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
index 1f9cdb0..68f782d 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
@@ -149,6 +149,9 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
     /** Cache metrics. */
     protected volatile CacheMetricsImpl metrics;
 
+    /** Cache mxBean. */
+    protected IgniteCacheMxBean mxBean;
+
     /** Logger. */
     protected IgniteLogger log;
 
@@ -228,6 +231,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
 
         metrics = new CacheMetricsImpl();
 
+        mxBean = new CacheMxBeanImpl(ctx);
+
         IgniteFsConfiguration[] ggfsCfgs = gridCfg.getGgfsConfiguration();
 
         if (ggfsCfgs != null) {
@@ -3392,7 +3397,12 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
 
     /** {@inheritDoc} */
     @Override public CacheMetrics metrics() {
-        return metrics;
+        return new CacheMetricsSnapshot(metrics);
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteCacheMxBean mxBean() {
+        return mxBean;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
index 611e2cb..1cd4759 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
@@ -101,12 +101,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     /** Caches stop sequence. */
     private final Deque<GridCacheAdapter<?, ?>> stopSeq;
 
-    /** MBean server. */
-    private final MBeanServer mBeanSrv;
-
-    /** Cache MBeans. */
-    private final Collection<ObjectName> cacheMBeans = new LinkedList<>();
-
     /** Transaction interface implementation. */
     private IgniteTransactionsImpl transactions;
 
@@ -124,8 +118,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         sysCaches = new HashSet<>();
         stopSeq = new LinkedList<>();
-
-        mBeanSrv = ctx.config().getMBeanServer();
     }
 
     /**
@@ -893,21 +885,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             jCacheProxies.put(e.getKey(), new IgniteCacheProxy(cache.context(), cache, null, false));
         }
 
-        for (GridCacheAdapter<?, ?> cache : caches.values()) {
-            try {
-                ObjectName mb = U.registerCacheMBean(mBeanSrv, ctx.gridName(), cache.name(), "Cache",
-                    new CacheMxBeanAdapter(cache.context()), IgniteCacheMxBean.class);
-
-                cacheMBeans.add(mb);
-
-                if (log.isDebugEnabled())
-                    log.debug("Registered cache MBean: " + mb);
-            }
-            catch (JMException ex) {
-                U.error(log, "Failed to register cache MBean.", ex);
-            }
-        }
-
         // Internal caches which should not be returned to user.
         for (Map.Entry<String, GridCacheAdapter<?, ?>> e : caches.entrySet()) {
             GridCacheAdapter cache = e.getValue();
@@ -1387,20 +1364,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (ctx.config().isDaemon())
             return;
 
-        if (!F.isEmpty(cacheMBeans)) {
-            for (ObjectName mb : cacheMBeans) {
-                try {
-                    mBeanSrv.unregisterMBean(mb);
-
-                    if (log.isDebugEnabled())
-                        log.debug("Unregistered cache MBean: " + mb);
-                }
-                catch (JMException e) {
-                    U.error(log, "Failed to unregister cache MBean: " + mb, e);
-                }
-            }
-        }
-
         for (GridCacheAdapter<?, ?> cache : stopSeq) {
             GridCacheContext ctx = cache.context();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProxyImpl.java
index 5c986cf..ada2542 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProxyImpl.java
@@ -208,6 +208,18 @@ public class GridCacheProxyImpl<K, V> implements GridCacheProxy<K, V>, Externali
     }
 
     /** {@inheritDoc} */
+    @Override public IgniteCacheMxBean mxBean() {
+        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+        try {
+            return cache.mxBean();
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public long overflowSize() throws IgniteCheckedException {
         GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/main/java/org/gridgain/grid/kernal/visor/cache/VisorCacheResetMetricsTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/visor/cache/VisorCacheResetMetricsTask.java b/modules/core/src/main/java/org/gridgain/grid/kernal/visor/cache/VisorCacheResetMetricsTask.java
index 3a18008..ea25524 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/visor/cache/VisorCacheResetMetricsTask.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/visor/cache/VisorCacheResetMetricsTask.java
@@ -56,7 +56,7 @@ public class VisorCacheResetMetricsTask extends VisorOneNodeTask<String, Void> {
             GridCache cache = g.cachex(cacheName);
 
             if (cache != null)
-                cache.metrics().clear();
+                cache.mxBean().clear();
 
             return null;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractMetricsSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractMetricsSelfTest.java
index 920910e..c757ebc 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractMetricsSelfTest.java
@@ -81,7 +81,7 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
 
             assert g.cache(null).isEmpty();
 
-            g.cache(null).metrics().clear();
+            g.cache(null).mxBean().clear();
 
             g.transactions().resetMetrics();
         }
@@ -101,6 +101,15 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
     /**
      * @throws Exception If failed.
      */
+    public void testGetMetricsSnapshot() throws Exception {
+        IgniteCache<Object, Object> cache = grid(0).jcache(null);
+
+        assertNotSame("Method metrics() should return snapshot.", cache.metrics(), cache.metrics());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testRemoveAsyncAvgTime() throws Exception {
         GridCache<Object, Object> cache = grid(0).cache(null);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMetricsSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMetricsSelfTest.java
index ecf83dc..4b6a799 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMetricsSelfTest.java
@@ -92,7 +92,7 @@ public class GridCachePartitionedNearDisabledMetricsSelfTest extends GridCacheAb
 
             assert g.cache(null).isEmpty();
 
-            g.cache(null).metrics().clear();
+            g.cache(null).mxBean().clear();
         }
 
         assertNull("Value is not null for key: " + 0, cache.get(0));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/669f3a91/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java
index d9a6861..3a8f79e 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java
@@ -70,7 +70,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
             assert g.cache(null).isEmpty();
 
-            g.cache(null).metrics().clear();
+            g.cache(null).mxBean().clear();
         }
     }
 


Mime
View raw message