Skip to content

Commit c432459

Browse files
author
cypof
committed
Removed duplicate message about multiple local IPs
1 parent 72cfb09 commit c432459

File tree

8 files changed

+26
-117
lines changed

8 files changed

+26
-117
lines changed

build.xml

-102
This file was deleted.

h2o_on_ec2

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#!/usr/bin/env bash
1+
#!/bin/bash
22

33
java -cp target/h2o.jar water.Boot -mainClass water.deploy.EC2 $@

h2o_on_hadoop

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#!/usr/bin/env bash
1+
#!/bin/bash
22

33
java -cp target/h2o.jar water.Boot -mainClass water.deploy.Hadoop $@

h2o_on_localhost

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
java -cp target/h2o.jar water.Boot $@

src/main/java/water/H2O.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public final class H2O {
5151

5252
// Myself, as a Node in the Cloud
5353
public static H2ONode SELF = null;
54+
public static InetAddress SELF_ADDRESS;
5455

5556
// Initial arguments
5657
public static String[] ARGS;
@@ -168,7 +169,7 @@ public int D( Key key, int repl ) {
168169
return Arrays.toString(_memary);
169170
}
170171

171-
public static InetAddress findInetAddressForSelf() throws Error {
172+
private static InetAddress findInetAddressForSelf() throws Error {
172173
// Get a list of all valid IPs on this machine. Typically 1 on Mac or
173174
// Windows, but could be many on Linux or if a hypervisor is present.
174175
ArrayList<InetAddress> ips = new ArrayList<InetAddress>();
@@ -515,6 +516,8 @@ public static void main( String[] args ) {
515516
ARGS = arguments.toStringArray();
516517
ParseDataset.PLIMIT = OPT_ARGS.pparse_limit;
517518

519+
SELF_ADDRESS = findInetAddressForSelf();
520+
518521
//if (OPT_ARGS.rshell.equals("false"))
519522
Log.wrap(); // Logging does not wrap when the rshell is on.
520523

@@ -632,7 +635,6 @@ private static void startupFinalize() {
632635
// function of the name. Parse node ip addresses from the filename.
633636
static void initializeNetworkSockets( ) {
634637
// Assign initial ports
635-
InetAddress inet = findInetAddressForSelf();
636638
API_PORT = OPT_ARGS.port != 0 ? OPT_ARGS.port : DEFAULT_PORT;
637639

638640
while (true) {
@@ -651,23 +653,23 @@ static void initializeNetworkSockets( ) {
651653
_apiSocket = new ServerSocket(API_PORT);
652654
_udpSocket = DatagramChannel.open();
653655
_udpSocket.socket().setReuseAddress(true);
654-
_udpSocket.socket().bind(new InetSocketAddress(inet, UDP_PORT));
656+
_udpSocket.socket().bind(new InetSocketAddress(SELF_ADDRESS, UDP_PORT));
655657
break;
656658
} catch (IOException e) {
657659
try { if( _apiSocket != null ) _apiSocket.close(); } catch( IOException ohwell ) { Log.err(ohwell); }
658660
Closeables.closeQuietly(_udpSocket);
659661
_apiSocket = null;
660662
_udpSocket = null;
661663
if( OPT_ARGS.port != 0 )
662-
Log.die("On " + H2O.findInetAddressForSelf() +
664+
Log.die("On " + SELF_ADDRESS +
663665
" some of the required ports " + (OPT_ARGS.port+0) +
664666
", " + (OPT_ARGS.port+1) +
665667
" are not available, change -port PORT and try again.");
666668
}
667669
API_PORT += 2;
668670
}
669-
SELF = H2ONode.self(inet);
670-
Log.info("Internal communication uses port: ",UDP_PORT,"\nListening for HTTP and REST traffic on http:/",inet,":"+_apiSocket.getLocalPort()+"/");
671+
SELF = H2ONode.self(SELF_ADDRESS);
672+
Log.info("Internal communication uses port: ",UDP_PORT,"\nListening for HTTP and REST traffic on http:/",SELF_ADDRESS,":"+_apiSocket.getLocalPort()+"/");
671673

672674
NAME = OPT_ARGS.name==null? System.getProperty("user.name") : OPT_ARGS.name;
673675
// Read a flatfile of allowed nodes

src/main/java/water/deploy/VM.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.apache.commons.codec.binary.Base64;
1111

12+
import water.H2O;
1213
import water.util.Log;
1314

1415
/**
@@ -152,7 +153,7 @@ private static void forward(Process process, final String header, InputStream so
152153
}
153154

154155
public static String localIP() {
155-
return Log.HOST;
156+
return H2O.SELF_ADDRESS.getHostAddress();
156157
}
157158

158159
/**

src/main/java/water/util/Log.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,13 @@ static public void wrap() {
7373
public final static Key LOG_KEY = Key.make("Log", (byte) 0, Key.BUILT_IN_KEY);
7474
/** Time from when this class loaded. */
7575
static final Timer time = new Timer();
76-
/** IP address of the host */
77-
public static final String HOST = H2O.findInetAddressForSelf().getHostAddress();
7876
/** Some guess at the process ID. */
7977
public static final long PID = getPid();
80-
/** Hostname and process ID. */
81-
private static final String HOST_AND_PID = "" + fixedLength(HOST + " ", 13) + fixedLength(PID + " ", 6);
78+
8279
private static final String LONG_HEADERS_PARAM = "long_log_headers";
8380
private static final boolean LONG_HEADERS = System.getProperty(LONG_HEADERS_PARAM) != null;
81+
private static String _longHeaders;
82+
8483
private static boolean printAll;
8584
/** Per subsystem debugging flags. */
8685
static {
@@ -213,7 +212,13 @@ private String body(int headroom) {
213212
}
214213

215214
private StringBuilder longHeader(StringBuilder buf) {
216-
buf.append(when.startAsString()).append(" ").append(HOST_AND_PID);
215+
String headers = _longHeaders;
216+
if(headers == null) {
217+
String host = H2O.SELF_ADDRESS != null ? H2O.SELF_ADDRESS.getHostAddress() : "";
218+
headers = fixedLength(host + " ", 16) + fixedLength(PID + " ", 6);
219+
if(H2O.SELF_ADDRESS != null) _longHeaders = headers;
220+
}
221+
buf.append(when.startAsString()).append(" ").append(headers);
217222
if( thread == null ) thread = fixedLength(Thread.currentThread().getName() + " ", 10);
218223
buf.append(thread);
219224
buf.append(kind.toString()).append(" ").append(sys.toString()).append(": ");

src/test/java/water/Sandbox.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static void localCloud(int nodes, boolean inProcess, String[] args) {
6161
}
6262

6363
public static void localMasterRemoteWorkers(String[] workers, String[] args) {
64-
String local = H2O.findInetAddressForSelf().getHostAddress();
64+
String local = H2O.SELF_ADDRESS.getHostAddress();
6565
int port = 54321;
6666
String flat = local + ":" + port + '\n';
6767
for( int i = 0; i < workers.length; i++ )

0 commit comments

Comments
 (0)