storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject [1/4] storm git commit: [YSTORM-1433] - normalize the scales of CPU/Mem/Net when choosing the best node
Date Thu, 05 Nov 2015 21:22:12 GMT
Repository: storm
Updated Branches:
  refs/heads/master 8545ff9a6 -> 90edd94dd


[YSTORM-1433] - normalize the scales of CPU/Mem/Net when choosing the best node


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/780a472a
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/780a472a
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/780a472a

Branch: refs/heads/master
Commit: 780a472ad2dc4e838b86f65f0c40eb9443046038
Parents: 8ba776b
Author: Boyang Jerry Peng <jerrypeng@yahoo-inc.com>
Authored: Tue Nov 3 17:13:08 2015 -0600
Committer: Boyang Jerry Peng <jerrypeng@yahoo-inc.com>
Committed: Tue Nov 3 17:13:08 2015 -0600

----------------------------------------------------------------------
 .../strategies/ResourceAwareStrategy.java       | 32 ++++++++++----------
 1 file changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/780a472a/storm-core/src/jvm/backtype/storm/scheduler/resource/strategies/ResourceAwareStrategy.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/scheduler/resource/strategies/ResourceAwareStrategy.java
b/storm-core/src/jvm/backtype/storm/scheduler/resource/strategies/ResourceAwareStrategy.java
index 22bac2d..754633c 100644
--- a/storm-core/src/jvm/backtype/storm/scheduler/resource/strategies/ResourceAwareStrategy.java
+++ b/storm-core/src/jvm/backtype/storm/scheduler/resource/strategies/ResourceAwareStrategy.java
@@ -209,18 +209,18 @@ public class ResourceAwareStrategy implements IStrategy {
         for (RAS_Node n : nodes) {
             if(n.getFreeSlots().size()>0) {
                 if (n.getAvailableMemoryResources() >= taskMem
-                      && n.getAvailableCpuResources() >= taskCPU) {
-                  double a = Math.pow((taskCPU - n.getAvailableCpuResources())
-                          * this.CPU_WEIGHT, 2);
-                  double b = Math.pow((taskMem - n.getAvailableMemoryResources())
-                          * this.MEM_WEIGHT, 2);
-                  double c = 0.0;
-                  if(this.refNode != null) {
-                      c = Math.pow(this.distToNode(this.refNode, n)
-                              * this.NETWORK_WEIGHT, 2);
-                  }
-                  double distance = Math.sqrt(a + b + c);
-                  nodeRankMap.put(distance, n);
+                        && n.getAvailableCpuResources() >= taskCPU) {
+                    double a = Math.pow(((taskCPU - n.getAvailableCpuResources())/n.getAvailableCpuResources())
+                            * this.CPU_WEIGHT, 2);
+                    double b = Math.pow(((taskMem - n.getAvailableMemoryResources())/n.getAvailableMemoryResources())
+                            * this.MEM_WEIGHT, 2);
+                    double c = 0.0;
+                    if(this.refNode != null) {
+                        c = Math.pow(this.distToNode(this.refNode, n)
+                                * this.NETWORK_WEIGHT, 2);
+                    }
+                    double distance = Math.sqrt(a + b + c);
+                    nodeRankMap.put(distance, n);
                 }
             }
         }
@@ -262,12 +262,12 @@ public class ResourceAwareStrategy implements IStrategy {
     }
 
     private Double distToNode(RAS_Node src, RAS_Node dest) {
-        if (src.getId().equals(dest.getId())==true) {
-            return 1.0;
+        if (src.getId().equals(dest.getId()) == true) {
+            return 0.0;
         }else if (this.NodeToCluster(src) == this.NodeToCluster(dest)) {
-            return 2.0;
+            return 0.5;
         } else {
-            return 3.0;
+            return 1.0;
         }
     }
 


Mime
View raw message