You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/02/17 10:41:30 UTC

[GitHub] [pulsar] mattisonchao commented on a change in pull request #14340: [LoadBalance] Optimize find nics process.

mattisonchao commented on a change in pull request #14340:
URL: https://github.com/apache/pulsar/pull/14340#discussion_r808909669



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LinuxBrokerHostUsageImpl.java
##########
@@ -227,23 +227,28 @@ public int getNicCount() {
     }
 
     private boolean isPhysicalNic(Path path) {
-        if (!path.toString().contains("/virtual/")) {
-            try {
-                Files.readAllBytes(path.resolve("speed"));
-                return true;
-            } catch (Exception e) {
-                // In some cases, VMs in EC2 won't have the speed reported on the NIC and will give a read-error.
-                // Check the type to make sure it's ethernet (type "1")
+        if (path.toString().contains("/virtual/")) {
+            return false;
+        }
+        try {
+            // Check the type to make sure it's ethernet (type "1")
+            String type = new String(Files.readAllBytes(path.resolve("type")), StandardCharsets.UTF_8).trim();
+            if (Integer.parseInt(type) == 1) {
                 try {
-                    String type = new String(Files.readAllBytes(path.resolve("type")), StandardCharsets.UTF_8).trim();
-                    return Integer.parseInt(type) == 1;
+                    Files.readAllBytes(path.resolve("speed"));

Review comment:
       Yes, you are right.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org