Skip to content

Commit

Permalink
Print a handy message (Open H2O Flow in your web browser) when the cl…
Browse files Browse the repository at this point in the history
…uster

comes up like Sparkling Water does.

To prevent lots of messages crossing each other, don't print this until all
the nodes have checked in with the full cluster size.  The code used to
"finish" after the first node checked in with the full cluster size.
This should not make any difference to the user, both behaviors are correct.
  • Loading branch information
tomkraljevic committed Jul 26, 2015
1 parent 8a30702 commit 2a926c0
Showing 1 changed file with 25 additions and 4 deletions.
Expand Up @@ -81,6 +81,9 @@ public class h2odriver extends Configured implements Tool {
volatile boolean clusterHasNodeWithLocalhostIp = false;
volatile boolean shutdownRequested = false;
volatile AtomicInteger numNodesStarted = new AtomicInteger();
volatile AtomicInteger numNodesReportingFullCloudSize = new AtomicInteger();
volatile String clusterIp = null;
volatile int clusterPort = -1;

public void setShutdownRequested() {
shutdownRequested = true;
Expand All @@ -90,6 +93,16 @@ public boolean getShutdownRequested() {
return shutdownRequested;
}

public void setClusterIpPort(String ip, int port) {
clusterIp = ip;
clusterPort = port;
}

public String getClusterUrl() {
String scheme = (jksFileName == null) ? "http" : "https";
return scheme + "://" + clusterIp + ":" + clusterPort;
}

public boolean usingYarn() {
Class clazz = null;
try {
Expand Down Expand Up @@ -263,11 +276,15 @@ else if (type == MapperToDriverMessage.TYPE_CLOUD_SIZE) {
// Do this under a synchronized block to avoid getting multiple cluster ready notification files.
synchronized (h2odriver.class) {
if (! clusterIsUp) {
if (clusterReadyFileName != null) {
createClusterReadyFile(msg.getEmbeddedWebServerIp(), msg.getEmbeddedWebServerPort());
System.out.println("Cluster notification file (" + clusterReadyFileName + ") created.");
int n = numNodesReportingFullCloudSize.incrementAndGet();
if (n == numNodes) {
if (clusterReadyFileName != null) {
createClusterReadyFile(msg.getEmbeddedWebServerIp(), msg.getEmbeddedWebServerPort());
System.out.println("Cluster notification file (" + clusterReadyFileName + ") created.");
}
setClusterIpPort(msg.getEmbeddedWebServerIp(), msg.getEmbeddedWebServerPort());
clusterIsUp = true;
}
clusterIsUp = true;
}
}
}
Expand Down Expand Up @@ -1138,12 +1155,16 @@ else if (rv != 0) {
// status stuff in H2O has settled down.
Thread.sleep(CLOUD_FORMATION_SETTLE_DOWN_SECONDS);

System.out.println("Open H2O Flow in your web browser: " + getClusterUrl());
System.out.println("Disowning cluster and exiting.");
Runtime.getRuntime().removeShutdownHook(ctrlc);
return 0;
}

System.out.println("(Note: Use the -disown option to exit the driver after cluster formation)");
System.out.println("");
System.out.println("Open H2O Flow in your web browser: " + getClusterUrl());
System.out.println("");
System.out.println("(Press Ctrl-C to kill the cluster)");
System.out.println("Blocking until the H2O cluster shuts down...");
waitForClusterToShutdown();
Expand Down

0 comments on commit 2a926c0

Please sign in to comment.