ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: # ignite-337: Return ClusterMetrics.totalNodes()
Date Fri, 27 Feb 2015 16:18:24 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-337 [created] 472ef0515


# ignite-337:  Return ClusterMetrics.totalNodes()


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

Branch: refs/heads/ignite-337
Commit: 472ef05159149d8c6c53a9b41ee473842fff641f
Parents: f053746
Author: Artem Shutak <ashutak@gridgain.com>
Authored: Fri Feb 27 19:18:32 2015 +0300
Committer: Artem Shutak <ashutak@gridgain.com>
Committed: Fri Feb 27 19:18:32 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/cluster/ClusterMetrics.java   | 66 +++++++++++---------
 .../ClusterLocalNodeMetricsMXBeanImpl.java      |  5 ++
 .../ignite/internal/ClusterMetricsSnapshot.java | 27 +++++++-
 .../mxbean/ClusterLocalNodeMetricsMXBean.java   |  4 ++
 4 files changed, 72 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/472ef051/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 c2b9a05..98820d2 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
@@ -17,6 +17,9 @@
 
 package org.apache.ignite.cluster;
 
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+
 /**
  * This class represents runtime information on a cluster. Apart from obvious
  * statistical value, this information is used for implementation of
@@ -24,10 +27,10 @@ package org.apache.ignite.cluster;
  * in combination with fail-over SPI could check if other nodes don't have
  * any active or waiting jobs and fail-over some jobs to those nodes.
  * <p>
- * Node metrics for any node can be accessed via {@link org.apache.ignite.cluster.ClusterNode#metrics()}
+ * Node metrics for any node can be accessed via {@link ClusterNode#metrics()}
  * method. Keep in mind that there will be a certain network delay (usually
  * equal to heartbeat delay) for the accuracy of node metrics. However, when accessing
- * metrics on local node {@link org.apache.ignite.IgniteCluster#localNode() Grid.localNode().getMetrics()}
+ * metrics on local node {@link IgniteCluster#localNode() Grid.localNode().getMetrics()}
  * the metrics are always accurate and up to date.
  * <p>
  * Local node metrics are registered as {@code MBean} and can be accessed from
@@ -52,8 +55,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Maximum number of jobs that ever ran concurrently on this node.
@@ -74,8 +77,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Average number of active jobs.
@@ -89,8 +92,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Maximum number of waiting jobs.
@@ -111,8 +114,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Average number of waiting jobs.
@@ -127,8 +130,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Maximum number of jobs rejected at once.
@@ -149,8 +152,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of grid configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Average number of jobs this node rejects during collision resolution operations.
@@ -193,8 +196,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Average number of cancelled jobs.
@@ -228,8 +231,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Maximum waiting time.
@@ -250,8 +253,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Average job wait time.
@@ -265,8 +268,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Time it took to execute the longest job on the node.
@@ -287,8 +290,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Average job execution time.
@@ -302,8 +305,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Total number of jobs handled by the node.
@@ -382,8 +385,8 @@ public interface ClusterMetrics {
      * calculated over all the metrics kept in history. The
      * history size is set via either one or both of configuration settings:
      * <ul>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsExpireTime()}</li>
-     * <li>{@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsHistorySize()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsExpireTime()}</li>
+     * <li>{@link IgniteConfiguration#getMetricsHistorySize()}</li>
      * </ul>
      *
      * @return Average of CPU load value in {@code [0, 1]} range over all metrics kept
@@ -674,4 +677,11 @@ public interface ClusterMetrics {
      * @return Outbound messages queue size.
      */
     public int getOutboundMessagesQueueSize();
+
+    /**
+     * Gets total number of nodes.
+     *
+     * @return Total number of nodes.
+     */
+    public int getTotalNodes();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/472ef051/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 a4ddafd..67dc5e6 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
@@ -313,6 +313,11 @@ public class ClusterLocalNodeMetricsMXBeanImpl implements ClusterLocalNodeMetric
     }
 
     /** {@inheritDoc} */
+    @Override public int getTotalNodes() {
+        return node.metrics().getTotalNodes();
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(ClusterLocalNodeMetricsMXBeanImpl.class, this);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/472ef051/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 6e1e4c3..6e933ab 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
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal;
 
 import org.apache.ignite.cluster.*;
-import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
@@ -86,7 +85,8 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
         8/*sent bytes count*/ +
         4/*received messages count*/ +
         8/*received bytes count*/ +
-        4/*outbound messages queue size*/;
+        4/*outbound messages queue size*/ + 
+        4/*total nodes*/;
 
     /** */
     private long lastUpdateTime = -1;
@@ -244,6 +244,9 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
     /** */
     private int outMesQueueSize = -1;
 
+    /** */
+    private int totalNodes = -1;
+
     /**
      * Create empty snapshot.
      */
@@ -315,6 +318,7 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
         rcvdBytesCnt = 0;
         outMesQueueSize = 0;
         heapTotal = 0;
+        totalNodes = nodes.size();
 
         for (ClusterNode node : nodes) {
             ClusterMetrics m = node.metrics();
@@ -926,6 +930,11 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
         return outMesQueueSize;
     }
 
+    /** {@inheritDoc} */
+    @Override public int getTotalNodes() {
+        return totalNodes;
+    }
+
     /**
      * Sets available processors.
      *
@@ -1152,6 +1161,15 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
     }
 
     /**
+     * Sets total number of nodes.
+     *
+     * @param totalNodes Total number of nodes.
+     */
+    public void setTotalNodes(int totalNodes) {
+        this.totalNodes = totalNodes;
+    }
+
+    /**
      * @param neighborhood Cluster neighborhood.
      * @return CPU count.
      */
@@ -1287,6 +1305,7 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
         off = U.intToBytes(metrics.getReceivedMessagesCount(), data, off);
         off = U.longToBytes(metrics.getReceivedBytesCount(), data, off);
         off = U.intToBytes(metrics.getOutboundMessagesQueueSize(), data, off);
+        off = U.intToBytes(metrics.getTotalNodes(), data, off);
 
         assert off - start == METRICS_SIZE : "Invalid metrics size [expected=" + METRICS_SIZE
+ ", actual=" +
                 (off - start) + ']';
@@ -1512,6 +1531,10 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
 
         off += 4;
 
+        metrics.setTotalNodes(U.bytesToInt(data, off));
+
+        off += 4;
+
         assert off - start == METRICS_SIZE : "Invalid metrics size [expected=" + METRICS_SIZE
+ ", actual=" +
                 (off - start) + ']';
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/472ef051/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 7a5b93a..a3c946d 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
@@ -246,4 +246,8 @@ public interface ClusterLocalNodeMetricsMXBean extends ClusterMetrics
{
     /** {@inheritDoc} */
     @MXBeanDescription("Start time of the grid node in milliseconds.")
     public long getNodeStartTime();
+
+    /** {@inheritDoc} */
+    @MXBeanDescription("Total number of nodes.")
+    public int getTotalNodes();
 }


Mime
View raw message