virajjasani commented on a change in pull request #1926:
URL: https://github.com/apache/hbase/pull/1926#discussion_r451599800
##
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/HDFSBlocksDistribution.java
##
@@ -228,33 +228,49 @@ public long getUniqueBlocksTotalWeight() {
* Implementations 'visit' hostAndWeight.
*/
public interface Visitor {
-float visit(final HostAndWeight hostAndWeight);
+long visit(final HostAndWeight hostAndWeight);
}
/**
* @param host the host name
* @return the locality index of the given host
*/
public float getBlockLocalityIndex(String host) {
-return getBlockLocalityIndexInternal(host,
- e -> (float) e.weight / (float) uniqueBlocksTotalWeight);
+return (float) getBlocksLocalityWeightInternal(host, e -> e.weight)
+ / (float) uniqueBlocksTotalWeight;
}
/**
* @param host the host name
* @return the locality index with ssd of the given host
*/
public float getBlockLocalityIndexForSsd(String host) {
-return getBlockLocalityIndexInternal(host,
- e -> (float) e.weightForSsd / (float) uniqueBlocksTotalWeight);
+return (float) getBlocksLocalityWeightInternal(host, e -> e.weightForSsd)
+ / (float) uniqueBlocksTotalWeight;
+ }
+
+ /**
+ * @param host the host name
+ * @return the blocks local weight of the given host
+ */
+ public long getBlocksLocalWeight(String host) {
+return getBlocksLocalityWeightInternal(host, e -> e.weight);
Review comment:
same here
##
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/HDFSBlocksDistribution.java
##
@@ -228,33 +228,49 @@ public long getUniqueBlocksTotalWeight() {
* Implementations 'visit' hostAndWeight.
*/
public interface Visitor {
-float visit(final HostAndWeight hostAndWeight);
+long visit(final HostAndWeight hostAndWeight);
}
/**
* @param host the host name
* @return the locality index of the given host
*/
public float getBlockLocalityIndex(String host) {
-return getBlockLocalityIndexInternal(host,
- e -> (float) e.weight / (float) uniqueBlocksTotalWeight);
+return (float) getBlocksLocalityWeightInternal(host, e -> e.weight)
+ / (float) uniqueBlocksTotalWeight;
}
/**
* @param host the host name
* @return the locality index with ssd of the given host
*/
public float getBlockLocalityIndexForSsd(String host) {
-return getBlockLocalityIndexInternal(host,
- e -> (float) e.weightForSsd / (float) uniqueBlocksTotalWeight);
+return (float) getBlocksLocalityWeightInternal(host, e -> e.weightForSsd)
Review comment:
same here: `getBlocksLocalityWeightInternal(host,
HostAndWeight::getWeightForSsd)`
##
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/HDFSBlocksDistribution.java
##
@@ -228,33 +228,49 @@ public long getUniqueBlocksTotalWeight() {
* Implementations 'visit' hostAndWeight.
*/
public interface Visitor {
-float visit(final HostAndWeight hostAndWeight);
+long visit(final HostAndWeight hostAndWeight);
}
/**
* @param host the host name
* @return the locality index of the given host
*/
public float getBlockLocalityIndex(String host) {
-return getBlockLocalityIndexInternal(host,
- e -> (float) e.weight / (float) uniqueBlocksTotalWeight);
+return (float) getBlocksLocalityWeightInternal(host, e -> e.weight)
Review comment:
Can we use method reference here: `getBlocksLocalityWeightInternal(host,
HostAndWeight::getWeight)` ?
##
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/HDFSBlocksDistribution.java
##
@@ -228,33 +228,49 @@ public long getUniqueBlocksTotalWeight() {
* Implementations 'visit' hostAndWeight.
*/
public interface Visitor {
-float visit(final HostAndWeight hostAndWeight);
+long visit(final HostAndWeight hostAndWeight);
}
/**
* @param host the host name
* @return the locality index of the given host
*/
public float getBlockLocalityIndex(String host) {
-return getBlockLocalityIndexInternal(host,
- e -> (float) e.weight / (float) uniqueBlocksTotalWeight);
+return (float) getBlocksLocalityWeightInternal(host, e -> e.weight)
+ / (float) uniqueBlocksTotalWeight;
}
/**
* @param host the host name
* @return the locality index with ssd of the given host
*/
public float getBlockLocalityIndexForSsd(String host) {
-return getBlockLocalityIndexInternal(host,
- e -> (float) e.weightForSsd / (float) uniqueBlocksTotalWeight);
+return (float) getBlocksLocalityWeightInternal(host, e -> e.weightForSsd)
+ / (float) uniqueBlocksTotalWeight;
+ }
+
+ /**
+ * @param host the host name
+ * @return the blocks local weight of the given host
+ */
+ public long getBlocksLocalWeight(String host) {
+return getBlocksLocalityWeightInternal(host, e ->