IGNITE-49 Renamed metrics interfaces.

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

Branch: refs/heads/ignite-102
Commit: f1a8f165afb2573b4df4e8847e76ab0a784e97a3
Parents: 75b1056
Author: nikolay_tikhonov <ntikho...@gridgain.com>
Authored: Tue Jan 27 15:18:12 2015 +0300
Committer: nikolay_tikhonov <ntikho...@gridgain.com>
Committed: Tue Jan 27 15:18:12 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cache/CacheManager.java   |   59 +-
 .../org/apache/ignite/cache/CacheMetrics.java   |  111 +-
 .../apache/ignite/cluster/ClusterMetrics.java   |    2 +-
 .../internal/CacheConfigurationMXBeanImpl.java  |   75 --
 .../internal/ClusterLocalMetricsMXBean.java     |  312 -----
 .../ClusterLocalNodeMetricsMXBeanImpl.java      |  312 +++++
 .../ignite/internal/ClusterMetricsImpl.java     |    2 -
 .../org/apache/ignite/internal/GridKernal.java  |    4 +-
 .../discovery/GridDiscoveryManager.java         |    2 +-
 .../processors/cache/CacheMetricsAdapter.java   |  551 ---------
 .../processors/cache/CacheMetricsImpl.java      |  587 +++++++++
 .../cache/CacheMetricsMXBeanImpl.java           |   35 +
 .../processors/cache/CacheMetricsSnapshot.java  |  165 +--
 .../processors/cache/GridCacheAdapter.java      |   18 +-
 .../cache/distributed/dht/GridDhtCache.java     |    2 +-
 .../dht/atomic/GridDhtAtomicCache.java          |    2 +-
 .../ignite/mxbean/CacheConfigurationMXBean.java |   54 -
 .../ignite/mxbean/CacheMetricsMXBean.java       |   30 +-
 .../mxbean/ClusterLocalNodeMetricsMXBean.java   |  240 ++++
 .../ignite/mxbean/ClusterMetricsMXBean.java     |  240 ----
 .../spi/discovery/ClusterMetricsSnapshot.java   | 1118 ++++++++++++++++++
 .../spi/discovery/DiscoveryMetricsAdapter.java  | 1068 -----------------
 .../spi/discovery/DiscoveryMetricsHelper.java   |    2 +-
 ...bStealingCollisionSpiAttributesSelfTest.java |    2 +-
 ...alingCollisionSpiCustomTopologySelfTest.java |    2 +-
 .../GridJobStealingCollisionSpiSelfTest.java    |    2 +-
 .../GridDiscoveryMetricsHelperSelfTest.java     |    2 +-
 .../testframework/GridSpiTestContext.java       |    4 +-
 .../junits/spi/GridSpiAbstractTest.java         |    2 +-
 .../util/GridTopologyHeapSizeSelfTest.java      |    2 +-
 30 files changed, 2534 insertions(+), 2473 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java 
b/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
index de91ef8..f6ac23a 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
@@ -19,9 +19,6 @@ package org.apache.ignite.cache;
 
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.lang.*;
 
 import javax.cache.*;
 import javax.cache.configuration.*;
