JacksonYao287 commented on pull request #2756:
URL: https://github.com/apache/ozone/pull/2756#issuecomment-983448371
thanks @lokeshj1703 very much for the review!
>I think it is better to have a separated ContainerBalancerSelectionCriteria
as it gives flexibility later to account both source and target limitations in
the criteria.
for now , the only role of ContainerBalancerSelectionCriteria is to get
Candidate Containers. but i agree with you. may be later in the future, we need
to do some flexible work in ContainerBalancerSelectionCriteria. so let us keep
it for now and i will cancel this refactor.
so in this patch , i will only do the network topology related work. so i
want to hear your opinion, should we sorting candidate targets by network
first, or make it configurable?
if we sort candidate targets by network first, we will then use a common
list instead of current Treeset to hold all the candidate targets, and we
should sort all the candidate targets for each source datanode with a function
, for example:
```
List<DatanodeUsageInfo> potentialTargets;
DatanodeUsageInfo source;
NetworkTopology nt = scm.getClusterMap();
//for each source, we should sort
potentialTargets.sort((a, b) -> {
// sort by network topology first
int ret = 0;
int distancetoA = nt.getDistanceCost(source, a);
int distancetoB = nt.getDistanceCost(source, b);
ret = distancetoA - distancetoB;
if (ret != 0) {
return ret;
}
// if network distance is equal, sort by usage
double currentUsageOfA = a.calculateUtilization(
sizeEnteringNode.get(a.getDatanodeDetails()));
double currentUsageOfB = b.calculateUtilization(
sizeEnteringNode.get(b.getDatanodeDetails()));
ret = Double.compare(currentUsageOfA, currentUsageOfB);
if (ret != 0) {
return ret;
}
UUID uuidA = a.getDatanodeDetails().getUuid();
UUID uuidB = b.getDatanodeDetails().getUuid();
return uuidA.compareTo(uuidB);
})
```
--
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]