[GitHub] [zeppelin] zjffdu commented on a change in pull request #3364: [ZEPPELIN-4155] Unable get available HostAddress in multi-NIC environment
zjffdu commented on a change in pull request #3364: [ZEPPELIN-4155] Unable get available HostAddress in multi-NIC environment URL: https://github.com/apache/zeppelin/pull/3364#discussion_r284523852 ## File path: zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterUtils.java ## @@ -93,22 +97,53 @@ public static TServerSocket createTServerSocket(String portRange) throw new IOException("No available port in the portRange: " + portRange); } + // 1) Multiple NetworkCard will be configured on some servers + // 2) In the docker container environment, A container will also generate multiple virtual NetworkCard Review comment: Could you add java doc to explain the logic ? To me, it seems to involves 2 steps: 1. find all available networkcards 2. loo all the neetworkcards, and use the first non-loopback ip address. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3364: [ZEPPELIN-4155] Unable get available HostAddress in multi-NIC environment
zjffdu commented on a change in pull request #3364: [ZEPPELIN-4155] Unable get available HostAddress in multi-NIC environment URL: https://github.com/apache/zeppelin/pull/3364#discussion_r284523852 ## File path: zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterUtils.java ## @@ -93,22 +97,53 @@ public static TServerSocket createTServerSocket(String portRange) throw new IOException("No available port in the portRange: " + portRange); } + // 1) Multiple NetworkCard will be configured on some servers + // 2) In the docker container environment, A container will also generate multiple virtual NetworkCard Review comment: Could you add java doc to explain the logic ? To me, it seems to involves 2 steps: 1. find all available networkcards 2. loo all the neetworkcards, and use the first non-loop ip address. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3364: [ZEPPELIN-4155] Unable get available HostAddress in multi-NIC environment
zjffdu commented on a change in pull request #3364: [ZEPPELIN-4155] Unable get available HostAddress in multi-NIC environment URL: https://github.com/apache/zeppelin/pull/3364#discussion_r284523852 ## File path: zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterUtils.java ## @@ -93,22 +97,53 @@ public static TServerSocket createTServerSocket(String portRange) throw new IOException("No available port in the portRange: " + portRange); } + // 1) Multiple NetworkCard will be configured on some servers + // 2) In the docker container environment, A container will also generate multiple virtual NetworkCard Review comment: Could you add java doc to explain the logic ? To me, it seems to involves 2 steps: 1. find all available networkcards 2. loop all the neetworkcards, and use the first non-loopback ip address. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3364: [ZEPPELIN-4155] Unable get available HostAddress in multi-NIC environment
zjffdu commented on a change in pull request #3364: [ZEPPELIN-4155] Unable get available HostAddress in multi-NIC environment URL: https://github.com/apache/zeppelin/pull/3364#discussion_r284523456 ## File path: zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterUtils.java ## @@ -93,22 +97,53 @@ public static TServerSocket createTServerSocket(String portRange) throw new IOException("No available port in the portRange: " + portRange); } + // 1) Multiple NetworkCard will be configured on some servers + // 2) In the docker container environment, A container will also generate multiple virtual NetworkCard public static String findAvailableHostAddress() throws UnknownHostException, SocketException { -InetAddress address = InetAddress.getLocalHost(); -if (address.isLoopbackAddress()) { - for (NetworkInterface networkInterface : Collections - .list(NetworkInterface.getNetworkInterfaces())) { -if (!networkInterface.isLoopback()) { - for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses()) { -InetAddress a = interfaceAddress.getAddress(); -if (a instanceof Inet4Address) { - return a.getHostAddress(); -} +List netlist = new ArrayList(); + +// Get all the network cards in the current environment +Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces(); +while (netInterfaces.hasMoreElements()) { + NetworkInterface networkInterface = (NetworkInterface)netInterfaces.nextElement(); + LOGGER.info("networkInterface = " + networkInterface.toString()); Review comment: -> LOGGER.debug 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3364: [ZEPPELIN-4155] Unable get available HostAddress in multi-NIC environment
zjffdu commented on a change in pull request #3364: [ZEPPELIN-4155] Unable get available HostAddress in multi-NIC environment URL: https://github.com/apache/zeppelin/pull/3364#discussion_r284523426 ## File path: zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterUtils.java ## @@ -93,22 +97,53 @@ public static TServerSocket createTServerSocket(String portRange) throw new IOException("No available port in the portRange: " + portRange); } + // 1) Multiple NetworkCard will be configured on some servers + // 2) In the docker container environment, A container will also generate multiple virtual NetworkCard public static String findAvailableHostAddress() throws UnknownHostException, SocketException { -InetAddress address = InetAddress.getLocalHost(); -if (address.isLoopbackAddress()) { - for (NetworkInterface networkInterface : Collections - .list(NetworkInterface.getNetworkInterfaces())) { -if (!networkInterface.isLoopback()) { - for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses()) { -InetAddress a = interfaceAddress.getAddress(); -if (a instanceof Inet4Address) { - return a.getHostAddress(); -} +List netlist = new ArrayList(); + +// Get all the network cards in the current environment +Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces(); +while (netInterfaces.hasMoreElements()) { + NetworkInterface networkInterface = (NetworkInterface)netInterfaces.nextElement(); + LOGGER.info("networkInterface = " + networkInterface.toString()); + if (networkInterface.isLoopback()) { +// Filter lo network card +continue; + } + // When all the network cards are obtained by the above method, + // The order obtained is the reverse of the order of the NICs + // seen in the server with the ifconfig command. + // Therefore, when you want to traverse from the first NIC, + // Need to reverse the elements in Enumeration + netlist.add(0, networkInterface); +} + +for (NetworkInterface list:netlist) { + Enumeration enumInetAddress = list.getInetAddresses(); + + while (enumInetAddress.hasMoreElements()) { +InetAddress ip = (InetAddress) enumInetAddress.nextElement(); +LOGGER.info("ip = " + ip.toString()); Review comment: -> LOGGER.debug 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services