ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [18/22] incubator-ignite git commit: IGNITE-49 Changed Interface ClusterNodeMetric, removed resetMetric method from Cache interface.
Date Thu, 22 Jan 2015 13:20:27 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterLocalNodeMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterLocalNodeMetrics.java b/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterLocalNodeMetrics.java
deleted file mode 100644
index df3d37b..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterLocalNodeMetrics.java
+++ /dev/null
@@ -1,311 +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;
-
-import org.apache.ignite.cluster.*;
-import org.gridgain.grid.util.typedef.internal.*;
-
-/**
- * Local node metrics MBean.
- */
-public class ClusterLocalNodeMetrics implements ClusterNodeMetricsMBean {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Grid node. */
-    private final ClusterNode node;
-
-    /**
-     * @param node Node to manage.
-     */
-    public ClusterLocalNodeMetrics(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(ClusterLocalNodeMetrics.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterMetricsImpl.java b/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterMetricsImpl.java
index 5f6ac91..faf7896 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterMetricsImpl.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterMetricsImpl.java
@@ -260,7 +260,7 @@ class ClusterMetricsImpl implements ClusterMetrics {
         int size = nodes.size();
 
         for (ClusterNode node : nodes) {
-            ClusterNodeMetrics m = node.metrics();
+            ClusterNodeMetricsMBean m = node.metrics();
 
             minActJobs = min(minActJobs, m.getCurrentActiveJobs());
             maxActJobs = max(maxActJobs, m.getCurrentActiveJobs());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterNodeMetricsMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterNodeMetricsMBean.java b/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterNodeMetricsMBean.java
deleted file mode 100644
index dc6579b..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/ClusterNodeMetricsMBean.java
+++ /dev/null
@@ -1,29 +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;
-
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.mbean.*;
-
-/**
- * MBean for local node metrics.
- */
-@IgniteMBeanDescription("MBean that provides access to all local node metrics.")
-public interface ClusterNodeMetricsMBean extends ClusterNodeMetrics {
-    // No-op.
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java
index f54d1e5..7745019 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java
@@ -960,7 +960,7 @@ public class GridKernal extends ClusterGroupAdapter implements GridEx, IgniteMBe
 
                 @Override protected void safeRun() {
                     if (log.isInfoEnabled()) {
-                        ClusterNodeMetrics m = localNode().metrics();
+                        ClusterNodeMetricsMBean m = localNode().metrics();
 
                         double cpuLoadPct = m.getCurrentCpuLoad() * 100;
                         double avgCpuLoadPct = m.getAverageCpuLoad() * 100;
@@ -1446,7 +1446,7 @@ public class GridKernal extends ClusterGroupAdapter implements GridEx, IgniteMBe
 
     /** @throws IgniteCheckedException If registration failed. */
     private void registerLocalNodeMBean() throws IgniteCheckedException {
-        ClusterNodeMetricsMBean mbean = new ClusterLocalNodeMetrics(ctx.discovery().localNode());
+        ClusterNodeMetricsMBean mbean = ctx.discovery().localNode().metrics();
 
         try {
             locNodeMBean = U.registerMBean(

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/discovery/GridDiscoveryManager.java
index 79eb973..7b0c31b 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/discovery/GridDiscoveryManager.java
@@ -494,7 +494,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
             private final long startTime = U.currentTimeMillis();
 
             /** {@inheritDoc} */
-            @Override public ClusterNodeMetrics getMetrics() {
+            @Override public ClusterNodeMetricsMBean getMetrics() {
                 GridJobMetrics jm = ctx.jobMetric().getJobMetrics();
 
                 DiscoveryNodeMetricsAdapter nm = new DiscoveryNodeMetricsAdapter();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsMxBeanImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsMxBeanImpl.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsMxBeanImpl.java
new file mode 100644
index 0000000..c5c1b2b
--- /dev/null
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheMetricsMxBeanImpl.java
@@ -0,0 +1,405 @@
+/*
+ * 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.tostring.*;
+import org.gridgain.grid.util.typedef.internal.*;
+
+import javax.cache.management.CacheStatisticsMXBean;
+import java.io.*;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Adapter for cache metrics.
+ */
+public class CacheMetricsMxBeanImpl implements CacheMetricsMxBean, CacheStatisticsMXBean, Externalizable {
+    /** */
+    private static final long NANOS_IN_MICROSECOND = 1000L;
+
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** 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 CacheMetricsMxBeanImpl delegate;
+
+    /**
+     * No-args constructor.
+     */
+    public CacheMetricsMxBeanImpl() {
+        delegate = null;
+    }
+
+    /**
+     * @param delegate Metrics to delegate to.
+     */
+    public void delegate(CacheMetricsMxBeanImpl delegate) {
+        this.delegate = delegate;
+    }
+
+    /** {@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();
+    }
+
+    /** {@inheritDoc} */
+    @Override 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 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(CacheMetricsMxBeanImpl.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/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 ef6b8ba..311accd 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
@@ -146,7 +146,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
     protected IgniteConfiguration gridCfg;
 
     /** Cache metrics. */
-    protected volatile GridCacheMetricsAdapter metrics;
+    protected volatile CacheMetricsMxBeanImpl metrics;
 
     /** Logger. */
     protected IgniteLogger log;
@@ -225,7 +225,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
 
         log = ctx.gridConfig().getGridLogger().getLogger(getClass());
 
-        metrics = new GridCacheMetricsAdapter();
+        metrics = new CacheMetricsMxBeanImpl();
 
         IgniteFsConfiguration[] ggfsCfgs = gridCfg.getGgfsConfiguration();
 
@@ -1677,7 +1677,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
             val = (V)ctx.config().getInterceptor().onGet(key, val);
 
         if (statsEnabled)
-            ctx.cache().metrics0().addGetTimeNanos(System.nanoTime() - start);
+            metrics0().addGetTimeNanos(System.nanoTime() - start);
 
         return val;
     }
@@ -1698,20 +1698,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
             });
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<V>>() {
-                @Override public void apply(IgniteFuture<V> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addGetTimeNanos(System.nanoTime() - start);
-                        }
-                    }
-                    catch (IgniteCheckedException ignore){
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdateGetTimeStatClosure<V>(metrics0(), start));
 
         return fut;
     }
@@ -1728,7 +1715,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
             map = interceptGet(keys, map);
 
         if (statsEnabled)
-            ctx.cache().metrics0().addGetTimeNanos(System.nanoTime() - start);
+            metrics0().addGetTimeNanos(System.nanoTime() - start);
 
         return map;
     }
@@ -1749,7 +1736,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
             });
 
         if (statsEnabled)
-            fut.listenAsync(new UpdateGetTimeMetricsClosure<Map<K, V>>(ctx.cache().metrics0(), start));
+            fut.listenAsync(new UpdateGetTimeStatClosure<Map<K, V>>(metrics0(), start));
 
         return fut;
     }
@@ -2139,7 +2126,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         }));
 
         if (statsEnabled)
-            ctx.cache().metrics0().addPutAndGetTimeNanos(System.nanoTime() - start);
+            metrics0().addPutAndGetTimeNanos(System.nanoTime() - start);
 
         return prevValue;
     }
@@ -2179,19 +2166,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         IgniteFuture<V> fut = putAsync(key, val, null, -1, filter);
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<V>>() {
-                @Override public void apply(IgniteFuture<V> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addPutAndGetTimeNanos(System.nanoTime() - start);
-                        }
-                    } catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdatePutAndGetTimeStatClosure<V>(metrics0(), start));
 
         return fut;
     }
@@ -2251,7 +2226,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         });
 
         if (statsEnabled)
