anuragp010 commented on code in PR #11866:
URL: https://github.com/apache/ozone/pull/11866#discussion_r4514713023
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerClusterSnapshot.java:
##########
Review Comment:
The class now holds two meanings of `maxUtilization`, `imbalance` and
`bytesToMove`: the whole cluster level in the legacy path, and one storage type
in the new path. In the JSON, for example, if:
- DISK has node A with utilization=50 and node b with utilization = 10.
- SSD has node A with utilization=95 and node b with utilization = 65.
Because we choose the `maxUtilization` and `minUtilization` based on the the
storageType with the most imbalance, `maxUtilizationPercentage` can be 50.0 but
a listed source node shows 95% as utilization.
Would it be easier to read if we had a per-type class (eg:
StorageTypeSnapshot) and then keep `ContainerBalancerClusterSnapshot` for
cluster level details with member names such as totalBytesToMove, maxImbalance,
topSourceNodesAcrossStorageTypes etc? Would this have any side-effects?
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerAdvisor.java:
##########
@@ -154,6 +154,15 @@ private static ContainerBalancerEstimation
estimateForProfile(OzoneConfiguration
maxSizeLeavingSource,
maxSizeEnteringTarget,
involved);
+ if (!snapshot.getStorageTypeSnapshots().isEmpty()) {
+ long storageTypeCapacity = 0;
+ for (ContainerBalancerClusterSnapshot type :
snapshot.getStorageTypeSnapshots().values()) {
Review Comment:
nit: Could we rename `ContainerBalancerClusterSnapshot type` to
`typeSnapshot`? type reads like a StorageType. Similar usage is also present in
`ContainerBalancerAssessmentSubcommand`.
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerAdvisor.java:
##########
@@ -154,6 +154,15 @@ private static ContainerBalancerEstimation
estimateForProfile(OzoneConfiguration
maxSizeLeavingSource,
maxSizeEnteringTarget,
involved);
+ if (!snapshot.getStorageTypeSnapshots().isEmpty()) {
+ long storageTypeCapacity = 0;
Review Comment:
`storageTypeCapacity` looks like the sum, over storage types, of the bytes
that can move in one iteration, not a capacity. Should we rename it, for
example `perIterationBytesAcrossStorageTypes`?
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerClusterAnalyzer.java:
##########
@@ -195,12 +237,63 @@ public static ContainerBalancerClusterSnapshot analyze(
.setTargetCount(targets.size())
.setTotalOverUtilizedBytes(totalOverUtilizedBytes)
.setTotalUnderUtilizedBytes(totalUnderUtilizedBytes)
+ .setBytesToMove(storageType != null && (sources.isEmpty() ||
targets.isEmpty()) ? 0 : totalOverUtilizedBytes)
+ .setSourceDatanodes(sourceDatanodes)
+ .setTargetDatanodes(targetDatanodes)
.setImbalance(imbalance)
.setTopSourceNodes(topNodes(sources, topNodeLimit))
.setBottomTargetNodes(topNodes(targets, topNodeLimit))
.build();
}
+ private static ContainerBalancerClusterSnapshot
combineStorageTypes(ContainerBalancerClusterSnapshot overall,
+ Map<StorageType, ContainerBalancerClusterSnapshot> snapshots, int
topNodeLimit, boolean incomplete) {
+ Set<String> sources = new HashSet<>();
+ Set<String> targets = new HashSet<>();
+ Map<String, NodeUtilization> topSources = new HashMap<>();
+ Map<String, NodeUtilization> bottomTargets = new HashMap<>();
+ long overBytes = 0, underBytes = 0, bytesToMove = 0;
+ double max = 0, min = 0, imbalance = -1;
+ for (ContainerBalancerClusterSnapshot snapshot : snapshots.values()) {
+ sources.addAll(snapshot.getSourceDatanodes());
+ targets.addAll(snapshot.getTargetDatanodes());
+ for (NodeUtilization node : snapshot.getTopSourceNodes()) {
+ topSources.merge(node.getDatanodeId(), node,
+ (a, b) -> a.getUtilization() >= b.getUtilization() ? a : b);
+ }
+ for (NodeUtilization node : snapshot.getBottomTargetNodes()) {
+ bottomTargets.merge(node.getDatanodeId(), node,
+ (a, b) -> a.getUtilization() <= b.getUtilization() ? a : b);
+ }
+ overBytes += snapshot.getTotalOverUtilizedBytes();
+ underBytes += snapshot.getTotalUnderUtilizedBytes();
+ bytesToMove += snapshot.getBytesToMove();
+ if (snapshot.getImbalance() > imbalance) {
Review Comment:
`max`, `min` and `imbalance` would be coming from a single storageType, but
the output doesn't highlight which `storageType`. Would it be useful to
highlight which `storageType` this comes from?
##########
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/scm/container/balancer/TestContainerBalancerClusterAnalyzer.java:
##########
@@ -40,6 +43,102 @@ public final class TestContainerBalancerClusterAnalyzer {
private static final double THRESHOLD = 0.10;
+ @Test
+ void testOppositeStorageTypeImbalancesAreNotHiddenByWholeNodeTotals() {
Review Comment:
Should we add a test where a datanode can be a source for multiple
storageTypes and validate the resulting `ContainerBalancerClusterSnapshot`? For
example `typedProto("a", 5, 60), ("b", 20, 80), ("c", 35, 100)` should result
in `getSourceCount() `= 1 .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]