You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@omid.apache.org by yo...@apache.org on 2019/01/29 13:58:09 UTC
[incubator-omid] 03/04: [OMID-123] Allow starting Omid on machines
without en or eth interfaces.
This is an automated email from the ASF dual-hosted git repository.
yonigo pushed a commit to branch 1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-omid.git
commit 6a812979360a5f9930893769cb664fba151b3a45
Author: Yonatan Gottesman <yo...@gmail.com>
AuthorDate: Fri Jan 4 12:33:13 2019 +0200
[OMID-123] Allow starting Omid on machines without en or eth interfaces.
---
common/src/main/java/org/apache/omid/NetworkUtils.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/common/src/main/java/org/apache/omid/NetworkUtils.java b/common/src/main/java/org/apache/omid/NetworkUtils.java
index 751a733..5d7bce2 100644
--- a/common/src/main/java/org/apache/omid/NetworkUtils.java
+++ b/common/src/main/java/org/apache/omid/NetworkUtils.java
@@ -36,15 +36,22 @@ public class NetworkUtils {
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
+ String fallBackName = null;
while (networkInterfaces.hasMoreElements()) {
NetworkInterface nextElement = networkInterfaces.nextElement();
String name = nextElement.getDisplayName();
LOG.info("Iterating over network interfaces, found '{}'", name);
boolean hasInet = Collections.list(nextElement.getInetAddresses()).size() > 1; // Checking that inet exists, to avoid taking iBridge
+ if (hasInet && fallBackName == null) {
+ fallBackName = name;
+ }
if ((name.startsWith(MAC_TSO_NET_IFACE_PREFIX) && hasInet ) ||
name.startsWith(LINUX_TSO_NET_IFACE_PREFIX)) {
return name;
- }
+ }
+ }
+ if (fallBackName != null) {
+ return fallBackName;
}
} catch (SocketException ignored) {
throw new RuntimeException("Failed to find any network interfaces", ignored);