-            ctx.cache().metrics0().addPutTimeNanos(System.nanoTime() - start);
+            metrics0().addPutTimeNanos(System.nanoTime() - start);
 
         return stored;
     }
@@ -2516,20 +2491,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         IgniteFuture<Boolean> fut = putxAsync(key, val, null, -1, filter);
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<Boolean>>() {
-                @Override public void apply(IgniteFuture<Boolean> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addPutTimeNanos(System.nanoTime() - start);
-                        }
-                    }
-                    catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdatePutTimeStatClosure<Boolean>(metrics0(), start));
 
         return fut;
     }
@@ -2608,20 +2570,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         }));
 
         if(statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<V>>() {
-                @Override public void apply(IgniteFuture<V> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addPutTimeNanos(System.nanoTime() - start);
-                        }
-                    }
-                    catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdatePutTimeStatClosure<V>(metrics0(), start));
 
         return fut;
     }
@@ -2652,7 +2601,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         });
 
         if (statsEnabled && stored)
-            ctx.cache().metrics0().addPutTimeNanos(System.nanoTime() - start);
+            metrics0().addPutTimeNanos(System.nanoTime() - start);
 
         return stored;
     }
@@ -2684,19 +2633,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         });
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<Boolean>>() {
-                @Override public void apply(IgniteFuture<Boolean> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addPutTimeNanos(System.nanoTime() - start);
-                        }
-                    } catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdatePutTimeStatClosure<Boolean>(metrics0(), start));
 
         return fut;
     }
@@ -2751,20 +2688,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         }));
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<V>>() {
-                @Override public void apply(IgniteFuture<V> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addPutAndGetTimeNanos(System.nanoTime() - start);
-                        }
-                    }
-                    catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdatePutAndGetTimeStatClosure<V>(metrics0(), start));
 
         return fut;
     }
@@ -2882,20 +2806,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         });
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<Boolean>>() {
-                @Override public void apply(IgniteFuture<Boolean> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addPutAndGetTimeNanos(System.nanoTime() - start);
-                        }
-                    }
-                    catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdatePutAndGetTimeStatClosure<Boolean>(metrics0(), start));
 
         return fut;
     }
@@ -2928,7 +2839,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         });
 
         if (statsEnabled)
-            ctx.cache().metrics0().addPutTimeNanos(System.nanoTime() - start);
+            metrics0().addPutTimeNanos(System.nanoTime() - start);
     }
 
     /** {@inheritDoc} */
@@ -2991,7 +2902,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         }));
 
         if (statsEnabled)
-            ctx.cache().metrics0().addRemoveAndGetTimeNanos(System.nanoTime() - start);
+            metrics0().addRemoveAndGetTimeNanos(System.nanoTime() - start);
 
         return prevVal;
     }
@@ -3005,21 +2916,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         IgniteFuture<V> fut = removeAsync(key, null, filter);
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<V>>() {
-                @Override public void apply(IgniteFuture<V> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
-                        }
-                    }
-                    catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-
-                }
-            });
+            fut.listenAsync(new UpdateRemoveTimeStatClosure<V>(metrics0(), start));
 
         return fut;
     }
