Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,19 @@ protected SubClusterId chooseSubCluster(
Map<SubClusterIdInfo, Float> weights = getPolicyInfo().getRouterPolicyWeights();
SubClusterIdInfo chosen = null;
long currBestMem = -1;
long currBestVcore = -1;
for (Map.Entry<SubClusterId, SubClusterInfo> entry : preSelectSubclusters.entrySet()) {
SubClusterIdInfo id = new SubClusterIdInfo(entry.getKey());
if (weights.containsKey(id) && weights.get(id) > 0) {
long availableMemory = getAvailableMemory(entry.getValue());
if (availableMemory > currBestMem) {
long availableVcore = getAvailableVcore(entry.getValue());
if (availableMemory > currBestMem && availableVcore > currBestVcore) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (availableMemory > currBestMem) {
 ....
}

This code is needed to select the largest subcluster of availableMemory. Memory is a more strictly limited resource, because without memory, the application cannot execute. Sufficient memory can also be considered as the cluster is idle.

If we add cpu constraints (availableVcore), subclusters with smaller memory may be selected, which is not an expected situation.

currBestMem = availableMemory;
currBestVcore = availableVcore;
chosen = id;
} else if (availableMemory > currBestMem) {
currBestMem = availableMemory;
currBestVcore = availableVcore;
chosen = id;
}
}
Expand All @@ -93,4 +100,15 @@ private long getAvailableMemory(SubClusterInfo value) throws YarnException {
throw new YarnException("FederationSubClusterInfo cannot be parsed", j);
}
}

private long getAvailableVcore(SubClusterInfo value) throws YarnException {
try {
long vcore = -1;
JSONObject obj = new JSONObject(value.getCapability());
vcore = obj.getJSONObject("clusterMetrics").getLong("availableVirtualCores");
return vcore;
} catch (JSONException j) {
throw new YarnException("FederationSubClusterInfo cannot be parsed", j);
}
}
}