Skip to content
This repository was archived by the owner on Apr 1, 2024. It is now read-only.

Commit c36c18d

Browse files
authored
[improve][broker] Change log level to reduce duplicated logs (apache#22147)
1 parent b8d53aa commit c36c18d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LinuxInfoUtils.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,20 @@ private static boolean isPhysicalNic(Path nicPath) {
198198
return false;
199199
}
200200
// Check the type to make sure it's ethernet (type "1")
201-
String type = readTrimStringFromFile(nicPath.resolve("type"));
201+
final Path nicTypePath = nicPath.resolve("type");
202+
if (!Files.exists(nicTypePath)) {
203+
if (log.isDebugEnabled()) {
204+
log.debug("Failed to read NIC type, the expected linux type file does not exist."
205+
+ " nic_type_path={}", nicTypePath);
206+
}
207+
return false;
208+
}
202209
// wireless NICs don't report speed, ignore them.
203-
return Integer.parseInt(type) == ARPHRD_ETHER;
204-
} catch (Exception e) {
205-
log.warn("[LinuxInfo] Failed to read {} NIC type, the detail is: {}", nicPath, e.getMessage());
206-
// Read type got error.
210+
return Integer.parseInt(readTrimStringFromFile(nicTypePath)) == ARPHRD_ETHER;
211+
} catch (Exception ex) {
212+
if (log.isDebugEnabled()) {
213+
log.debug("Failed to read NIC type. nic_path={}", nicPath, ex);
214+
}
207215
return false;
208216
}
209217
}

0 commit comments

Comments
 (0)