@@ -3051,20 +2948,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         }));
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<V>>() {
-                @Override public void apply(IgniteFuture<V> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
-                        }
-                    }
-                    catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdateRemoveTimeStatClosure<V>(metrics0(), start));
 
         return fut;
     }
@@ -3106,7 +2990,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         });
 
         if (statsEnabled)
-            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
+            metrics0().addRemoveTimeNanos(System.nanoTime() - start);
     }
 
     /** {@inheritDoc} */
@@ -3135,19 +3019,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         });
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<Object>>() {
-                @Override public void apply(IgniteFuture<Object> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
-                        }
-                    } catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdateRemoveTimeStatClosure<>(metrics0(), start));
 
         return fut;
     }
@@ -3162,7 +3034,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         boolean removed = removex(key, null, filter);
 
         if (statsEnabled && removed)
-            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
+            metrics0().addRemoveTimeNanos(System.nanoTime() - start);
 
         return removed;
     }
@@ -3192,7 +3064,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         });
 
         if (statsEnabled && removed)
-            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
+            metrics0().addRemoveTimeNanos(System.nanoTime() - start);
 
         return removed;
     }
@@ -3228,19 +3100,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         });
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<Boolean>>() {
-                @Override public void apply(IgniteFuture<Boolean> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
-                        }
-                    } catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdateRemoveTimeStatClosure<Boolean>(metrics0(), start));
 
         return fut;
     }
@@ -3430,7 +3290,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         });
 
         if (statsEnabled && removed)
-            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
+            metrics0().addRemoveTimeNanos(System.nanoTime() - start);
 
         return removed;
     }
@@ -3484,20 +3344,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
         });
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<Boolean>>() {
-                @Override public void apply(IgniteFuture<Boolean> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
-                        }
-                    }
-                    catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdateRemoveTimeStatClosure<Boolean>(metrics0(), start));
 
         return fut;
     }
@@ -3547,7 +3394,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
     /**
      * @return Metrics.
      */
-    public GridCacheMetricsAdapter metrics0() {
+    public CacheMetricsMxBeanImpl metrics0() {
         return metrics;
     }
 
@@ -4389,11 +4236,6 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
     }
 
     /** {@inheritDoc} */
