Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][branch-2.9] Fix wrong unit of NIC speed on linux #15770

Merged
merged 2 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
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 @@ -248,7 +248,7 @@ private Path getNicSpeedPath(String nic) {
private double getTotalNicLimitKbps(List<String> nics) {
// Use the override value as configured. Return the total max speed across all available NICs, converted
// from Gbps into Kbps
return overrideBrokerNicSpeedGbps.map(aDouble -> aDouble * nics.size() * 1024 * 1024)
return overrideBrokerNicSpeedGbps.map(aDouble -> aDouble * nics.size() * 1000 * 1000)
.orElseGet(() -> nics.stream().mapToDouble(nicPath -> {
// Nic speed is in Mbits/s, return kbits/s
try {
Expand All @@ -258,7 +258,7 @@ private double getTotalNicLimitKbps(List<String> nics) {
+ " config [loadBalancerOverrideBrokerNicSpeedGbps] to override it.", nicPath), e);
return 0d;
}
}).sum() * 1024);
}).sum() * 1000);
}

private Path getNicTxPath(String nic) {
Expand All @@ -277,7 +277,7 @@ private double getTotalNicUsageRxKb(List<String> nics) {
log.error("Failed to read rx_bytes for NIC " + s, e);
return 0d;
}
}).sum() * 8 / 1024;
}).sum() * 8d / 1000;
}

private double getTotalNicUsageTxKb(List<String> nics) {
Expand All @@ -288,7 +288,7 @@ private double getTotalNicUsageTxKb(List<String> nics) {
log.error("Failed to read tx_bytes for NIC " + s, e);
return 0d;
}
}).sum() * 8 / 1024;
}).sum() * 8d / 1000;
}

private static long readLongFromFile(String path) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void checkLoadReportNicSpeed() throws Exception {
LoadManagerReport report = admin.brokerStats().getLoadReport();

if (SystemUtils.IS_OS_LINUX) {
assertEquals(report.getBandwidthIn().limit, nicCount * 5.4 * 1024 * 1024);
assertEquals(report.getBandwidthOut().limit, nicCount * 5.4 * 1024 * 1024);
assertEquals(report.getBandwidthIn().limit, nicCount * 5.4 * 1000 * 1000);
assertEquals(report.getBandwidthOut().limit, nicCount * 5.4 * 1000 * 1000);
} else {
// On non-Linux system we don't report the network usage
assertEquals(report.getBandwidthIn().limit, -1.0);
Expand Down