ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [03/36] incubator-ignite git commit: #IGNITE-236 WIP
Date Fri, 13 Feb 2015 16:27:34 GMT
#IGNITE-236 WIP


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

Branch: refs/heads/ignite-hadoop-tests
Commit: cc4cdfbec7ce4a34074ae0d8530735c2d36e8f9a
Parents: e6beac4
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Fri Feb 13 13:23:46 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Fri Feb 13 13:23:46 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/ClusterMetricsSnapshot.java   | 18 ++++++++++++++++--
 .../internal/ClusterNodeMetricsSelfTest.java      |  3 +--
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc4cdfbe/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 7129453..1007b7f 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
@@ -375,7 +375,6 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
             outMesQueueSize += m.getOutboundMessagesQueueSize();
 
             avgLoad += m.getCurrentCpuLoad();
-            availProcs += m.getTotalCpus();
         }
 
         curJobExecTime /= size;
@@ -399,6 +398,7 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
 
         gcLoad = gcCpus(neighborhood);
         load = cpus(neighborhood);
+        availProcs = cpuCnt(neighborhood);
     }
 
     /** {@inheritDoc} */
@@ -1108,7 +1108,7 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
         this.outMesQueueSize = outMesQueueSize;
     }
 
-    private static int cpus(Map<String, Collection<ClusterNode>> neighborhood)
{
+    private static int cpuCnt(Map<String, Collection<ClusterNode>> neighborhood)
{
         int cpus = 0;
 
         for (Collection<ClusterNode> nodes : neighborhood.values()) {
@@ -1122,6 +1122,20 @@ public class ClusterMetricsSnapshot implements ClusterMetrics {
         return cpus;
     }
 
+    private static int cpus(Map<String, Collection<ClusterNode>> neighborhood)
{
+        int cpus = 0;
+
+        for (Collection<ClusterNode> nodes : neighborhood.values()) {
+            ClusterNode first = F.first(nodes);
+
+            // Projection can be empty if all nodes in it failed.
+            if (first != null)
+                cpus += first.metrics().getCurrentCpuLoad();
+        }
+
+        return cpus;
+    }
+
     private static int gcCpus(Map<String, Collection<ClusterNode>> neighborhood)
{
         int cpus = 0;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cc4cdfbe/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
index 31543e6..87bb788 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
@@ -235,12 +235,11 @@ public class ClusterNodeMetricsSelfTest extends GridCommonAbstractTest
{
         Ignite ignite1 = startGrid(1);
 
         ClusterMetrics metrics0 = ignite0.cluster().localNode().metrics();
-        ClusterMetrics metrics1 = ignite1.cluster().localNode().metrics();
 
         ClusterMetrics nodesMetrics =
             ignite0.cluster().forNode(ignite0.cluster().localNode(), ignite1.cluster().localNode()).metrics();
 
-        assertEquals(metrics0.getTotalCpus() + metrics1.getTotalCpus(), nodesMetrics.getTotalCpus());
+        assertEquals(metrics0.getTotalCpus(), nodesMetrics.getTotalCpus());
     }
 
     /**


Mime
View raw message