[2/6] hbase git commit: HBASE-18164 Fast locality computation in balancer - addendum handles NaN

2017-06-27 Thread busbey
HBASE-18164 Fast locality computation in balancer - addendum handles NaN

Signed-off-by: tedyu 
Signed-off-by: Sean Busbey 


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

Branch: refs/heads/branch-1
Commit: bb181ff50bd60120bcda463d6d71db8505170e88
Parents: 386a6e8
Author: Kahlil Oppenheimer 
Authored: Tue Jun 6 15:53:43 2017 -0400
Committer: Sean Busbey 
Committed: Tue Jun 27 13:33:48 2017 -0500

--
 .../hadoop/hbase/master/balancer/StochasticLoadBalancer.java  | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/bb181ff5/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
--
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
index 6f99f44..0f29a1a 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
@@ -1279,8 +1279,9 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
   }
 
   // We normalize locality to be a score between 0 and 1.0 representing 
how good it
-  // is compared to how good it could be
-  locality /= bestLocality;
+  // is compared to how good it could be. If bestLocality is 0, assume 
locality is 100
+  // (and the cost is 0)
+  locality = bestLocality == 0 ? 1.0 : locality / bestLocality;
 }
 
 @Override
@@ -1291,7 +1292,7 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
 return;
   }
   double localityDelta = getWeightedLocality(region, newEntity) - 
getWeightedLocality(region, oldEntity);
-  double normalizedDelta = localityDelta / bestLocality;
+  double normalizedDelta = bestLocality == 0 ? 0.0 : localityDelta / 
bestLocality;
   locality += normalizedDelta;
 }
 



[6/6] hbase git commit: HBASE-18164 Fast locality computation in balancer - addendum handles NaN

2017-06-27 Thread busbey
HBASE-18164 Fast locality computation in balancer - addendum handles NaN

Signed-off-by: tedyu 
Signed-off-by: Sean Busbey 


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/812b3833
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/812b3833
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/812b3833

Branch: refs/heads/branch-2
Commit: 812b38332557b497560655005c839a92543a80ec
Parents: 0ad8f26
Author: Kahlil Oppenheimer 
Authored: Tue Jun 6 15:53:43 2017 -0400
Committer: Sean Busbey 
Committed: Tue Jun 27 14:58:03 2017 -0500

--
 .../hadoop/hbase/master/balancer/StochasticLoadBalancer.java  | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/812b3833/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
--
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
index 63ec0b5..6f05581 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
@@ -1286,8 +1286,9 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
   }
 
   // We normalize locality to be a score between 0 and 1.0 representing 
how good it
-  // is compared to how good it could be
-  locality /= bestLocality;
+  // is compared to how good it could be. If bestLocality is 0, assume 
locality is 100
+  // (and the cost is 0)
+  locality = bestLocality == 0 ? 1.0 : locality / bestLocality;
 }
 
 @Override
@@ -1298,7 +1299,7 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
 return;
   }
   double localityDelta = getWeightedLocality(region, newEntity) - 
getWeightedLocality(region, oldEntity);
-  double normalizedDelta = localityDelta / bestLocality;
+  double normalizedDelta = bestLocality == 0 ? 0.0 : localityDelta / 
bestLocality;
   locality += normalizedDelta;
 }
 



[4/6] hbase git commit: HBASE-18164 Fast locality computation in balancer - addendum handles NaN

2017-06-27 Thread busbey
HBASE-18164 Fast locality computation in balancer - addendum handles NaN

Signed-off-by: tedyu 
Signed-off-by: Sean Busbey 


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8da6f069
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8da6f069
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8da6f069

Branch: refs/heads/master
Commit: 8da6f069c307d7cf0b8d56281189e84108c7430b
Parents: 1414825
Author: Kahlil Oppenheimer 
Authored: Tue Jun 6 15:53:43 2017 -0400
Committer: Sean Busbey 
Committed: Tue Jun 27 14:57:53 2017 -0500

--
 .../hadoop/hbase/master/balancer/StochasticLoadBalancer.java  | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/8da6f069/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
--
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
index 63ec0b5..6f05581 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
@@ -1286,8 +1286,9 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
   }
 
   // We normalize locality to be a score between 0 and 1.0 representing 
how good it
-  // is compared to how good it could be
-  locality /= bestLocality;
+  // is compared to how good it could be. If bestLocality is 0, assume 
locality is 100
+  // (and the cost is 0)
+  locality = bestLocality == 0 ? 1.0 : locality / bestLocality;
 }
 
 @Override
@@ -1298,7 +1299,7 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
 return;
   }
   double localityDelta = getWeightedLocality(region, newEntity) - 
getWeightedLocality(region, oldEntity);
-  double normalizedDelta = localityDelta / bestLocality;
+  double normalizedDelta = bestLocality == 0 ? 0.0 : localityDelta / 
bestLocality;
   locality += normalizedDelta;
 }
 



hbase git commit: HBASE-18164 Fast locality computation in balancer - addendum handles NaN

2017-06-26 Thread tedyu
Repository: hbase
Updated Branches:
  refs/heads/branch-1 d5bba5079 -> 74e9d3147


HBASE-18164 Fast locality computation in balancer - addendum handles NaN

-Added new LocalityCostFunction and LocalityCandidateGenerator that
cache localities of every region/rack combination and mappings of every
region to its most local server and to its most local rack.

-Made LocalityCostFunction incremental so that it only computes locality
based on most recent region moves/swaps, rather than recomputing the
locality of every region in the cluster at every iteration of the
balancer

-Changed locality cost function to reflect the ratio of:
(Current locality) / (Best locality possible given current cluster)

