Skip to content

Commit

Permalink
[SW-1005] Use correct scheme in sparkling water when ssl on flow is e…
Browse files Browse the repository at this point in the history
…nabled (#905)
  • Loading branch information
jakubhava committed Aug 16, 2018
1 parent 1d6a904 commit e4938cb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala/org/apache/spark/h2o/H2OContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class H2OContext private(val sparkSession: SparkSession, conf: H2OConf) extends
}

/** Open H2O Flow running in this client. */
def openFlow(): Unit = openURI(sparkContext, s"http://$h2oLocalClient")
def openFlow(): Unit = openURI(sparkContext, s"${getScheme(_conf)}://$h2oLocalClient")

override def toString: String = {
val basic =
Expand All @@ -327,7 +327,7 @@ class H2OContext private(val sparkSession: SparkSession, conf: H2OConf) extends
| ${h2oNodes.mkString("\n ")}
| ------------------------
|
| Open H2O Flow in browser: http://$h2oLocalClient (CMD + click in Mac OSX)
| Open H2O Flow in browser: ${getScheme(_conf)}://$h2oLocalClient (CMD + click in Mac OSX)
|
""".stripMargin
val sparkYarnAppId = if (sparkContext.master.toLowerCase.startsWith("yarn")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.util.Date
import java.util.zip.{ZipEntry, ZipOutputStream}

import org.apache.spark.SparkContext
import org.apache.spark.h2o.BuildInfo
import org.apache.spark.h2o.{BuildInfo, H2OConf}
import org.apache.spark.internal.Logging
import water.H2O
import water.fvec.Frame
Expand Down Expand Up @@ -53,6 +53,14 @@ private[spark] trait H2OContextUtils extends Logging {
}
}

def getScheme(hc: H2OConf) = {
if (hc.jks.isDefined && hc.jksPass.isDefined) {
"https"
} else {
"http"
}
}

/**
* Return true if running inside spark/sparkling water test.
*
Expand Down
11 changes: 6 additions & 5 deletions py/pysparkling/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,15 @@ def __do_init(self, spark_session):
self.is_initialized = False

def __default_h2o_connect(h2o_context, **kwargs):
schema = h2o_context._jhc.h2oContext().getScheme(h2o_context._jhc.h2oContext()._conf())
https = False
if schema == "https":
https = True
if h2o_context._conf.context_path() is not None:
schema = "http"
if "https" in kwargs:
schema = "https"
url = "{}://{}:{}/{}".format(schema, h2o_context._client_ip, h2o_context._client_port, h2o_context._conf.context_path())
return h2o.connect(url=url, **kwargs)
return h2o.connect(url=url, https=https, **kwargs)
else:
return h2o.connect(ip=h2o_context._client_ip, port=h2o_context._client_port, **kwargs)
return h2o.connect(ip=h2o_context._client_ip, port=h2o_context._client_port, https=https,**kwargs)


@staticmethod
Expand Down

0 comments on commit e4938cb

Please sign in to comment.