@@ -31,7 +28,7 @@ import java.util.*;
 import java.util.concurrent.atomic.*;
 
 /**
- * Implementation of JSR-107 {@link javax.cache.CacheManager}.
+ * Implementation of JSR-107 {@link CacheManager}.
  */
 public class CacheManager implements javax.cache.CacheManager {
     /** */
@@ -41,7 +38,7 @@ public class CacheManager implements javax.cache.CacheManager 
{
     private static final String CACHE_CONFIGURATION = "CacheConfiguration";
 
     /** */
-    private final Map<String, IgniteBiTuple<Ignite, 
CacheConfigurationMXBeanImpl>> igniteMap = new HashMap<>();
+    private final Map<String, Ignite> igniteMap = new HashMap<>();
 
     /** */
     private final URI uri;
@@ -147,7 +144,7 @@ public class CacheManager implements 
javax.cache.CacheManager {
 
             res = ignite.jcache(cacheName);
 
-            igniteMap.put(cacheName, new T2<>(ignite, new 
CacheConfigurationMXBeanImpl(res)));
+            igniteMap.put(cacheName, ignite);
         }
 
         if (((CompleteConfiguration)cacheCfg).isManagementEnabled())
@@ -163,16 +160,16 @@ public class CacheManager implements 
javax.cache.CacheManager {
      * @param cacheName Cache name.
      */
     private <K, V> IgniteCache<K, V> findCache(String cacheName) {
-        IgniteBiTuple<Ignite, CacheConfigurationMXBeanImpl> tuple;
+        Ignite ignite;
 
         synchronized (igniteMap) {
-            tuple = igniteMap.get(cacheName);
+            ignite = igniteMap.get(cacheName);
         }
 
-        if (tuple == null)
+        if (ignite == null)
             return null;
 
-        return tuple.get1().jcache(cacheName);
+        return ignite.jcache(cacheName);
     }
 
     /** {@inheritDoc} */
@@ -229,8 +226,8 @@ public class CacheManager implements 
javax.cache.CacheManager {
      */
     public boolean isManagedIgnite(Ignite ignite) {
         synchronized (igniteMap) {
-            for (IgniteBiTuple<Ignite, CacheConfigurationMXBeanImpl> tuple : 
igniteMap.values()) {
-                if (ignite.equals(tuple.get1()))
+            for (Ignite instance : igniteMap.values()) {
+                if (ignite.equals(instance))
                     return true;
             }
         }
@@ -245,21 +242,21 @@ public class CacheManager implements 
javax.cache.CacheManager {
         if (cacheName == null)
             throw new NullPointerException();
 
-        IgniteBiTuple<Ignite, CacheConfigurationMXBeanImpl> tuple;
+        Ignite ignite;
 
         synchronized (igniteMap) {
-            tuple = igniteMap.remove(cacheName);
+            ignite = igniteMap.remove(cacheName);
         }
 
-        if (tuple != null) {
+        if (ignite != null) {
             try {
-                tuple.get1().close();
+                ignite.close();
             }
             catch (Exception ignored) {
-
+                // No-op.
             }
 
-            MBeanServer mBeanSrv = 
tuple.get1().configuration().getMBeanServer();
+            MBeanServer mBeanSrv = ignite.configuration().getMBeanServer();
 
             unregisterCacheObject(mBeanSrv, cacheName, CACHE_STATISTICS);
 
@@ -290,23 +287,23 @@ public class CacheManager implements 
javax.cache.CacheManager {
         if (cacheName == null)
             throw new NullPointerException();
 
-        IgniteBiTuple<Ignite, CacheConfigurationMXBeanImpl> tuple;
+        Ignite ignite;
 
         synchronized (igniteMap) {
-            tuple = igniteMap.get(cacheName);
+            ignite = igniteMap.get(cacheName);
         }
 
-        MBeanServer mBeanSrv = tuple.get1().configuration().getMBeanServer();
+        MBeanServer mBeanSrv = ignite.configuration().getMBeanServer();
 
         if (enabled) {
-            registerCacheObject(mBeanSrv, tuple.get2(), cacheName, 
CACHE_CONFIGURATION);
+            registerCacheObject(mBeanSrv, ignite.jcache(cacheName).mxBean(), 
cacheName, CACHE_CONFIGURATION);
 
-            
tuple.get1().cache(cacheName).configuration().setManagementEnabled(true);
+            ignite.cache(cacheName).configuration().setManagementEnabled(true);
         }
         else {
             unregisterCacheObject(mBeanSrv, cacheName, CACHE_CONFIGURATION);
 
-            
tuple.get1().cache(cacheName).configuration().setManagementEnabled(false);
+            
ignite.cache(cacheName).configuration().setManagementEnabled(false);
         }
     }
 
@@ -318,14 +315,12 @@ public class CacheManager implements 
javax.cache.CacheManager {
         if (cacheName == null)
             throw new NullPointerException();
 
-        IgniteBiTuple<Ignite, CacheConfigurationMXBeanImpl> tuple;
+        Ignite ignite;
 
         synchronized (igniteMap) {
-            tuple = igniteMap.get(cacheName);
+            ignite = igniteMap.get(cacheName);
         }
 
-        Ignite ignite = tuple.get1();
-
         IgniteCache<Object, Object> cache = ignite.jcache(cacheName);
 
         CacheConfiguration cfg = 
cache.getConfiguration(CacheConfiguration.class);
@@ -404,15 +399,15 @@ public class CacheManager implements 
javax.cache.CacheManager {
     /** {@inheritDoc} */
     @Override public void close() {
         if (closed.compareAndSet(false, true)) {
-            IgniteBiTuple<Ignite, CacheConfigurationMXBeanImpl>[] ignites;
+            Ignite[] ignites;
 
             synchronized (igniteMap) {
-                ignites = igniteMap.values().toArray(new 
IgniteBiTuple[igniteMap.values().size()]);
+                ignites = igniteMap.values().toArray(new 
Ignite[igniteMap.values().size()]);
             }
 
-            for (IgniteBiTuple<Ignite, CacheConfigurationMXBeanImpl> tuple : 
ignites) {
+            for (Ignite ignite : ignites) {
                 try {
-                    tuple.get1().close();
+                    ignite.close();
                 }
                 catch (Exception ignored) {
                     // Ignore any exceptions according to javadoc of 
javax.cache.CacheManager#close()

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java 
b/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
index b0a1350..da4bceb 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
@@ -17,9 +17,14 @@
 
 package org.apache.ignite.cache;
 
+import org.apache.ignite.*;
+
+import javax.cache.*;
+import javax.cache.integration.*;
+
 /**
  * Cache metrics used to obtain statistics on cache itself.
- * Use {@link org.apache.ignite.IgniteCache#metrics()} to obtain metrics for a 
cache.
+ * Use {@link IgniteCache#metrics()} to obtain metrics for a cache.
  */
 public interface CacheMetrics {
     /**
@@ -34,14 +39,14 @@ public interface CacheMetrics {
      *
      * @return the percentage of successful hits, as a decimal e.g 75.
      */
-    float getCacheHitPercentage();
+    public float getCacheHitPercentage();
 
     /**
      * A miss is a get request that is not satisfied.
      *
      * @return the number of misses
      */
-    long getCacheMisses();
+    public long getCacheMisses();
 
     /**
      * Returns the percentage of cache accesses that did not find a requested 
entry
@@ -49,7 +54,7 @@ public interface CacheMetrics {
      *
      * @return the percentage of accesses that failed to find anything
      */
-    float getCacheMissPercentage();
+    public float getCacheMissPercentage();
 
     /**
      * The total number of requests to the cache. This will be equal to the 
sum of
@@ -57,14 +62,14 @@ public interface CacheMetrics {
      *
      * @return the number of gets
      */
-    long getCacheGets();
+    public long getCacheGets();
 
     /**
      * The total number of puts to the cache.
      *
      * @return the number of puts
      */
-    long getCachePuts();
+    public long getCachePuts();
 
     /**
      * The total number of removals from the cache. This does not include 
evictions,
@@ -72,7 +77,7 @@ public interface CacheMetrics {
      *
      * @return the number of removals
      */
-    long getCacheRemovals();
+    public long getCacheRemovals();
 
     /**
      * The total number of evictions from the cache. An eviction is a removal
@@ -81,28 +86,28 @@ public interface CacheMetrics {
      *
      * @return the number of evictions
      */
-    long getCacheEvictions();
+    public long getCacheEvictions();
 
     /**
      * The mean time to execute gets.
      *
      * @return the time in µs
      */
-    float getAverageGetTime();
+    public float getAverageGetTime();
 
     /**
      * The mean time to execute puts.
      *
      * @return the time in µs
      */
-    float getAveragePutTime();
+    public float getAveragePutTime();
 
     /**
      * The mean time to execute removes.
      *
      * @return the time in µs
      */
-    float getAverageRemoveTime();
+    public float getAverageRemoveTime();
 
 
     /**
@@ -363,4 +368,88 @@ public interface CacheMetrics {
      * @return Total count of entries in cache store internal buffer.
      */
     public int getWriteBehindBufferSize();
+
+    /**
+     * Determines the required type of keys for this {@link Cache}, if any.
+     *
+     * @return the fully qualified class name of the key type,
+     * or "java.lang.Object" if the type is undefined.
+     */
+    public String getKeyType();
+
+    /**
+     * Determines the required type of values for this {@link Cache}, if any.
+     *
+     * @return the fully qualified class name of the value type,
+     *         or "java.lang.Object" if the type is undefined.
+     */
+    public String getValueType();
+
+    /**
+     * Whether storeByValue {@code true} or storeByReference {@code false}.
+     * When {@code true}, both keys and values are stored by value.
+     * <p>
+     * When {@code false}, both keys and values are stored by reference.
+     * Caches stored by reference are capable of mutation by any threads 
holding
+     * the reference. The effects are:
+     * <ul>
+     * <li>if the key is mutated, then the key may not be retrievable or
+     * removable</li>
+     * <li>if the value is mutated, then all threads in the JVM can potentially
+     * observe those mutations, subject to the normal Java Memory Model 
rules.</li>
+     * </ul>
+     * Storage by reference only applies to the local heap. If an entry is 
moved off
+     * heap it will need to be transformed into a representation. Any 
mutations that
+     * occur after transformation may not be reflected in the cache.
+     * <p>
+     * When a cache is storeByValue, any mutation to the key or value does not 
affect
+     * the key of value stored in the cache.
+     * <p>
+     * The default value is {@code true}.
+     *
+     * @return true if the cache is store by value
+     */
+    public boolean isStoreByValue();
+
+    /**
+     * Checks whether statistics collection is enabled in this cache.
+     * <p>
+     * The default value is {@code false}.
+     *
+     * @return true if statistics collection is enabled
+     */
+    public boolean isStatisticsEnabled();
+
+    /**
+     * Checks whether management is enabled on this cache.
+     * <p>
+     * The default value is {@code false}.
+     *
+     * @return true if management is enabled
+     */
+    public boolean isManagementEnabled();
+
+    /**
+     * Determines if a {@link Cache} should operate in read-through mode.
+     * <p>
+     * The default value is {@code false}
+     *
+     * @return {@code true} when a {@link Cache} is in
+     *         "read-through" mode.
+     * @see CacheLoader
+     */
+    public boolean isReadThrough();
+
+    /**
+     * Determines if a {@link Cache} should operate in "write-through"
+     * mode.
+     * <p>
+     * will appropriately cause the configured {@link CacheWriter} to be 
invoked.
+     * <p>
+     * The default value is {@code false}
+     *
+     * @return {@code true} when a {@link Cache} is in "write-through" mode.
+     * @see CacheWriter
+     */
+    public boolean isWriteThrough();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/cluster/ClusterMetrics.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterMetrics.java 
b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterMetrics.java
index 461cc17..3cdb7f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterMetrics.java
@@ -37,7 +37,7 @@ import java.io.*;
  * that comes with JDK as it also provides ability to view any node parameter
  * as a graph.
  */
-public interface ClusterMetrics extends Serializable {
+public interface ClusterMetrics {
     /**
      * Gets last update time of this node metrics.
      *

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/internal/CacheConfigurationMXBeanImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/CacheConfigurationMXBeanImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/CacheConfigurationMXBeanImpl.java
deleted file mode 100644
index 0b402e8..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/CacheConfigurationMXBeanImpl.java
+++ /dev/null
@@ -1,75 +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.apache.ignite.internal;
-
-import org.apache.ignite.mxbean.*;
-
-import javax.cache.*;
-import javax.cache.configuration.*;
-import javax.cache.management.*;
-
-/**
- * Implementation of {@link CacheMXBean}.
- *
- */
-public class CacheConfigurationMXBeanImpl implements CacheConfigurationMXBean {
-    /** */
-    private final Cache<?, ?> cache;
-
-    /**
-     * @param cache Cache.
-     */
-    public CacheConfigurationMXBeanImpl(Cache<?, ?> cache) {
-        this.cache = cache;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String getKeyType() {
-        return 
cache.getConfiguration(CompleteConfiguration.class).getKeyType().getName();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String getValueType() {
-        return 
cache.getConfiguration(CompleteConfiguration.class).getValueType().getName();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isReadThrough() {
-        return 
cache.getConfiguration(CompleteConfiguration.class).isReadThrough();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isWriteThrough() {
-        return 
cache.getConfiguration(CompleteConfiguration.class).isWriteThrough();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isStoreByValue() {
-        return 
cache.getConfiguration(CompleteConfiguration.class).isStoreByValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isStatisticsEnabled() {
-        return 
cache.getConfiguration(CompleteConfiguration.class).isStatisticsEnabled();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isManagementEnabled() {
-        return 
cache.getConfiguration(CompleteConfiguration.class).isManagementEnabled();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/internal/ClusterLocalMetricsMXBean.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/ClusterLocalMetricsMXBean.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/ClusterLocalMetricsMXBean.java
deleted file mode 100644
index ee194f2..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/ClusterLocalMetricsMXBean.java
+++ /dev/null
@@ -1,312 +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.apache.ignite.internal;
-
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.mxbean.*;
-
-/**
- * Local node metrics MBean.
- */
-public class ClusterLocalMetricsMXBean implements ClusterMetricsMXBean {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Grid node. */
-    private final ClusterNode node;
-
-    /**
-     * @param node Node to manage.
-     */
-    public ClusterLocalMetricsMXBean(ClusterNode node) {
-        assert node != null;
-
-        this.node = node;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTotalCpus() {
-        return node.metrics().getTotalCpus();
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageActiveJobs() {
-        return node.metrics().getAverageActiveJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageCancelledJobs() {
-        return node.metrics().getAverageCancelledJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getAverageJobExecuteTime() {
-        return node.metrics().getAverageJobExecuteTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getAverageJobWaitTime() {
-        return node.metrics().getAverageJobWaitTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageRejectedJobs() {
-        return node.metrics().getAverageRejectedJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageWaitingJobs() {
-        return node.metrics().getAverageWaitingJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getBusyTimePercentage() {
-        return node.metrics().getBusyTimePercentage() * 100;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getCurrentActiveJobs() {
-        return node.metrics().getCurrentActiveJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getCurrentCancelledJobs() {
-        return node.metrics().getCurrentCancelledJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCurrentIdleTime() {
-        return node.metrics().getCurrentIdleTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCurrentJobExecuteTime() {
-        return node.metrics().getCurrentJobExecuteTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCurrentJobWaitTime() {
-        return node.metrics().getCurrentJobWaitTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getCurrentRejectedJobs() {
-        return node.metrics().getCurrentRejectedJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getCurrentWaitingJobs() {
-        return node.metrics().getCurrentWaitingJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTotalExecutedTasks() {
-        return node.metrics().getTotalExecutedTasks();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getCurrentDaemonThreadCount() {
-        return node.metrics().getCurrentDaemonThreadCount();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getHeapMemoryCommitted() {
-        return node.metrics().getHeapMemoryCommitted();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getHeapMemoryInitialized() {
-        return node.metrics().getHeapMemoryInitialized();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getHeapMemoryMaximum() {
-        return node.metrics().getHeapMemoryMaximum();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getHeapMemoryUsed() {
-        return node.metrics().getHeapMemoryUsed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getIdleTimePercentage() {
-        return node.metrics().getIdleTimePercentage() * 100;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getLastUpdateTime() {
-        return node.metrics().getLastUpdateTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getMaximumActiveJobs() {
-        return node.metrics().getMaximumActiveJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getMaximumCancelledJobs() {
-        return node.metrics().getMaximumCancelledJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getMaximumJobExecuteTime() {
-        return node.metrics().getMaximumJobExecuteTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getMaximumJobWaitTime() {
-        return node.metrics().getMaximumJobWaitTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getMaximumRejectedJobs() {
-        return node.metrics().getMaximumRejectedJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getMaximumWaitingJobs() {
-        return node.metrics().getMaximumWaitingJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getNonHeapMemoryCommitted() {
-        return node.metrics().getNonHeapMemoryCommitted();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getNonHeapMemoryInitialized() {
-        return node.metrics().getNonHeapMemoryInitialized();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getNonHeapMemoryMaximum() {
-        return node.metrics().getNonHeapMemoryMaximum();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getNonHeapMemoryUsed() {
-        return node.metrics().getNonHeapMemoryUsed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getMaximumThreadCount() {
-        return node.metrics().getMaximumThreadCount();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getStartTime() {
-        return node.metrics().getStartTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getNodeStartTime() {
-        return node.metrics().getNodeStartTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getCurrentCpuLoad() {
-        return node.metrics().getCurrentCpuLoad() * 100;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getAverageCpuLoad() {
-        return node.metrics().getAverageCpuLoad() * 100;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getCurrentGcCpuLoad() {
-        return node.metrics().getCurrentGcCpuLoad() * 100;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getCurrentThreadCount() {
-        return node.metrics().getCurrentThreadCount();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getTotalBusyTime() {
-        return node.metrics().getTotalBusyTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTotalCancelledJobs() {
-        return node.metrics().getTotalCancelledJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTotalExecutedJobs() {
-        return node.metrics().getTotalExecutedJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getTotalIdleTime() {
-        return node.metrics().getTotalIdleTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTotalRejectedJobs() {
-        return node.metrics().getTotalRejectedJobs();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getTotalStartedThreadCount() {
-        return node.metrics().getTotalStartedThreadCount();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getUpTime() {
-        return node.metrics().getUpTime();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getLastDataVersion() {
-        return node.metrics().getLastDataVersion();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getSentMessagesCount() {
-        return node.metrics().getSentMessagesCount();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getSentBytesCount() {
-        return node.metrics().getSentBytesCount();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getReceivedMessagesCount() {
-        return node.metrics().getReceivedMessagesCount();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getReceivedBytesCount() {
-        return node.metrics().getReceivedBytesCount();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getOutboundMessagesQueueSize() {
-        return node.metrics().getOutboundMessagesQueueSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(ClusterLocalMetricsMXBean.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/internal/ClusterLocalNodeMetricsMXBeanImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/ClusterLocalNodeMetricsMXBeanImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/ClusterLocalNodeMetricsMXBeanImpl.java
new file mode 100644
index 0000000..30fa224
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/ClusterLocalNodeMetricsMXBeanImpl.java
@@ -0,0 +1,312 @@
+/*
+ * 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.apache.ignite.internal;
+
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.mxbean.*;
+
+/**
+ * Local node metrics MBean.
+ */
+public class ClusterLocalNodeMetricsMXBeanImpl implements 
ClusterLocalNodeMetricsMXBean {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Grid node. */
+    private final ClusterNode node;
+
+    /**
+     * @param node Node to manage.
+     */
+    public ClusterLocalNodeMetricsMXBeanImpl(ClusterNode node) {
+        assert node != null;
+
+        this.node = node;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTotalCpus() {
+        return node.metrics().getTotalCpus();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageActiveJobs() {
+        return node.metrics().getAverageActiveJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageCancelledJobs() {
+        return node.metrics().getAverageCancelledJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getAverageJobExecuteTime() {
+        return node.metrics().getAverageJobExecuteTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getAverageJobWaitTime() {
+        return node.metrics().getAverageJobWaitTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageRejectedJobs() {
+        return node.metrics().getAverageRejectedJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageWaitingJobs() {
+        return node.metrics().getAverageWaitingJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getBusyTimePercentage() {
+        return node.metrics().getBusyTimePercentage() * 100;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getCurrentActiveJobs() {
+        return node.metrics().getCurrentActiveJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getCurrentCancelledJobs() {
+        return node.metrics().getCurrentCancelledJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCurrentIdleTime() {
+        return node.metrics().getCurrentIdleTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCurrentJobExecuteTime() {
+        return node.metrics().getCurrentJobExecuteTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCurrentJobWaitTime() {
+        return node.metrics().getCurrentJobWaitTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getCurrentRejectedJobs() {
+        return node.metrics().getCurrentRejectedJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getCurrentWaitingJobs() {
+        return node.metrics().getCurrentWaitingJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTotalExecutedTasks() {
+        return node.metrics().getTotalExecutedTasks();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getCurrentDaemonThreadCount() {
+        return node.metrics().getCurrentDaemonThreadCount();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getHeapMemoryCommitted() {
+        return node.metrics().getHeapMemoryCommitted();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getHeapMemoryInitialized() {
+        return node.metrics().getHeapMemoryInitialized();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getHeapMemoryMaximum() {
+        return node.metrics().getHeapMemoryMaximum();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getHeapMemoryUsed() {
+        return node.metrics().getHeapMemoryUsed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getIdleTimePercentage() {
+        return node.metrics().getIdleTimePercentage() * 100;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getLastUpdateTime() {
+        return node.metrics().getLastUpdateTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getMaximumActiveJobs() {
+        return node.metrics().getMaximumActiveJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getMaximumCancelledJobs() {
+        return node.metrics().getMaximumCancelledJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getMaximumJobExecuteTime() {
+        return node.metrics().getMaximumJobExecuteTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getMaximumJobWaitTime() {
+        return node.metrics().getMaximumJobWaitTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getMaximumRejectedJobs() {
+        return node.metrics().getMaximumRejectedJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getMaximumWaitingJobs() {
+        return node.metrics().getMaximumWaitingJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getNonHeapMemoryCommitted() {
+        return node.metrics().getNonHeapMemoryCommitted();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getNonHeapMemoryInitialized() {
+        return node.metrics().getNonHeapMemoryInitialized();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getNonHeapMemoryMaximum() {
+        return node.metrics().getNonHeapMemoryMaximum();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getNonHeapMemoryUsed() {
+        return node.metrics().getNonHeapMemoryUsed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getMaximumThreadCount() {
+        return node.metrics().getMaximumThreadCount();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getStartTime() {
+        return node.metrics().getStartTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getNodeStartTime() {
+        return node.metrics().getNodeStartTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getCurrentCpuLoad() {
+        return node.metrics().getCurrentCpuLoad() * 100;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getAverageCpuLoad() {
+        return node.metrics().getAverageCpuLoad() * 100;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getCurrentGcCpuLoad() {
+        return node.metrics().getCurrentGcCpuLoad() * 100;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getCurrentThreadCount() {
+        return node.metrics().getCurrentThreadCount();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getTotalBusyTime() {
+        return node.metrics().getTotalBusyTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTotalCancelledJobs() {
+        return node.metrics().getTotalCancelledJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTotalExecutedJobs() {
+        return node.metrics().getTotalExecutedJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getTotalIdleTime() {
+        return node.metrics().getTotalIdleTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTotalRejectedJobs() {
+        return node.metrics().getTotalRejectedJobs();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getTotalStartedThreadCount() {
+        return node.metrics().getTotalStartedThreadCount();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getUpTime() {
+        return node.metrics().getUpTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getLastDataVersion() {
+        return node.metrics().getLastDataVersion();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getSentMessagesCount() {
+        return node.metrics().getSentMessagesCount();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getSentBytesCount() {
+        return node.metrics().getSentBytesCount();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getReceivedMessagesCount() {
+        return node.metrics().getReceivedMessagesCount();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getReceivedBytesCount() {
+        return node.metrics().getReceivedBytesCount();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getOutboundMessagesQueueSize() {
+        return node.metrics().getOutboundMessagesQueueSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(ClusterLocalNodeMetricsMXBeanImpl.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/internal/ClusterMetricsImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/ClusterMetricsImpl.java 
b/modules/core/src/main/java/org/apache/ignite/internal/ClusterMetricsImpl.java
index 1a932da..113a1bc 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/ClusterMetricsImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/ClusterMetricsImpl.java
@@ -30,8 +30,6 @@ import static java.lang.Math.*;
  * Implementation for {@link org.apache.ignite.cluster.ClusterMetrics 
ClusterNodeMetrics} interface.
  */
 class ClusterMetricsImpl implements ClusterMetrics {
-    /** */
-    private static final long serialVersionUID = 0L;
 
     /** */
     private int totalExecutedTask;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/internal/GridKernal.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/GridKernal.java 
b/modules/core/src/main/java/org/apache/ignite/internal/GridKernal.java
index fbb4ac0..7038b5a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernal.java
@@ -1448,7 +1448,7 @@ public class GridKernal extends ClusterGroupAdapter 
implements GridEx, IgniteMBe
 
     /** @throws IgniteCheckedException If registration failed. */
     private void registerLocalNodeMBean() throws IgniteCheckedException {
-        ClusterMetricsMXBean mbean = new 
ClusterLocalMetricsMXBean(ctx.discovery().localNode());
+        ClusterLocalNodeMetricsMXBean mbean = new 
ClusterLocalNodeMetricsMXBeanImpl(ctx.discovery().localNode());
 
         try {
             locNodeMBean = U.registerMBean(
@@ -1457,7 +1457,7 @@ public class GridKernal extends ClusterGroupAdapter 
implements GridEx, IgniteMBe
                 "Kernal",
                 mbean.getClass().getSimpleName(),
                 mbean,
-                ClusterMetricsMXBean.class);
+                ClusterLocalNodeMetricsMXBean.class);
 
             if (log.isDebugEnabled())
                 log.debug("Registered local node MBean: " + locNodeMBean);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 2b568c2..c2c330e 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -495,7 +495,7 @@ public class GridDiscoveryManager extends 
GridManagerAdapter<DiscoverySpi> {
             @Override public ClusterMetrics metrics() {
                 GridJobMetrics jm = ctx.jobMetric().getJobMetrics();
 
-                DiscoveryMetricsAdapter nm = new DiscoveryMetricsAdapter();
+                ClusterMetricsSnapshot nm = new ClusterMetricsSnapshot();
 
                 nm.setLastUpdateTime(U.currentTimeMillis());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsAdapter.java
deleted file mode 100644
index 0752544..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsAdapter.java
+++ /dev/null
@@ -1,551 +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.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.internal.util.tostring.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-import java.util.concurrent.atomic.*;
-
-/**
- * Adapter for cache metrics.
- */
-public class CacheMetricsAdapter implements CacheMetrics {
-    /** */
-    private static final long NANOS_IN_MICROSECOND = 1000L;
-
-    /** Number of reads. */
-    private AtomicLong reads = new AtomicLong();
-
-    /** Number of writes. */
-    private AtomicLong writes = new AtomicLong();
-
-    /** Number of hits. */
-    private AtomicLong hits = new AtomicLong();
-
-    /** Number of misses. */
-    private AtomicLong misses = new AtomicLong();
-
-    /** Number of transaction commits. */
-    private AtomicLong txCommits = new AtomicLong();
-
-    /** Number of transaction rollbacks. */
-    private AtomicLong txRollbacks = new AtomicLong();
-
-    /** Number of evictions. */
-    private AtomicLong evictCnt = new AtomicLong();
-
-    /** Number of removed entries. */
-    private AtomicLong rmCnt = new AtomicLong();
-
-    /** Put time taken nanos. */
-    private AtomicLong putTimeNanos = new AtomicLong();
-
-    /** Get time taken nanos. */
-    private AtomicLong getTimeNanos = new AtomicLong();
-
-    /** Remove time taken nanos. */
-    private AtomicLong removeTimeNanos = new AtomicLong();
-
-    /** Commit transaction time taken nanos. */
-    private AtomicLong commitTimeNanos = new AtomicLong();
-
-    /** Commit transaction time taken nanos. */
-    private AtomicLong rollbackTimeNanos = new AtomicLong();
-
-    /** Cache metrics. */
-    @GridToStringExclude
-    private transient CacheMetricsAdapter delegate;
-
-    /** Cache context. */
-    private GridCacheContext<?, ?> cctx;
-
-    /** DHT context. */
-    private GridCacheContext<?, ?> dhtCtx;
-
-    /** Write-behind store, if configured. */
-    private GridCacheWriteBehindStore store;
-
-    /**
-     * Creates cache metrics;
-     *
-     * @param cctx Cache context.
-     */
-    public CacheMetricsAdapter(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();
-
-        delegate = null;
-    }
-
-    /**
-     * @param delegate Metrics to delegate to.
-     */
-    public void delegate(CacheMetricsAdapter delegate) {
-        this.delegate = delegate;
-    }
-
-
-    /** {@inheritDoc} */
-    @Override public String name() {
-        return cctx.name();
-    }
-
-    /** {@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 != null ? dhtCtx.evicts().evictQueueSize() : -1
-                : 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 != null ? dhtCtx.tm().threadMapSize() : 
-1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtXidMapSize() {
-        return cctx.isNear() && dhtCtx != null ? dhtCtx.tm().idMapSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtCommitQueueSize() {
-        return cctx.isNear() && dhtCtx != null ? dhtCtx.tm().commitQueueSize() 
: -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtPrepareQueueSize() {
-        return cctx.isNear() && dhtCtx != null ? 
dhtCtx.tm().prepareQueueSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtStartVersionCountsSize() {
-        return cctx.isNear() && dhtCtx != null ? 
dhtCtx.tm().startVersionCountsSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtCommittedVersionsSize() {
-        return cctx.isNear() && dhtCtx != null ? 
dhtCtx.tm().committedVersionsSize() : -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getTxDhtRolledbackVersionsSize() {
-        return cctx.isNear() && dhtCtx != null ? 
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 float getAverageTxCommitTime() {
-        long timeNanos = commitTimeNanos.get();
-        long commitsCnt = txCommits.get();
-
-        if (timeNanos == 0 || commitsCnt == 0)
-            return 0;
-
-        return ((1f * timeNanos) / commitsCnt) / NANOS_IN_MICROSECOND;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageTxRollbackTime() {
-        long timeNanos = rollbackTimeNanos.get();
-        long rollbacksCnt = txRollbacks.get();
-
-        if (timeNanos == 0 || rollbacksCnt == 0)
-            return 0;
-
-        return ((1f * timeNanos) / rollbacksCnt) / NANOS_IN_MICROSECOND;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheTxCommits() {
-        return txCommits.get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheTxRollbacks() {
-        return txRollbacks.get();
-    }
-
-    /**
-     * Clear metrics.
-     */
-    public void clear() {
-        reads.set(0);
-        writes.set(0);
-        rmCnt.set(0);
-        hits.set(0);
-        misses.set(0);
-        evictCnt.set(0);
-        txCommits.set(0);
-        txRollbacks.set(0);
-        putTimeNanos.set(0);
-        removeTimeNanos.set(0);
-        getTimeNanos.set(0);
-        commitTimeNanos.set(0);
-        rollbackTimeNanos.set(0);
-
-        if (delegate != null)
-            delegate.clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheHits() {
-        return hits.get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getCacheHitPercentage() {
-        long hits0 = hits.get();
-        long gets0 = reads.get();
-
-        if (hits0 == 0)
-            return 0;
-
-        return (float) hits0 / gets0 * 100.0f;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheMisses() {
-        return misses.get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getCacheMissPercentage() {
-        long misses0 = misses.get();
-        long reads0 = reads.get();
-
-        if (misses0 == 0) {
-            return 0;
-        }
-
-        return (float) misses0 / reads0 * 100.0f;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheGets() {
-        return reads.get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCachePuts() {
-        return writes.get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheRemovals() {
-        return rmCnt.get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheEvictions() {
-        return evictCnt.get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageGetTime() {
-        long timeNanos = getTimeNanos.get();
-        long readsCnt = reads.get();
-
-        if (timeNanos == 0 || readsCnt == 0)
-            return 0;
-
-        return ((1f * timeNanos) / readsCnt) / NANOS_IN_MICROSECOND;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAveragePutTime() {
-        long timeNanos = putTimeNanos.get();
-        long putsCnt = writes.get();
-
-        if (timeNanos == 0 || putsCnt == 0)
-            return 0;
-
-        return ((1f * timeNanos) / putsCnt) / NANOS_IN_MICROSECOND;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageRemoveTime() {
-        long timeNanos = removeTimeNanos.get();
-        long removesCnt = rmCnt.get();
-
-        if (timeNanos == 0 || removesCnt == 0)
-            return 0;
-
-        return ((1f * timeNanos) / removesCnt) / NANOS_IN_MICROSECOND;
-    }
-
-    /**
-     * Cache read callback.
-     * @param isHit Hit or miss flag.
-     */
-    public void onRead(boolean isHit) {
-        reads.incrementAndGet();
-
-        if (isHit)
-            hits.incrementAndGet();
-        else
-            misses.incrementAndGet();
-
-        if (delegate != null)
-            delegate.onRead(isHit);
-    }
-
-    /**
-     * Cache write callback.
-     */
-    public void onWrite() {
-        writes.incrementAndGet();
-
-        if (delegate != null)
-            delegate.onWrite();
-    }
-
-    /**
-     * Cache remove callback.
-     */
-    public void onRemove(){
-        rmCnt.incrementAndGet();
-
-        if (delegate != null)
-            delegate.onRemove();
-    }
-
-    /**
-     * Cache remove callback.
-     */
-    public void onEvict() {
-        evictCnt.incrementAndGet();
-
-        if (delegate != null)
-            delegate.onEvict();
-    }
-
-    /**
-     * Transaction commit callback.
-     */
-    public void onTxCommit(long duration) {
-        txCommits.incrementAndGet();
-        commitTimeNanos.addAndGet(duration);
-
-        if (delegate != null) {
-            delegate.onTxCommit(duration);
-        }
-    }
-
-    /**
-     * Transaction rollback callback.
-     */
-    public void onTxRollback(long duration) {
-        txRollbacks.incrementAndGet();
-        rollbackTimeNanos.addAndGet(duration);
-
-        if (delegate != null)
-            delegate.onTxRollback(duration);
-    }
-
-
-    /**
-     * Increments the get time accumulator.
-     *
-     * @param duration the time taken in nanoseconds.
-     */
-    public void addGetTimeNanos(long duration) {
-        getTimeNanos.addAndGet(duration);
-
-        if (delegate != null)
-            delegate.addGetTimeNanos(duration);
-    }
-
-    /**
-     * Increments the put time accumulator.
-     *
-     * @param duration the time taken in nanoseconds.
-     */
-    public void addPutTimeNanos(long duration) {
-        putTimeNanos.addAndGet(duration);
-
-        if (delegate != null)
-            delegate.addPutTimeNanos(duration);
-    }
-
-    /**
-     * Increments the remove time accumulator.
-     *
-     * @param duration the time taken in nanoseconds.
-     */
-    public void addRemoveTimeNanos(long duration) {
-        removeTimeNanos.addAndGet(duration);
-
-        if (delegate != null)
-            delegate.addRemoveTimeNanos(duration);
-    }
-
-    /**
-     * Increments remove and get time accumulators.
-     *
-     * @param duration the time taken in nanoseconds.
-     */
-    public void addRemoveAndGetTimeNanos(long duration) {
-        removeTimeNanos.addAndGet(duration);
-        getTimeNanos.addAndGet(duration);
-
-        if (delegate != null)
-            delegate.addRemoveAndGetTimeNanos(duration);
-    }
-
-    /**
-     * Increments put and get time accumulators.
-     *
-     * @param duration the time taken in nanoseconds.
-     */
-    public void addPutAndGetTimeNanos(long duration) {
-        putTimeNanos.addAndGet(duration);
-        getTimeNanos.addAndGet(duration);
-
-        if (delegate != null)
-            delegate.addPutAndGetTimeNanos(duration);
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(CacheMetricsAdapter.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/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
new file mode 100644
index 0000000..2df1400
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
@@ -0,0 +1,587 @@
+/*
+ * 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.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.internal.util.tostring.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+
+import javax.cache.configuration.CompleteConfiguration;
+import java.util.concurrent.atomic.*;
+
+/**
+ * Adapter for cache metrics.
+ */
+public class CacheMetricsImpl implements CacheMetrics {
+    /** */
+    private static final long NANOS_IN_MICROSECOND = 1000L;
+
+    /** Number of reads. */
+    private AtomicLong reads = new AtomicLong();
+
+    /** Number of writes. */
+    private AtomicLong writes = new AtomicLong();
+
+    /** Number of hits. */
+    private AtomicLong hits = new AtomicLong();
+
+    /** Number of misses. */
+    private AtomicLong misses = new AtomicLong();
+
+    /** Number of transaction commits. */
+    private AtomicLong txCommits = new AtomicLong();
+
+    /** Number of transaction rollbacks. */
+    private AtomicLong txRollbacks = new AtomicLong();
+
+    /** Number of evictions. */
+    private AtomicLong evictCnt = new AtomicLong();
+
+    /** Number of removed entries. */
+    private AtomicLong rmCnt = new AtomicLong();
+
+    /** Put time taken nanos. */
+    private AtomicLong putTimeNanos = new AtomicLong();
+
+    /** Get time taken nanos. */
+    private AtomicLong getTimeNanos = new AtomicLong();
+
+    /** Remove time taken nanos. */
+    private AtomicLong removeTimeNanos = new AtomicLong();
+
+    /** Commit transaction time taken nanos. */
+    private AtomicLong commitTimeNanos = new AtomicLong();
+
+    /** Commit transaction time taken nanos. */
+    private AtomicLong rollbackTimeNanos = new AtomicLong();
+
+    /** Cache metrics. */
+    @GridToStringExclude
+    private transient CacheMetricsImpl delegate;
+
+    /** Cache context. */
+    private GridCacheContext<?, ?> cctx;
+
+    /** DHT context. */
+    private GridCacheContext<?, ?> dhtCtx;
+
+    /** Write-behind store, if configured. */
+    private GridCacheWriteBehindStore store;
+
+    /**
+     * Creates cache metrics;
+     *
+     * @param cctx Cache context.
+     */
+    public CacheMetricsImpl(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();
+
+        delegate = null;
+    }
+
+    /**
+     * @param delegate Metrics to delegate to.
+     */
+    public void delegate(CacheMetricsImpl delegate) {
+        this.delegate = delegate;
+    }
+
+
+    /** {@inheritDoc} */
+    @Override public String name() {
+        return cctx.name();
+    }
+
+    /** {@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 != null ? dhtCtx.evicts().evictQueueSize() : -1
+                : 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 != null ? dhtCtx.tm().threadMapSize() : 
-1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtXidMapSize() {
+        return cctx.isNear() && dhtCtx != null ? dhtCtx.tm().idMapSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtCommitQueueSize() {
+        return cctx.isNear() && dhtCtx != null ? dhtCtx.tm().commitQueueSize() 
: -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtPrepareQueueSize() {
+        return cctx.isNear() && dhtCtx != null ? 
dhtCtx.tm().prepareQueueSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtStartVersionCountsSize() {
+        return cctx.isNear() && dhtCtx != null ? 
dhtCtx.tm().startVersionCountsSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtCommittedVersionsSize() {
+        return cctx.isNear() && dhtCtx != null ? 
dhtCtx.tm().committedVersionsSize() : -1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getTxDhtRolledbackVersionsSize() {
+        return cctx.isNear() && dhtCtx != null ? 
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 float getAverageTxCommitTime() {
+        long timeNanos = commitTimeNanos.get();
+        long commitsCnt = txCommits.get();
+
+        if (timeNanos == 0 || commitsCnt == 0)
+            return 0;
+
+        return ((1f * timeNanos) / commitsCnt) / NANOS_IN_MICROSECOND;
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageTxRollbackTime() {
+        long timeNanos = rollbackTimeNanos.get();
+        long rollbacksCnt = txRollbacks.get();
+
+        if (timeNanos == 0 || rollbacksCnt == 0)
+            return 0;
+
+        return ((1f * timeNanos) / rollbacksCnt) / NANOS_IN_MICROSECOND;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheTxCommits() {
+        return txCommits.get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheTxRollbacks() {
+        return txRollbacks.get();
+    }
+
+    /**
+     * Clear metrics.
+     */
+    public void clear() {
+        reads.set(0);
+        writes.set(0);
+        rmCnt.set(0);
+        hits.set(0);
+        misses.set(0);
+        evictCnt.set(0);
+        txCommits.set(0);
+        txRollbacks.set(0);
+        putTimeNanos.set(0);
+        removeTimeNanos.set(0);
+        getTimeNanos.set(0);
+        commitTimeNanos.set(0);
+        rollbackTimeNanos.set(0);
+
+        if (delegate != null)
+            delegate.clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheHits() {
+        return hits.get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getCacheHitPercentage() {
+        long hits0 = hits.get();
+        long gets0 = reads.get();
+
+        if (hits0 == 0)
+            return 0;
+
+        return (float) hits0 / gets0 * 100.0f;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheMisses() {
+        return misses.get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getCacheMissPercentage() {
+        long misses0 = misses.get();
+        long reads0 = reads.get();
+
+        if (misses0 == 0) {
+            return 0;
+        }
+
+        return (float) misses0 / reads0 * 100.0f;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheGets() {
+        return reads.get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCachePuts() {
+        return writes.get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheRemovals() {
+        return rmCnt.get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCacheEvictions() {
+        return evictCnt.get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageGetTime() {
+        long timeNanos = getTimeNanos.get();
+        long readsCnt = reads.get();
+
+        if (timeNanos == 0 || readsCnt == 0)
+            return 0;
+
+        return ((1f * timeNanos) / readsCnt) / NANOS_IN_MICROSECOND;
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAveragePutTime() {
+        long timeNanos = putTimeNanos.get();
+        long putsCnt = writes.get();
+
+        if (timeNanos == 0 || putsCnt == 0)
+            return 0;
+
+        return ((1f * timeNanos) / putsCnt) / NANOS_IN_MICROSECOND;
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getAverageRemoveTime() {
+        long timeNanos = removeTimeNanos.get();
+        long removesCnt = rmCnt.get();
+
+        if (timeNanos == 0 || removesCnt == 0)
+            return 0;
+
+        return ((1f * timeNanos) / removesCnt) / NANOS_IN_MICROSECOND;
+    }
+
+    /**
+     * Cache read callback.
+     * @param isHit Hit or miss flag.
+     */
+    public void onRead(boolean isHit) {
+        reads.incrementAndGet();
+
+        if (isHit)
+            hits.incrementAndGet();
+        else
+            misses.incrementAndGet();
+
+        if (delegate != null)
+            delegate.onRead(isHit);
+    }
+
+    /**
+     * Cache write callback.
+     */
+    public void onWrite() {
+        writes.incrementAndGet();
+
+        if (delegate != null)
+            delegate.onWrite();
+    }
+
+    /**
+     * Cache remove callback.
+     */
+    public void onRemove(){
+        rmCnt.incrementAndGet();
+
+        if (delegate != null)
+            delegate.onRemove();
+    }
+
+    /**
+     * Cache remove callback.
+     */
+    public void onEvict() {
+        evictCnt.incrementAndGet();
+
+        if (delegate != null)
+            delegate.onEvict();
+    }
+
+    /**
+     * Transaction commit callback.
+     */
+    public void onTxCommit(long duration) {
+        txCommits.incrementAndGet();
+        commitTimeNanos.addAndGet(duration);
+
+        if (delegate != null) {
+            delegate.onTxCommit(duration);
+        }
+    }
+
+    /**
+     * Transaction rollback callback.
+     */
+    public void onTxRollback(long duration) {
+        txRollbacks.incrementAndGet();
+        rollbackTimeNanos.addAndGet(duration);
+
+        if (delegate != null)
+            delegate.onTxRollback(duration);
+    }
+
+
+    /**
+     * Increments the get time accumulator.
+     *
+     * @param duration the time taken in nanoseconds.
+     */
+    public void addGetTimeNanos(long duration) {
+        getTimeNanos.addAndGet(duration);
+
+        if (delegate != null)
+            delegate.addGetTimeNanos(duration);
+    }
+
+    /**
+     * Increments the put time accumulator.
+     *
+     * @param duration the time taken in nanoseconds.
+     */
+    public void addPutTimeNanos(long duration) {
+        putTimeNanos.addAndGet(duration);
+
+        if (delegate != null)
+            delegate.addPutTimeNanos(duration);
+    }
+
+    /**
+     * Increments the remove time accumulator.
+     *
+     * @param duration the time taken in nanoseconds.
+     */
+    public void addRemoveTimeNanos(long duration) {
+        removeTimeNanos.addAndGet(duration);
+
+        if (delegate != null)
+            delegate.addRemoveTimeNanos(duration);
+    }
+
+    /**
+     * Increments remove and get time accumulators.
+     *
+     * @param duration the time taken in nanoseconds.
+     */
+    public void addRemoveAndGetTimeNanos(long duration) {
+        removeTimeNanos.addAndGet(duration);
+        getTimeNanos.addAndGet(duration);
+
+        if (delegate != null)
+            delegate.addRemoveAndGetTimeNanos(duration);
+    }
+
+    /**
+     * Increments put and get time accumulators.
+     *
+     * @param duration the time taken in nanoseconds.
+     */
+    public void addPutAndGetTimeNanos(long duration) {
+        putTimeNanos.addAndGet(duration);
+        getTimeNanos.addAndGet(duration);
+
+        if (delegate != null)
+            delegate.addPutAndGetTimeNanos(duration);
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getKeyType() {
+        return cctx.config().getKeyType().getName();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getValueType() {
+        return cctx.config().getValueType().getName();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isReadThrough() {
+        return cctx.config().isReadThrough();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isWriteThrough() {
+        return cctx.config().isWriteThrough();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isStoreByValue() {
+        return cctx.config().isStoreByValue();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isStatisticsEnabled() {
+        return cctx.config().isStatisticsEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isManagementEnabled() {
+        return cctx.config().isManagementEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(CacheMetricsImpl.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsMXBeanImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsMXBeanImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsMXBeanImpl.java
index 1a8e893..e9d547c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsMXBeanImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsMXBeanImpl.java
@@ -272,4 +272,39 @@ class CacheMetricsMXBeanImpl implements CacheMetricsMXBean 
{
     @Override public long getCacheTxRollbacks() {
         return cache.metrics0().getCacheTxRollbacks();
     }
+
+    /** {@inheritDoc} */
+    @Override public String getKeyType() {
+        return cache.metrics0().getKeyType();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getValueType() {
+        return cache.metrics0().getValueType();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isStoreByValue() {
+        return cache.metrics0().isStoreByValue();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isStatisticsEnabled() {
+        return cache.metrics0().isStatisticsEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isManagementEnabled() {
+        return cache.metrics0().isManagementEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isReadThrough() {
+        return cache.metrics0().isReadThrough();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isWriteThrough() {
+        return cache.metrics0().isWriteThrough();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
index 23c757c..0391f4e 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
@@ -20,15 +20,10 @@ package org.apache.ignite.internal.processors.cache;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
-import java.io.*;
-
 /**
  * Metrics snapshot.
  */
-class CacheMetricsSnapshot implements CacheMetrics, Externalizable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
+class CacheMetricsSnapshot implements CacheMetrics {
     /** Number of reads. */
     private long reads = 0;
 
@@ -161,6 +156,27 @@ class CacheMetricsSnapshot implements CacheMetrics, 
Externalizable {
     /** Total count of entries in cache store internal buffer. */
     private int writeBehindBufferSize;
 
+    /** */
+    private String keyType;
+
+    /** */
+    private String valueType;
+
+    /** */
+    private boolean isStoreByValue;
+
+    /** */
+    private boolean isStatisticsEnabled;
+
+    /** */
+    private boolean isManagementEnabled;
+
+    /** */
+    private boolean isReadThrough;
+
+    /** */
+    private boolean isWriteThrough;
+
     /**
      * Create snapshot for given metrics.
      *
@@ -213,6 +229,14 @@ class CacheMetricsSnapshot implements CacheMetrics, 
Externalizable {
         writeBehindCriticalOverflowCount = 
m.getWriteBehindCriticalOverflowCount();
         writeBehindErrorRetryCount = m.getWriteBehindErrorRetryCount();
         writeBehindBufferSize = m.getWriteBehindBufferSize();
+
+        keyType = m.getKeyType();
+        valueType = m.getValueType();
+        isStoreByValue = m.isStoreByValue();
+        isStatisticsEnabled = m.isStatisticsEnabled();
+        isManagementEnabled = m.isManagementEnabled();
+        isReadThrough = m.isReadThrough();
+        isWriteThrough = m.isWriteThrough();
     }
 
     /** {@inheritDoc} */
@@ -453,103 +477,38 @@ class CacheMetricsSnapshot implements CacheMetrics, 
Externalizable {
     }
 
     /** {@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);
-
-        out.writeObject(cacheName);
-        out.writeLong(overflowSize);
-        out.writeLong(offHeapEntriesCount);
-        out.writeLong(offHeapAllocatedSize);
-        out.writeInt(size);
-        out.writeInt(keySize);
-        out.writeBoolean(isEmpty);
-        out.writeInt(dhtEvictQueueCurrentSize);
-        out.writeInt(txThreadMapSize);
-        out.writeInt(txXidMapSize);
-        out.writeInt(txCommitQueueSize);
-        out.writeInt(txPrepareQueueSize);
-        out.writeInt(txStartVersionCountsSize);
-        out.writeInt(txCommittedVersionsSize);
-        out.writeInt(txRolledbackVersionsSize);
-        out.writeInt(txDhtThreadMapSize);
-        out.writeInt(txDhtXidMapSize);
-        out.writeInt(txDhtCommitQueueSize);
-        out.writeInt(txDhtPrepareQueueSize);
-        out.writeInt(txDhtStartVersionCountsSize);
-        out.writeInt(txDhtCommittedVersionsSize);
-        out.writeInt(txDhtRolledbackVersionsSize);
-        out.writeBoolean(isWriteBehindEnabled);
-        out.writeInt(writeBehindFlushSize);
-        out.writeInt(writeBehindFlushThreadCount);
-        out.writeLong(writeBehindFlushFrequency);
-        out.writeInt(writeBehindStoreBatchSize);
-        out.writeInt(writeBehindTotalCriticalOverflowCount);
-        out.writeInt(writeBehindCriticalOverflowCount);
-        out.writeInt(writeBehindErrorRetryCount);
-        out.writeInt(writeBehindBufferSize);
-    }
-
-    /** {@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();
-
-        cacheName = (String)in.readObject();
-        overflowSize = in.readLong();
-        offHeapEntriesCount = in.readLong();
-        offHeapAllocatedSize = in.readLong();
-        size = in.readInt();
-        keySize = in.readInt();
-        isEmpty = in.readBoolean();
-        dhtEvictQueueCurrentSize = in.readInt();
-        txThreadMapSize = in.readInt();
-        txXidMapSize = in.readInt();
-        txCommitQueueSize = in.readInt();
-        txPrepareQueueSize = in.readInt();
-        txStartVersionCountsSize = in.readInt();
-        txCommittedVersionsSize = in.readInt();
-        txRolledbackVersionsSize = in.readInt();
-        txDhtThreadMapSize = in.readInt();
-        txDhtXidMapSize = in.readInt();
-        txDhtCommitQueueSize = in.readInt();
-        txDhtPrepareQueueSize = in.readInt();
-        txDhtStartVersionCountsSize = in.readInt();
-        txDhtCommittedVersionsSize = in.readInt();
-        txDhtRolledbackVersionsSize = in.readInt();
-        isWriteBehindEnabled = in.readBoolean();
-        writeBehindFlushSize = in.readInt();
-        writeBehindFlushThreadCount = in.readInt();
-        writeBehindFlushFrequency = in.readLong();
-        writeBehindStoreBatchSize = in.readInt();
-        writeBehindTotalCriticalOverflowCount = in.readInt();
-        writeBehindCriticalOverflowCount = in.readInt();
-        writeBehindErrorRetryCount = in.readInt();
-        writeBehindBufferSize = in.readInt();
+    @Override public String getKeyType() {
+        return keyType;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getValueType() {
+        return valueType;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isStoreByValue() {
+        return isStoreByValue;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isStatisticsEnabled() {
+        return isStatisticsEnabled;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isManagementEnabled() {
+        return isManagementEnabled;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isReadThrough() {
+        return isReadThrough;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isWriteThrough() {
+        return isWriteThrough;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 6cb5857..9271e29 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -147,7 +147,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
     protected IgniteConfiguration gridCfg;
 
     /** Cache metrics. */
-    protected CacheMetricsAdapter metrics;
+    protected CacheMetricsImpl metrics;
 
     /** Cache mxBean. */
     protected CacheMetricsMXBean mxBean;
@@ -229,7 +229,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
 
         log = ctx.gridConfig().getGridLogger().getLogger(getClass());
 
-        metrics = new CacheMetricsAdapter(ctx);
+        metrics = new CacheMetricsImpl(ctx);
 
         mxBean = new CacheMetricsMXBeanImpl(this);
 
@@ -3424,7 +3424,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
     /**
      * @return Metrics.
      */
-    public CacheMetricsAdapter metrics0() {
+    public CacheMetricsImpl metrics0() {
         return metrics;
     }
 
@@ -5699,7 +5699,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
      */
     protected static abstract class UpdateTimeStatClosure<T> implements 
CI1<IgniteFuture<T>> {
         /** */
-        protected final CacheMetricsAdapter metrics;
+        protected final CacheMetricsImpl metrics;
 
         /** */
         protected final long start;
@@ -5708,7 +5708,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
          * @param metrics Metrics.
          * @param start   Start time.
          */
-        public UpdateTimeStatClosure(CacheMetricsAdapter metrics, long start) {
+        public UpdateTimeStatClosure(CacheMetricsImpl metrics, long start) {
             this.metrics = metrics;
             this.start = start;
         }
@@ -5741,7 +5741,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
          * @param metrics Metrics.
          * @param start   Start time.
          */
-        public UpdateGetTimeStatClosure(CacheMetricsAdapter metrics, long 
start) {
+        public UpdateGetTimeStatClosure(CacheMetricsImpl metrics, long start) {
             super(metrics, start);
         }
 
@@ -5759,7 +5759,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
          * @param metrics Metrics.
          * @param start   Start time.
          */
-        public UpdateRemoveTimeStatClosure(CacheMetricsAdapter metrics, long 
start) {
+        public UpdateRemoveTimeStatClosure(CacheMetricsImpl metrics, long 
start) {
             super(metrics, start);
         }
 
@@ -5777,7 +5777,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
          * @param metrics Metrics.
          * @param start   Start time.
          */
-        public UpdatePutTimeStatClosure(CacheMetricsAdapter metrics, long 
start) {
+        public UpdatePutTimeStatClosure(CacheMetricsImpl metrics, long start) {
             super(metrics, start);
         }
 
@@ -5795,7 +5795,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
          * @param metrics Metrics.
          * @param start   Start time.
          */
-        public UpdatePutAndGetTimeStatClosure(CacheMetricsAdapter metrics, 
long start) {
+        public UpdatePutAndGetTimeStatClosure(CacheMetricsImpl metrics, long 
start) {
             super(metrics, start);
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f1a8f165/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCache.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCache.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCache.java
index becbf0c..f1c96a1 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCache.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCache.java
@@ -71,7 +71,7 @@ public class GridDhtCache<K, V> extends 
GridDhtTransactionalCacheAdapter<K, V> {
 
     /** {@inheritDoc} */
     @Override public void start() throws IgniteCheckedException {
-        CacheMetricsAdapter m = new CacheMetricsAdapter(ctx);
+        CacheMetricsImpl m = new CacheMetricsImpl(ctx);
 
         m.delegate(ctx.dht().near().metrics0());
 

Reply via email to