Skip to content

Commit

Permalink
GH-15684 - add stderr log to all error branches
Browse files Browse the repository at this point in the history
  • Loading branch information
valenad1 committed Feb 1, 2024
1 parent 9d523ef commit dc68d67
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions h2o-core/src/main/java/water/init/NetworkInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,23 @@ public class NetworkInit {
public static H2OHttpViewImpl h2oHttpView;

public static InetAddress findInetAddressForSelf() throws Error {
if (H2O.SELF_ADDRESS != null)
if (H2O.SELF_ADDRESS != null && false)
return H2O.SELF_ADDRESS;
else {
if (H2O.ARGS.disable_web && H2O.ARGS.disable_net) {
if (H2O.ARGS.disable_web && H2O.ARGS.disable_net && false) {
// if we don't need an address just use loopback as a filler, SELF_ADDRESS always needs to be defined
return InetAddress.getLoopbackAddress();
}
try {
return HostnameGuesser.findInetAddressForSelf(H2O.ARGS.ip, H2O.ARGS.network);
} catch (HostnameGuesser.HostnameGuessingException e) {
if (e.getCause() != null)
if (e.getCause() != null) {
Log.err(e.getCause());
else
e.getCause().printStackTrace();
} else {
Log.err(e.getMessage());
System.err.println(e.getMessage());
}
H2O.clusterInitializationFailed();
}
}
Expand Down Expand Up @@ -117,7 +120,7 @@ public static void initializeNetworkSockets( ) {

} catch (IOException e) {
Log.trace("Cannot allocate API port " + H2O.API_PORT + " because of following exception: ", e);
if( apiSocket != null ) try { apiSocket.close(); } catch( IOException ohwell ) { Log.err(ohwell); }
if( apiSocket != null ) try { apiSocket.close(); } catch( IOException ohwell ) { Log.err(ohwell); ohwell.printStackTrace();}
if( _tcpSocket != null ) try { _tcpSocket.close(); } catch( IOException ie ) { }
apiSocket = null;
_tcpSocket = null;
Expand All @@ -130,7 +133,9 @@ public static void initializeNetworkSockets( ) {
// Try next available port to bound
H2O.API_PORT += (H2O.ARGS.port_offset == 1) ? 2 : 1;
if (H2O.API_PORT > (1<<16)) {
Log.err("Cannot find free port for " + H2O.SELF_ADDRESS + " from baseport = " + H2O.ARGS.baseport);
String msg = "Cannot find free port for " + H2O.SELF_ADDRESS + " from baseport = " + H2O.ARGS.baseport;
Log.err(msg);
System.err.println(msg);
H2O.exit(-1);
}
}
Expand All @@ -156,8 +161,11 @@ public static void initializeNetworkSockets( ) {
embeddedConfigFlatfile = ec.fetchFlatfile();
}
catch (Exception e) {
Log.err("Failed to get embedded config flatfile");
String msg = "Failed to get embedded config flatfile";
Log.err(msg);
Log.err(e);
System.err.println(msg);
e.printStackTrace();
H2O.exit(1);
}
}
Expand Down Expand Up @@ -283,6 +291,7 @@ private static InetAddress getInetAddress(String ip) {
addr = InetAddress.getByName(ip);
} catch (UnknownHostException e) {
Log.err(e);
e.printStackTrace();
H2O.exit(-1);
}
return addr;
Expand Down Expand Up @@ -319,7 +328,7 @@ static private void multicast2( ByteBuffer bb, byte priority ) {
// awake from sleep.
if( H2O.CLOUD_MULTICAST_SOCKET != null )
try { H2O.CLOUD_MULTICAST_SOCKET.close(); }
catch( Exception e2 ) { Log.err("Got",e2); }
catch( Exception e2 ) { Log.err("Got",e2); System.err.println("Got"); e.printStackTrace();}
finally { H2O.CLOUD_MULTICAST_SOCKET = null; }
}
}
Expand Down

0 comments on commit dc68d67

Please sign in to comment.