ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/2] incubator-ignite git commit: IGNITE-236 Added getNon-heap/HeapMemoryTotal methods into ClusterMetrics.
Date Mon, 16 Feb 2015 09:44:38 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/sprint-1 41f324305 -> 1194fdccd


IGNITE-236 Added getNon-heap/HeapMemoryTotal methods into ClusterMetrics.


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

Branch: refs/heads/sprint-1
Commit: 3174bdb4af13c022aff67d3f0660b37d52fe27de
Parents: e608da8
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Mon Feb 16 12:35:27 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Mon Feb 16 12:35:27 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/cluster/ClusterMetrics.java   | 41 +++++++++++++++
 .../ClusterLocalNodeMetricsMXBeanImpl.java      | 10 ++++
 .../ignite/internal/ClusterMetricsSnapshot.java | 52 ++++++++++++++++++++
 .../discovery/GridDiscoveryManager.java         |  2 +
 .../mxbean/ClusterLocalNodeMetricsMXBean.java   |  9 ++++
 ...ClusterMetricsSnapshotSerializeSelfTest.java |  6 ++-
 6 files changed, 119 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3174bdb4/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 7ef463e..4ad936c 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
@@ -465,6 +465,26 @@ public interface ClusterMetrics {
     public long getHeapMemoryMaximum();
 
     /**
+     * Returns the total amount of heap memory in bytes. This method returns {@code -1}
+     * if the total memory size is undefined.
+     * <p>
+     * This amount of memory is not guaranteed to be available
+     * for memory management if it is greater than the amount of
+     * committed memory. The JVM may fail to allocate
+     * memory even if the amount of used memory does not exceed this
+     * maximum size.
+     * <p>
+     * This value represents a setting of the heap memory for Java VM and is
+     * not a sum of all initial heap values for all memory pools.
+     * <p>
+     * <b>Note:</b> this is <b>not</b> an aggregated metric and it's
calculated
+     * from the time of the node's startup.
+     *
+     * @return The total amount of memory in bytes; {@code -1} if undefined.
+     */
+    public long getHeapMemoryTotal();
+
+    /**
      * Returns the amount of non-heap memory in bytes that the JVM
      * initially requests from the operating system for memory management.
      * This method returns {@code -1} if the initial memory size is undefined.
@@ -530,6 +550,27 @@ public interface ClusterMetrics {
     public long getNonHeapMemoryMaximum();
 
     /**
+     * Returns the total amount of non-heap memory in bytes that can be
+     * used for memory management. This method returns {@code -1}
+     * if the total memory size is undefined.
+     * <p>
+     * This amount of memory is not guaranteed to be available
+     * for memory management if it is greater than the amount of
+     * committed memory.  The JVM may fail to allocate
+     * memory even if the amount of used memory does not exceed this
+     * maximum size.
+     * <p>
+     * This value represents a setting of the non-heap memory for Java VM and is
+     * not a sum of all initial non-heap values for all memory pools.
+     * <p>
+     * <b>Note:</b> this is <b>not</b> an aggregated metric and it's
calculated
+     * from the time of the node's startup.
+     *
+     * @return The total amount of memory in bytes; {@code -1} if undefined.
+     */
+    public long getNonHeapMemoryTotal();
+
+    /**
      * Returns the uptime of the JVM in milliseconds.
      *
      * @return Uptime of the JVM in milliseconds.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3174bdb4/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
index 80269e5..a4ddafd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/ClusterLocalNodeMetricsMXBeanImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/ClusterLocalNodeMetricsMXBeanImpl.java
@@ -138,6 +138,11 @@ public class ClusterLocalNodeMetricsMXBeanImpl implements ClusterLocalNodeMetric
     }
 
     /** {@inheritDoc} */
+    @Override public long getHeapMemoryTotal() {
+        return node.metrics().getHeapMemoryTotal();
+    }
+
+    /** {@inheritDoc} */
     @Override public long getHeapMemoryUsed() {
         return node.metrics().getHeapMemoryUsed();
     }
@@ -198,6 +203,11 @@ public class ClusterLocalNodeMetricsMXBeanImpl implements ClusterLocalNodeMetric
     }
 
     /** {@inheritDoc} */