Signed-off-by: tedyu 


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/74e9d314
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/74e9d314
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/74e9d314

Branch: refs/heads/branch-1
Commit: 74e9d314749a24ecdeebecfb801416efd71c3b79
Parents: d5bba50
Author: Kahlil Oppenheimer 
Authored: Tue Jun 6 15:53:43 2017 -0400
Committer: tedyu 
Committed: Mon Jun 26 12:40:30 2017 -0700

--
 .../hadoop/hbase/master/balancer/StochasticLoadBalancer.java  | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/74e9d314/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
--
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
index 6f99f44..419f051 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
@@ -1279,8 +1279,9 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
   }
 
   // We normalize locality to be a score between 0 and 1.0 representing 
how good it
-  // is compared to how good it could be
-  locality /= bestLocality;
+  // is compared to how good it could be. If bestLocality is 0, assume 
locality is 100
+  // (and the cost is 0)
+  locality = bestLocality == 0 ? 1 : locality / bestLocality;
 }
 
 @Override
@@ -1291,7 +1292,7 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
 return;
   }
   double localityDelta = getWeightedLocality(region, newEntity) - 
getWeightedLocality(region, oldEntity);
-  double normalizedDelta = localityDelta / bestLocality;
+  double normalizedDelta = bestLocality == 0 ? 0.0 : localityDelta / 
bestLocality;
   locality += normalizedDelta;
 }
 



hbase git commit: HBASE-18164 Fast locality computation in balancer - addendum handles NaN

2017-06-26 Thread tedyu
Repository: hbase
Updated Branches:
  refs/heads/branch-2 44c9c1de9 -> b4c3fe976


HBASE-18164 Fast locality computation in balancer - addendum handles NaN

-Added new LocalityCostFunction and LocalityCandidateGenerator that
cache localities of every region/rack combination and mappings of every
region to its most local server and to its most local rack.

-Made LocalityCostFunction incremental so that it only computes locality
based on most recent region moves/swaps, rather than recomputing the
locality of every region in the cluster at every iteration of the
balancer

-Changed locality cost function to reflect the ratio of:
(Current locality) / (Best locality possible given current cluster)

Signed-off-by: tedyu 


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

Branch: refs/heads/branch-2
Commit: b4c3fe97638a4bcd4d950f6c571315d320ca47f3
Parents: 44c9c1d
Author: Kahlil Oppenheimer 
Authored: Tue Jun 6 15:53:43 2017 -0400
Committer: tedyu 
Committed: Mon Jun 26 12:39:51 2017 -0700

--
 .../hadoop/hbase/master/balancer/StochasticLoadBalancer.java  | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/b4c3fe97/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
--
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
index 63ec0b5..ece9153 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
@@ -1286,8 +1286,9 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
   }
 
   // We normalize locality to be a score between 0 and 1.0 representing 
how good it
-  // is compared to how good it could be
-  locality /= bestLocality;
+  // is compared to how good it could be. If bestLocality is 0, assume 
locality is 100
+  // (and the cost is 0)
+  locality = bestLocality == 0 ? 1 : locality / bestLocality;
 }
 
 @Override
@@ -1298,7 +1299,7 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
 return;
   }
   double localityDelta = getWeightedLocality(region, newEntity) - 
getWeightedLocality(region, oldEntity);
-  double normalizedDelta = localityDelta / bestLocality;
+  double normalizedDelta = bestLocality == 0 ? 0.0 : localityDelta / 
bestLocality;
   locality += normalizedDelta;
 }
 



hbase git commit: HBASE-18164 Fast locality computation in balancer - addendum handles NaN

2017-06-26 Thread tedyu
Repository: hbase
Updated Branches:
  refs/heads/master ed70f15b1 -> 35693f058


HBASE-18164 Fast locality computation in balancer - addendum handles NaN

-Added new LocalityCostFunction and LocalityCandidateGenerator that
cache localities of every region/rack combination and mappings of every
region to its most local server and to its most local rack.

-Made LocalityCostFunction incremental so that it only computes locality
based on most recent region moves/swaps, rather than recomputing the
locality of every region in the cluster at every iteration of the
balancer

-Changed locality cost function to reflect the ratio of:
(Current locality) / (Best locality possible given current cluster)

Signed-off-by: tedyu 


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/35693f05
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/35693f05
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/35693f05

Branch: refs/heads/master
Commit: 35693f0583bd358dc5ecae2d09acb1bbf3676cfa
Parents: ed70f15
Author: Kahlil Oppenheimer 
Authored: Tue Jun 6 15:53:43 2017 -0400
Committer: tedyu 
Committed: Mon Jun 26 12:38:43 2017 -0700

--
 .../hadoop/hbase/master/balancer/StochasticLoadBalancer.java  | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/35693f05/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
--
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
index 63ec0b5..ece9153 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
@@ -1286,8 +1286,9 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
   }
 
   // We normalize locality to be a score between 0 and 1.0 representing 
how good it
-  // is compared to how good it could be
-  locality /= bestLocality;
+  // is compared to how good it could be. If bestLocality is 0, assume 
locality is 100
+  // (and the cost is 0)
+  locality = bestLocality == 0 ? 1 : locality / bestLocality;
 }
 
 @Override
@@ -1298,7 +1299,7 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
 return;
   }
   double localityDelta = getWeightedLocality(region, newEntity) - 
getWeightedLocality(region, oldEntity);
-  double normalizedDelta = localityDelta / bestLocality;
+  double normalizedDelta = bestLocality == 0 ? 0.0 : localityDelta / 
bestLocality;
   locality += normalizedDelta;
 }