mattisonchao commented on a change in pull request #14537:
URL: https://github.com/apache/pulsar/pull/14537#discussion_r817714902
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LinuxBrokerHostUsageImpl.java
##########
@@ -252,10 +252,22 @@ private double getTotalNicLimitKbps(List<String> nics) {
.orElseGet(() -> nics.stream().mapToDouble(nicPath -> {
// Nic speed is in Mbits/s, return kbits/s
try {
- return Double.parseDouble(new
String(Files.readAllBytes(getNicSpeedPath(nicPath))));
+ final Path nicSpeedPath = getNicSpeedPath(nicPath);
+ return readDoubleFromPath(nicSpeedPath);
} catch (IOException e) {
- log.error(String.format("Failed to read speed for nic
%s, maybe you can set broker"
- + " config
[loadBalancerOverrideBrokerNicSpeedGbps] to override it.", nicPath), e);
+ // "speed" is not supported by all the types of NIC
+ //
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net
+ // Linux raises "Invalid argument" message error in
case "speed" file doesn't exist or
+ // is not readable
+ if (e.getCause() == null && "Invalid
argument".equals(e.getMessage())) {
+ log.warn("Failed to read speed for nic {}, the OS
raised a 'Invalid argument' error." +
+ " Maybe you can set broker config
[loadBalancerOverrideBrokerNicSpeedGbps] " +
+ "to override it.", nicPath);
+ } else {
+ log.error(String.format("Failed to read speed for
nic %s, maybe you can set broker"
Review comment:
Maybe it's better to print the error message?
--
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]