+    @Override public long getNonHeapMemoryTotal() {
+        return node.metrics().getNonHeapMemoryTotal();
+    }
+
+    /** {@inheritDoc} */
     @Override public long getNonHeapMemoryUsed() {
         return node.metrics().getNonHeapMemoryUsed();
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3174bdb4/modules/core/src/main/java/org/apache/ignite/internal/ClusterMetricsSnapshot.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/ClusterMetricsSnapshot.java
b/modules/core/src/main/java/org/apache/ignite/internal/ClusterMetricsSnapshot.java
index 5b08116..a934d6c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/ClusterMetricsSnapshot.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/ClusterMetricsSnapshot.java
@@ -67,10 +67,12 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
         8/*heap memory used*/ +
         8/*heap memory committed*/ +
         8/*heap memory max*/ +
+        8/*heap memory total*/ +
         8/*non-heap memory init*/ +
         8/*non-heap memory used*/ +
         8/*non-heap memory committed*/ +
         8/*non-heap memory max*/ +
+        8/*non-heap memory total*/ +
         8/*uptime*/ +
         8/*start time*/ +
         8/*node start time*/ +
@@ -185,6 +187,9 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
     private long heapMax = -1;
 
     /** */
+    private long heapTotal = -1;
+
+    /** */
     private long nonHeapInit = -1;
 
     /** */
@@ -197,6 +202,9 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
     private long nonHeapMax = -1;
 
     /** */
+    private long nonHeapTotal = -1;
+
+    /** */
     private long upTime = -1;
 
     /** */
@@ -291,6 +299,7 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
         nonHeapUsed = 0;
         nonHeapCommitted = 0;
         nonHeapMax = 0;
+        nonHeapTotal = 0;
         upTime = 0;
         startTime = 0;
         nodeStartTime = 0;
@@ -304,6 +313,7 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
         rcvdMsgsCnt = 0;
         rcvdBytesCnt = 0;
         outMesQueueSize = 0;
+        heapTotal = 0;
 
         for (ClusterNode node : nodes) {
             ClusterMetrics m = node.metrics();
@@ -354,6 +364,8 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
 
             heapMax = max(heapMax, m.getHeapMemoryMaximum());
 
+            heapTotal += m.getHeapMemoryTotal();
+
             heapInit += m.getHeapMemoryInitialized();
 
             nonHeapCommitted += m.getNonHeapMemoryCommitted();
@@ -362,6 +374,8 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
 
             nonHeapMax = max(nonHeapMax, m.getNonHeapMemoryMaximum());
 
+            nonHeapTotal += m.getNonHeapMemoryTotal();
+
             nonHeapInit += m.getNonHeapMemoryInitialized();
 
             upTime = max(upTime, m.getUpTime());
@@ -402,6 +416,29 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
     }
 
     /** {@inheritDoc} */
+    @Override public long getHeapMemoryTotal() {
+        return heapTotal;
+    }
+
+    /**
+     * Sets total heap size.
+     *
+     * @param heapTotal Total heap.
+     */
+    public void setHeapMemoryTotal(long heapTotal) {
+        this.heapTotal = heapTotal;
+    }
+
+    /**
+     * Sets non-heap total heap size.
+     *
+     * @param nonHeapTotal Total heap.
+     */
+    public void setNonHeapMemoryTotal(long nonHeapTotal) {
+        this.nonHeapTotal = nonHeapTotal;
+    }
+
+    /** {@inheritDoc} */
     @Override public long getLastUpdateTime() {
         return lastUpdateTime;
     }
@@ -819,6 +856,11 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
     }
 
     /** {@inheritDoc} */
+    @Override public long getNonHeapMemoryTotal() {
+        return nonHeapTotal;
+    }
+
+    /** {@inheritDoc} */
     @Override public long getUpTime() {
         return upTime;
     }
@@ -1225,10 +1267,12 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
         off = U.longToBytes(metrics.getHeapMemoryUsed(), data, off);
         off = U.longToBytes(metrics.getHeapMemoryCommitted(), data, off);
         off = U.longToBytes(metrics.getHeapMemoryMaximum(), data, off);
+        off = U.longToBytes(metrics.getHeapMemoryTotal(), data, off);
         off = U.longToBytes(metrics.getNonHeapMemoryInitialized(), data, off);
         off = U.longToBytes(metrics.getNonHeapMemoryUsed(), data, off);
         off = U.longToBytes(metrics.getNonHeapMemoryCommitted(), data, off);
         off = U.longToBytes(metrics.getNonHeapMemoryMaximum(), data, off);
+        off = U.longToBytes(metrics.getNonHeapMemoryTotal(), data, off);
         off = U.longToBytes(metrics.getStartTime(), data, off);
         off = U.longToBytes(metrics.getNodeStartTime(), data, off);
         off = U.longToBytes(metrics.getUpTime(), data, off);
@@ -1391,6 +1435,10 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
 
         off += 8;
 