-    @Override public void resetMetrics() {
-        metrics = new GridCacheMetricsAdapter();
-    }
-
-    /** {@inheritDoc} */
     @Override public IgniteFuture<?> forceRepartition() {
         ctx.preloader().forcePreload();
 
@@ -5438,18 +5280,18 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
     /**
      *
      */
-    protected static class UpdateGetTimeMetricsClosure<T> implements CI1<IgniteFuture<T>> {
+    protected static abstract class UpdateTimeStatClosure<T> implements CI1<IgniteFuture<T>> {
         /** */
-        private final GridCacheMetricsAdapter metrics;
+        protected final CacheMetricsMxBeanImpl metrics;
 
         /** */
-        private final long start;
+        protected final long start;
 
         /**
          * @param metrics Metrics.
          * @param start   Start time.
          */
-        public UpdateGetTimeMetricsClosure(GridCacheMetricsAdapter metrics, long start) {
+        public UpdateTimeStatClosure(CacheMetricsMxBeanImpl metrics, long start) {
             this.metrics = metrics;
             this.start = start;
         }
@@ -5460,11 +5302,88 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter im
                 if (!fut.isCancelled()) {
                     fut.get();
 
-                    metrics.addGetTimeNanos(System.nanoTime() - start);
+                    updateTimeStat();
                 }
             } catch (IgniteCheckedException ignore) {
                 //No-op.
             }
         }
+
+        /**
+         * Updates statistics.
+         */
+        abstract protected void updateTimeStat();
+    }
+
+    /**
+     *
+     */
+    protected static class UpdateGetTimeStatClosure<T> extends UpdateTimeStatClosure<T> {
+        /**
+         * @param metrics Metrics.
+         * @param start   Start time.
+         */
+        public UpdateGetTimeStatClosure(CacheMetricsMxBeanImpl metrics, long start) {
+            super(metrics, start);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected void updateTimeStat() {
+            metrics.addGetTimeNanos(System.nanoTime() - start);
+        }
+    }
+
+    /**
+     *
+     */
+    protected static class UpdateRemoveTimeStatClosure<T> extends UpdateTimeStatClosure<T> {
+        /**
+         * @param metrics Metrics.
+         * @param start   Start time.
+         */
+        public UpdateRemoveTimeStatClosure(CacheMetricsMxBeanImpl metrics, long start) {
+            super(metrics, start);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected void updateTimeStat() {
+            metrics.addRemoveTimeNanos(System.nanoTime() - start);
+        }
+    }
+
+    /**
+     *
+     */
+    protected static class UpdatePutTimeStatClosure<T> extends UpdateTimeStatClosure {
+        /**
+         * @param metrics Metrics.
+         * @param start   Start time.
+         */
+        public UpdatePutTimeStatClosure(CacheMetricsMxBeanImpl metrics, long start) {
+            super(metrics, start);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected void updateTimeStat() {
+            metrics.addPutTimeNanos(System.nanoTime() - start);
+        }
+    }
+
+    /**
+     *
+     */
+    protected static class UpdatePutAndGetTimeStatClosure<T> extends UpdateTimeStatClosure {
+        /**
+         * @param metrics Metrics.
+         * @param start   Start time.
+         */
+        public UpdatePutAndGetTimeStatClosure(CacheMetricsMxBeanImpl metrics, long start) {
+            super(metrics, start);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected void updateTimeStat() {
+            metrics.addPutAndGetTimeNanos(System.nanoTime() - start);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMetricsAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMetricsAdapter.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMetricsAdapter.java
deleted file mode 100644
index e4c106b..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMetricsAdapter.java
+++ /dev/null
@@ -1,426 +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.gridgain.grid.cache.*;
-import org.gridgain.grid.util.tostring.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-import java.io.*;
-
-/**
- * Adapter for cache metrics.
- */
-public class GridCacheMetricsAdapter implements CacheMetricsMxBean, Externalizable {
-    /** */
-    private static final long NANOS_IN_MICROSECOND = 1000L;
-
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Number of reads. */
-    private volatile int reads;
-
-    /** Number of writes. */
-    private volatile int writes;
-
-    /** Number of hits. */
-    private volatile int hits;
-
-    /** Number of misses. */
-    private volatile int misses;
-
-    /** Number of transaction commits. */
-    private volatile int txCommits;
-
-    /** Number of transaction rollbacks. */
-    private volatile int txRollbacks;
-
-    /** Number of evictions. */
-    private volatile long evictCnt;
-
-    /** Number of removed entries. */
-    private volatile long rmCnt;
-
-    /** Put time taken nanos. */
-    private volatile long putTimeNanos;
-
-    /** Get time taken nanos. */
-    private volatile long getTimeNanos;
-
-    /** Remove time taken nanos. */
-    private volatile long removeTimeNanos;
-
-    /** Cache metrics. */
-    @GridToStringExclude
-    private transient GridCacheMetricsAdapter delegate;
-
-    /**
-     * No-args constructor.
-     */
-    public GridCacheMetricsAdapter() {
-        delegate = null;
-    }
-
-    /**
-     * @param m Metrics to copy from.
-     */
-    public GridCacheMetricsAdapter(GridCacheMetricsAdapter m) {
-        reads = m.reads;
-        writes = m.writes;
-        hits = m.hits;
-        misses = m.misses;
-        txCommits = m.txCommits;
-        txRollbacks = m.txRollbacks;
-        rmCnt = m.rmCnt;
-        evictCnt = m.evictCnt;
-        getTimeNanos = m.getTimeNanos;
-        putTimeNanos = m.putTimeNanos;
-        removeTimeNanos = m.removeTimeNanos;
-    }
-
-    /**
-     * @param delegate Metrics to delegate to.
-     */
-    public void delegate(GridCacheMetricsAdapter delegate) {
-        this.delegate = delegate;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageTxCommitTime() {
-        return 1.f;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageTxRollbackTime() {
-        return 1.f;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getCacheTxCommits() {
-        return txCommits;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getCacheTxRollbacks() {
-        return txRollbacks;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear() {
-        reads = 0;
-        writes = 0;
-        hits = 0;
-        misses = 0;
-        txCommits = 0;
-        txRollbacks = 0;
-
-        putTimeNanos = 0;
-        removeTimeNanos = 0;
-        getTimeNanos = 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheHits() {
-        return hits;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getCacheHitPercentage() {
-        long hits0 = hits;
-
-        if (hits0 == 0)
-            return 0;
-
-        return (float) hits0 / getCacheGets() * 100.0f;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheMisses() {
-        return misses;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getCacheMissPercentage() {
-        long misses0 = misses;
-
-        if (misses0 == 0)
-            return 0;
-
-        return (float) misses0 / getCacheGets() * 100.0f;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheGets() {
-        return reads;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCachePuts() {
-        return writes;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheRemovals() {
-        return rmCnt;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCacheEvictions() {
-        return evictCnt;
-    }
-
-    /**
-     * Increments the get time accumulator.
-     *
-     * @param duration the time taken in nanoseconds.
-     */
-    public void addGetTimeNanos(long duration) {
-        getTimeNanos += 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 += 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 += 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 += duration;
-        getTimeNanos += 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 += duration;
-        getTimeNanos += duration;
-
-        if (delegate != null)
-            delegate.addPutAndGetTimeNanos(duration);
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageGetTime() {
-        long timeNanos = getTimeNanos;
-        long readsCnt = reads;
-
-        if (timeNanos == 0 || readsCnt == 0)
-            return 0;
-
-        return ((1f * timeNanos) / readsCnt) / NANOS_IN_MICROSECOND;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAveragePutTime() {
-        long timeNanos = putTimeNanos;
-        long putsCnt = writes;
-
-        if (timeNanos == 0 || putsCnt == 0)
-            return 0;
-
-        return ((1f * timeNanos) / putsCnt) / NANOS_IN_MICROSECOND;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAverageRemoveTime() {
-        long timeNanos = removeTimeNanos;
-        long removesCnt = rmCnt;
-
-        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++;
-
-        if (isHit)
-            hits++;
-        else
-            misses++;
-
-        if (delegate != null)
-            delegate.onRead(isHit);
-    }
-
-    /**
-     * Cache write callback.
-     */
-    public void onWrite() {
-        writes++;
-
-        if (delegate != null)
-            delegate.onWrite();
-    }
-
-    /**
-     * Cache remove callback.
-     */
-    public void onRemove(){
-        rmCnt++;
-
-        if (delegate != null)
-            delegate.onRemove();
-    }
-
-    /**
-     * Cache remove callback.
-     */
-    public void onEvict() {
-        evictCnt++;
-
-        if (delegate != null)
-            delegate.onEvict();
-    }
-
-    /**
-     * Transaction commit callback.
-     */
-    public void onTxCommit() {
-        txCommits++;
-
-        if (delegate != null)
-            delegate.onTxCommit();
-    }
-
-    /**
-     * Transaction rollback callback.
-     */
-    public void onTxRollback() {
-        txRollbacks++;
-
-        if (delegate != null)
-            delegate.onTxRollback();
-    }
-
-    /**
-     * Gets remove time.
-     *
-     * @return Remove time taken nanos.
-     */
-    public long removeTimeNanos() {
-        return removeTimeNanos;
-    }
-
-    /**
-     * Gets get time.
-     *
-     * @return Get time taken nanos.
-     */
-    public long getTimeNanos() {
-        return getTimeNanos;
-    }
-
-    /**
-     * Gets put time.
-     *
-     * @return Get time taken nanos.
-     */
-    public long putTimeNanos() {
-        return putTimeNanos;
-    }
-
-    /**
-     * Create a copy of given metrics object.
-     *
-     * @param m Metrics to copy from.
-     * @return Copy of given metrics.
-     */
-    @Nullable public static GridCacheMetricsAdapter copyOf(@Nullable GridCacheMetricsAdapter m) {
-        if (m == null)
-            return null;
-
-        return new GridCacheMetricsAdapter(m);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(reads);
-        out.writeInt(writes);
-        out.writeInt(hits);
-        out.writeInt(misses);
-        out.writeInt(txCommits);
-        out.writeInt(txRollbacks);
-        out.writeLong(rmCnt);
-        out.writeLong(evictCnt);
-
-        out.writeLong(putTimeNanos);
-        out.writeLong(getTimeNanos);
-        out.writeLong(removeTimeNanos);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        reads = in.readInt();
-        writes = in.readInt();
-        hits = in.readInt();
-        misses = in.readInt();
-        txCommits = in.readInt();
-        txRollbacks = in.readInt();
-        rmCnt = in.readLong();
-        evictCnt = in.readLong();
-
-        putTimeNanos = in.readLong();
-        getTimeNanos = in.readLong();
-        removeTimeNanos = in.readLong();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(GridCacheMetricsAdapter.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/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 0441549..5c3cc15 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
@@ -1866,18 +1866,6 @@ public class GridCacheProxyImpl<K, V> implements GridCacheProxy<K, V>, Externali
     }
 
     /** {@inheritDoc} */
-    @Override public void resetMetrics() {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            cache.resetMetrics();
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Nullable @Override public ExpiryPolicy expiry() {
         return delegate.expiry();
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtCache.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtCache.java
index e048efc..c3dbd18 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtCache.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtCache.java
@@ -71,20 +71,16 @@ public class GridDhtCache<K, V> extends GridDhtTransactionalCacheAdapter<K, V> {
 
     /** {@inheritDoc} */
     @Override public void start() throws IgniteCheckedException {
-        resetMetrics();
-
-        super.start();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void resetMetrics() {
-        GridCacheMetricsAdapter m = new GridCacheMetricsAdapter();
+        CacheMetricsMxBeanImpl m = new CacheMetricsMxBeanImpl();
 
         m.delegate(ctx.dht().near().metrics0());
 
         metrics = m;
 
         ctx.dr().resetMetrics();
+
+
+        super.start();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 87e43ca..f1e9c51 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -116,8 +116,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     @Override protected void init() {
         map.setEntryFactory(new GridCacheMapEntryFactory<K, V>() {
             /** {@inheritDoc} */
-            @Override public GridCacheMapEntry<K, V> create(GridCacheContext<K, V> ctx, long topVer, K key, int hash,
-                V val, GridCacheMapEntry<K, V> next, long ttl, int hdrId) {
+            @Override
+            public GridCacheMapEntry<K, V> create(GridCacheContext<K, V> ctx, long topVer, K key, int hash,
+                                                  V val, GridCacheMapEntry<K, V> next, long ttl, int hdrId) {
                 return new GridDhtAtomicCacheEntry<>(ctx, topVer, key, hash, val, next, ttl, hdrId);
             }
         });
@@ -154,7 +155,12 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     @Override public void start() throws IgniteCheckedException {
         super.start();
 
-        resetMetrics();
+        CacheMetricsMxBeanImpl m = new CacheMetricsMxBeanImpl();
+
+        if (ctx.dht().near() != null)
+            m.delegate(ctx.dht().near().metrics0());
+
+        metrics = m;
 
         preldr = new GridDhtPreloader<>(ctx);
 
@@ -212,18 +218,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         });
     }
 
-    /** {@inheritDoc} */
-    @Override public void resetMetrics() {
-        GridCacheMetricsAdapter m = new GridCacheMetricsAdapter();
-
-        if (ctx.dht().near() != null)
-            m.delegate(ctx.dht().near().metrics0());
-
-        metrics = m;
-
-        ctx.dr().resetMetrics();
-    }
-
     /**
      * @param near Near cache.
      */
@@ -826,21 +820,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             taskNameHash);
 
         if (statsEnabled) {
-            updateFut.listenAsync(new CI1<IgniteFuture<Object>>() {
-                /** {@inheritDoc} */
-                @Override public void apply(IgniteFuture<Object> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
-                        }
-                    }
-                    catch (IgniteCheckedException ignore){
-                        //No-op.
-                    }
-                }
-            });
+            updateFut.listenAsync(new UpdateRemoveTimeStatClosure<>(metrics0(), start));
         }
 
         return asyncOp(new CO<IgniteFuture<Object>>() {
@@ -964,7 +944,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                 if (!success)
                     break;
                 else
-                    ctx.cache().metrics0().onRead(true);
+                    metrics0().onRead(true);
             }
 
             if (success) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheAdapter.java
index efcd6dd..2920032 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -316,13 +316,6 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
         return dht().loadCacheAsync(p, ttl, args);
     }
 
-    /** {@inheritDoc} */
-    @Override public void resetMetrics() {
-        super.resetMetrics();
-
-        dht().resetMetrics();
-    }
-
     /**
      * @param nodeId Sender ID.
      * @param res Response.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/atomic/GridLocalAtomicCache.java
index a2a3b13..bb65bc4 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -422,7 +422,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                 ctx.isStoreEnabled());
 
         if (statsEnabled && removed)
-            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
+            metrics0().addRemoveTimeNanos(System.nanoTime() - start);
 
         return  removed;
     }
@@ -840,21 +840,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         });
 
         if (statsEnabled)
-            fut.listenAsync(new CI1<IgniteFuture<Boolean>>() {
-                /** {@inheritDoc} */
-                @Override public void apply(IgniteFuture<Boolean> fut) {
-                    try {
-                        if (!fut.isCancelled()) {
-                            fut.get();
-
-                            ctx.cache().metrics0().addRemoveTimeNanos(System.nanoTime() - start);
-                        }
-                    }
-                    catch (IgniteCheckedException ignore) {
-                        //No-op.
-                    }
-                }
-            });
+            fut.listenAsync(new UpdateRemoveTimeStatClosure<>(metrics0(), start));
 
         return fut;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxManager.java
index bc78303..209ea49 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxManager.java
@@ -1257,7 +1257,7 @@ public class IgniteTxManager<K, V> extends GridCacheSharedManagerAdapter<K, V> {
                     GridCacheContext<K, V> cacheCtx = cctx.cacheContext(cacheId);
 
                     if (cacheCtx.cache().configuration().isStatisticsEnabled())
-                        cacheCtx.cache().metrics0().onTxCommit();
+                        cacheCtx.cache().metrics0().onTxCommit(System.nanoTime() - tx.startTime());
                 }
             }
 
@@ -1331,7 +1331,7 @@ public class IgniteTxManager<K, V> extends GridCacheSharedManagerAdapter<K, V> {
                     GridCacheContext<K, V> cacheCtx = cctx.cacheContext(cacheId);
 
                     if (cacheCtx.cache().configuration().isStatisticsEnabled())
-                        cacheCtx.cache().metrics0().onTxRollback();
+                        cacheCtx.cache().metrics0().onTxRollback(System.nanoTime() - tx.startTime());
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/top/GridTopologyCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/top/GridTopologyCommandHandler.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/top/GridTopologyCommandHandler.java
index 8560db3..084444a 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/top/GridTopologyCommandHandler.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/top/GridTopologyCommandHandler.java
@@ -201,7 +201,7 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter {
         }
 
         if (mtr) {
-            ClusterNodeMetrics metrics = node.metrics();
+            ClusterNodeMetricsMBean metrics = node.metrics();
 
             GridClientNodeMetricsBean metricsBean = new GridClientNodeMetricsBean();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/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 c1d8bf0..3a18008 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.resetMetrics();
+                cache.metrics().clear();
 
             return null;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/kernal/visor/node/VisorNodeGcTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/visor/node/VisorNodeGcTask.java b/modules/core/src/main/java/org/gridgain/grid/kernal/visor/node/VisorNodeGcTask.java
index edf5020..356b482 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/visor/node/VisorNodeGcTask.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/visor/node/VisorNodeGcTask.java
@@ -87,7 +87,7 @@ public class VisorNodeGcTask extends VisorMultiNodeTask<Void, Map<UUID, IgniteBi
          * @return Current free heap.
          */
         private long freeHeap(ClusterNode node) {
-            final ClusterNodeMetrics m = node.metrics();
+            final ClusterNodeMetricsMBean m = node.metrics();
 
             return m.getHeapMemoryMaximum() - m.getHeapMemoryUsed();
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/main/java/org/gridgain/grid/util/GridUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/util/GridUtils.java b/modules/core/src/main/java/org/gridgain/grid/util/GridUtils.java
index 390f61f..a9f84e7 100644
--- a/modules/core/src/main/java/org/gridgain/grid/util/GridUtils.java
+++ b/modules/core/src/main/java/org/gridgain/grid/util/GridUtils.java
@@ -793,7 +793,7 @@ public abstract class GridUtils {
         double heap = 0.0;
 
         for (ClusterNode n : nodesPerJvm(nodes)) {
-            ClusterNodeMetrics m = n.metrics();
+            ClusterNodeMetricsMBean m = n.metrics();
 
             heap += Math.max(m.getHeapMemoryInitialized(), m.getHeapMemoryMaximum());
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridDiscoveryMetricsHelperSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridDiscoveryMetricsHelperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridDiscoveryMetricsHelperSelfTest.java
index 7fd7847..04b13ba 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridDiscoveryMetricsHelperSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/GridDiscoveryMetricsHelperSelfTest.java
@@ -46,7 +46,7 @@ public class GridDiscoveryMetricsHelperSelfTest extends GridCommonAbstractTest {
         assert off == DiscoveryMetricsHelper.METRICS_SIZE;
 
         // Test deserialization.
-        ClusterNodeMetrics res = DiscoveryMetricsHelper.deserialize(data, 0);
+        ClusterNodeMetricsMBean res = DiscoveryMetricsHelper.deserialize(data, 0);
 
         assert res != null;
     }
@@ -55,7 +55,7 @@ public class GridDiscoveryMetricsHelperSelfTest extends GridCommonAbstractTest {
     public void testSerialization() {
         byte[] data = new byte[DiscoveryMetricsHelper.METRICS_SIZE];
 
-        ClusterNodeMetrics metrics1 = createMetrics();
+        ClusterNodeMetricsMBean metrics1 = createMetrics();
 
         // Test serialization.
         int off = DiscoveryMetricsHelper.serialize(data, 0, metrics1);
@@ -63,7 +63,7 @@ public class GridDiscoveryMetricsHelperSelfTest extends GridCommonAbstractTest {
         assert off == DiscoveryMetricsHelper.METRICS_SIZE;
 
         // Test deserialization.
-        ClusterNodeMetrics metrics2 = DiscoveryMetricsHelper.deserialize(data, 0);
+        ClusterNodeMetricsMBean metrics2 = DiscoveryMetricsHelper.deserialize(data, 0);
 
         assert metrics2 != null;
 
@@ -74,7 +74,7 @@ public class GridDiscoveryMetricsHelperSelfTest extends GridCommonAbstractTest {
      * @throws IOException If I/O error occurs.
      */
     public void testMultipleMetricsSerialization() throws IOException {
-        Map<UUID, ClusterNodeMetrics> metrics = new HashMap<>(METRICS_COUNT);
+        Map<UUID, ClusterNodeMetricsMBean> metrics = new HashMap<>(METRICS_COUNT);
 
         for (int i = 0; i < METRICS_COUNT; i++)
             metrics.put(UUID.randomUUID(), createMetrics());
@@ -94,7 +94,7 @@ public class GridDiscoveryMetricsHelperSelfTest extends GridCommonAbstractTest {
     /**
      * @return Test metrics.
      */
-    private ClusterNodeMetrics createMetrics() {
+    private ClusterNodeMetricsMBean createMetrics() {
         DiscoveryNodeMetricsAdapter metrics = new DiscoveryNodeMetricsAdapter();
 
         metrics.setAvailableProcessors(1);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/test/java/org/gridgain/grid/kernal/ClusterNodeMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/ClusterNodeMetricsSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/ClusterNodeMetricsSelfTest.java
index 5ca829c..a59f4b6 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/ClusterNodeMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/ClusterNodeMetricsSelfTest.java
@@ -88,7 +88,7 @@ public class ClusterNodeMetricsSelfTest extends GridCommonAbstractTest {
         // Wait for metrics update.
         latch.await();
 
-        ClusterNodeMetrics metrics = ignite.cluster().localNode().metrics();
+        ClusterNodeMetricsMBean metrics = ignite.cluster().localNode().metrics();
 
         info("Node metrics: " + metrics);
 
@@ -144,7 +144,7 @@ public class ClusterNodeMetricsSelfTest extends GridCommonAbstractTest {
         // Wait for metrics update.
         latch.await();
 
-        ClusterNodeMetrics metrics = ignite.cluster().localNode().metrics();
+        ClusterNodeMetricsMBean metrics = ignite.cluster().localNode().metrics();
 
         info("Node metrics: " + metrics);
 
@@ -207,7 +207,7 @@ public class ClusterNodeMetricsSelfTest extends GridCommonAbstractTest {
 
         latch.await();
 
-        ClusterNodeMetrics metrics = ignite0.cluster().localNode().metrics();
+        ClusterNodeMetricsMBean metrics = ignite0.cluster().localNode().metrics();
 
         info("Node 0 metrics: " + metrics);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/test/java/org/gridgain/grid/kernal/GridDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridDiscoverySelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridDiscoverySelfTest.java
index bf8f394..96aa26c 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/GridDiscoverySelfTest.java
@@ -371,7 +371,7 @@ public class GridDiscoverySelfTest extends GridCommonAbstractTest {
         }
 
         /** {@inheritDoc} */
-        @Nullable @Override public ClusterNodeMetrics metrics() {
+        @Nullable @Override public ClusterNodeMetricsMBean metrics() {
             return null;
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/test/java/org/gridgain/grid/kernal/GridNonHistoryMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridNonHistoryMetricsSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridNonHistoryMetricsSelfTest.java
index f1fb44f..66bd632 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridNonHistoryMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/GridNonHistoryMetricsSelfTest.java
@@ -84,13 +84,13 @@ public class GridNonHistoryMetricsSelfTest extends GridCommonAbstractTest {
 
         GridTestUtils.waitForCondition(new GridAbsPredicate() {
             @Override public boolean apply() {
-                ClusterNodeMetrics metrics = ignite.cluster().localNode().metrics();
+                ClusterNodeMetricsMBean metrics = ignite.cluster().localNode().metrics();
 
                 return metrics.getTotalExecutedJobs() == 5;
             }
         }, 5000);
 
-        ClusterNodeMetrics metrics = ignite.cluster().localNode().metrics();
+        ClusterNodeMetricsMBean metrics = ignite.cluster().localNode().metrics();
 
         info("Node metrics: " + metrics);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/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 c347f29..4563d3d 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).resetMetrics();
+            g.cache(null).metrics().clear();
 
             g.transactions().resetMetrics();
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java
index 1e0b38c..b01b562 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java
@@ -225,8 +225,10 @@ public abstract class GridCacheTransactionalAbstractMetricsSelfTest extends Grid
             if (i == 0) {
                 assertEquals(TX_CNT, metrics.txCommits());
 
-                if (put)
+                if (put) {
                     assertEquals(TX_CNT, cacheMetrics.getCacheTxCommits());
+                    assert cacheMetrics.getAverageTxCommitTime() > 0;
+                }
             }
             else {
                 assertEquals(0, metrics.txCommits());
@@ -268,8 +270,10 @@ public abstract class GridCacheTransactionalAbstractMetricsSelfTest extends Grid
             if (i == 0) {
                 assertEquals(TX_CNT, metrics.txRollbacks());
 
-                if (put)
+                if (put) {
                     assertEquals(TX_CNT, cacheMetrics.getCacheTxRollbacks());
+                    assert cacheMetrics.getAverageTxRollbackTime() > 0;
+                }
             }
             else {
                 assertEquals(0, metrics.txRollbacks());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/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 8b76feb..6ef9187 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
@@ -91,7 +91,7 @@ public class GridCachePartitionedNearDisabledMetricsSelfTest extends GridCacheAb
 
             assert g.cache(null).isEmpty();
 
-            g.cache(null).resetMetrics();
+            g.cache(null).metrics().clear();
         }
 
         assertNull("Value is not null for key: " + 0, cache.get(0));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/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 28e7eb5..3a8d991 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
@@ -69,7 +69,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
             assert g.cache(null).isEmpty();
 
-            g.cache(null).resetMetrics();
+            g.cache(null).metrics().clear();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/test/java/org/gridgain/grid/p2p/GridP2PClassLoadingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/p2p/GridP2PClassLoadingSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/p2p/GridP2PClassLoadingSelfTest.java
index 2109fba..e279a6e 100644
--- a/modules/core/src/test/java/org/gridgain/grid/p2p/GridP2PClassLoadingSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/p2p/GridP2PClassLoadingSelfTest.java
@@ -110,7 +110,7 @@ public class GridP2PClassLoadingSelfTest extends GridCommonAbstractTest {
         }
 
         /** {@inheritDoc} */
-        @Nullable @Override public ClusterNodeMetrics metrics() {
+        @Nullable @Override public ClusterNodeMetricsMBean metrics() {
             return null;
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/test/java/org/gridgain/testframework/GridTestNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testframework/GridTestNode.java b/modules/core/src/test/java/org/gridgain/testframework/GridTestNode.java
index 083a1bf..032e152 100644
--- a/modules/core/src/test/java/org/gridgain/testframework/GridTestNode.java
+++ b/modules/core/src/test/java/org/gridgain/testframework/GridTestNode.java
@@ -53,7 +53,7 @@ public class GridTestNode extends GridMetadataAwareAdapter implements ClusterNod
     private Object consistentId = consistentIdCtr.incrementAndGet();
 
     /** */
-    private ClusterNodeMetrics metrics;
+    private ClusterNodeMetricsMBean metrics;
 
     /** */
     private long order;
@@ -84,7 +84,7 @@ public class GridTestNode extends GridMetadataAwareAdapter implements ClusterNod
      * @param id Node ID.
      * @param metrics Node metrics.
      */
-    public GridTestNode(UUID id, ClusterNodeMetrics metrics) {
+    public GridTestNode(UUID id, ClusterNodeMetricsMBean metrics) {
         this.id = id;
         this.metrics = metrics;
 
@@ -182,7 +182,7 @@ public class GridTestNode extends GridMetadataAwareAdapter implements ClusterNod
     }
 
     /** {@inheritDoc} */
-    @Override public ClusterNodeMetrics metrics() {
+    @Override public ClusterNodeMetricsMBean metrics() {
         return metrics;
     }
 
@@ -208,7 +208,7 @@ public class GridTestNode extends GridMetadataAwareAdapter implements ClusterNod
      *
      * @param metrics Node metrics.
      */
-    public void setMetrics(ClusterNodeMetrics metrics) {
+    public void setMetrics(ClusterNodeMetricsMBean metrics) {
         this.metrics = metrics;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2a599ec/modules/core/src/test/java/org/gridgain/testframework/junits/spi/GridSpiAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testframework/junits/spi/GridSpiAbstractTest.java b/modules/core/src/test/java/org/gridgain/testframework/junits/spi/GridSpiAbstractTest.java
index 3f7eb27..a2c1fd1 100644
--- a/modules/core/src/test/java/org/gridgain/testframework/junits/spi/GridSpiAbstractTest.java
+++ b/modules/core/src/test/java/org/gridgain/testframework/junits/spi/GridSpiAbstractTest.java
@@ -347,7 +347,7 @@ public abstract class GridSpiAbstractTest<T extends IgniteSpi> extends GridAbstr
     protected DiscoveryMetricsProvider createMetricsProvider() {
         return new DiscoveryMetricsProvider() {
             /** {@inheritDoc} */
-            @Override public ClusterNodeMetrics getMetrics() { return new DiscoveryNodeMetricsAdapter(); }
+            @Override public ClusterNodeMetricsMBean getMetrics() { return new DiscoveryNodeMetricsAdapter(); }
         };
     }
 


Mime
View raw message