+        metrics.setHeapMemoryTotal(U.bytesToLong(data, off));
+
+        off += 8;
+
         metrics.setNonHeapMemoryInitialized(U.bytesToLong(data, off));
 
         off += 8;
@@ -1407,6 +1455,10 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
 
         off += 8;
 
+        metrics.setNonHeapMemoryTotal(U.bytesToLong(data, off));
+
+        off += 8;
+
         metrics.setStartTime(U.bytesToLong(data, off));
 
         off += 8;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3174bdb4/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 bd5cff2..06ba35b 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
@@ -498,10 +498,12 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
                 nm.setHeapMemoryUsed(metrics.getHeapMemoryUsed());
                 nm.setHeapMemoryCommitted(metrics.getHeapMemoryCommitted());
                 nm.setHeapMemoryMaximum(metrics.getHeapMemoryMaximum());
+                nm.setHeapMemoryTotal(metrics.getHeapMemoryMaximum());
                 nm.setNonHeapMemoryInitialized(metrics.getNonHeapMemoryInitialized());
                 nm.setNonHeapMemoryUsed(metrics.getNonHeapMemoryUsed());
                 nm.setNonHeapMemoryCommitted(metrics.getNonHeapMemoryCommitted());
                 nm.setNonHeapMemoryMaximum(metrics.getNonHeapMemoryMaximum());
+                nm.setNonHeapMemoryTotal(metrics.getNonHeapMemoryMaximum());
                 nm.setUpTime(metrics.getUptime());
                 nm.setStartTime(metrics.getStartTime());
                 nm.setNodeStartTime(startTime);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3174bdb4/modules/core/src/main/java/org/apache/ignite/mxbean/ClusterLocalNodeMetricsMXBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/mxbean/ClusterLocalNodeMetricsMXBean.java
b/modules/core/src/main/java/org/apache/ignite/mxbean/ClusterLocalNodeMetricsMXBean.java
index b323160..7a5b93a 100644
--- a/modules/core/src/main/java/org/apache/ignite/mxbean/ClusterLocalNodeMetricsMXBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/mxbean/ClusterLocalNodeMetricsMXBean.java
@@ -170,6 +170,10 @@ public interface ClusterLocalNodeMetricsMXBean extends ClusterMetrics
{
     public long getHeapMemoryMaximum();
 
     /** {@inheritDoc} */
+    @MXBeanDescription("The total amount of memory in bytes; -1 if undefined.")
+    public long getHeapMemoryTotal();
+
+    /** {@inheritDoc} */
     @MXBeanDescription("The initial size of memory in bytes; -1 if undefined.")
     public long getNonHeapMemoryInitialized();
 
@@ -187,6 +191,11 @@ public interface ClusterLocalNodeMetricsMXBean extends ClusterMetrics
{
     public long getNonHeapMemoryMaximum();
 
     /** {@inheritDoc} */
+    @MXBeanDescription("Total amount of non-heap memory in bytes that can " +
+        "be used for memory management. -1 if undefined.")
+    public long getNonHeapMemoryTotal();
+
+    /** {@inheritDoc} */
     @MXBeanDescription("Uptime of the JVM in milliseconds.")
     public long getUpTime();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3174bdb4/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeSelfTest.java
index 5eca33f..a9d6f8c 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeSelfTest.java
@@ -117,6 +117,8 @@ public class ClusterMetricsSnapshotSerializeSelfTest extends GridCommonAbstractT
         metrics.setReceivedMessagesCount(44);
         metrics.setReceivedBytesCount(45);
         metrics.setOutboundMessagesQueueSize(46);
+        metrics.setNonHeapMemoryTotal(47);
+        metrics.setHeapMemoryTotal(48);
 
         return metrics;
     }
@@ -165,6 +167,8 @@ public class ClusterMetricsSnapshotSerializeSelfTest extends GridCommonAbstractT
             obj.getSentBytesCount() == obj1.getSentBytesCount() &&
             obj.getReceivedMessagesCount() == obj1.getReceivedMessagesCount() &&
             obj.getReceivedBytesCount() == obj1.getReceivedBytesCount() &&
-            obj.getOutboundMessagesQueueSize() == obj1.getOutboundMessagesQueueSize();
+            obj.getOutboundMessagesQueueSize() == obj1.getOutboundMessagesQueueSize() &&
+            obj.getNonHeapMemoryTotal() == obj1.getNonHeapMemoryTotal() &&
+            obj.getHeapMemoryTotal() == obj1.getHeapMemoryTotal();
     }
 }


Mime
View raw message