From 1591f422d0e286caa74add358ff6615fbeb9e6bf Mon Sep 17 00:00:00 2001 From: Luciano Resende Date: Tue, 24 Jan 2017 16:04:39 -0800 Subject: Enable running multiple notebooks concurrently There was port conflicts starting py4j when a new notebook instance was started. We now specify the py4j ports to use in profile.json and use those to avoid conflicts. --- src/main/resources/profiles/kernel-1/profile.json | 4 +++- src/main/resources/profiles/kernel-2/profile.json | 4 +++- src/main/resources/profiles/kernel-3/profile.json | 4 +++- src/main/scala/org/apache/toree/gateway/ToreeGateway.scala | 11 ++++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/resources/profiles/kernel-1/profile.json b/src/main/resources/profiles/kernel-1/profile.json index 3d65897..1891b65 100644 --- a/src/main/resources/profiles/kernel-1/profile.json +++ b/src/main/resources/profiles/kernel-1/profile.json @@ -7,5 +7,7 @@ "ip": "9.30.137.220", "transport": "tcp", "signature_scheme": "hmac-sha256", - "key": "" + "key": "", + "py4j_java": 25333, + "py4j_python": 25334 } \ No newline at end of file diff --git a/src/main/resources/profiles/kernel-2/profile.json b/src/main/resources/profiles/kernel-2/profile.json index 0953896..330156b 100644 --- a/src/main/resources/profiles/kernel-2/profile.json +++ b/src/main/resources/profiles/kernel-2/profile.json @@ -7,5 +7,7 @@ "ip": "9.30.137.220", "transport": "tcp", "signature_scheme": "hmac-sha256", - "key": "" + "key": "", + "py4j_java": 25335, + "py4j_python": 25336 } \ No newline at end of file diff --git a/src/main/resources/profiles/kernel-3/profile.json b/src/main/resources/profiles/kernel-3/profile.json index 72113b1..1fa422c 100644 --- a/src/main/resources/profiles/kernel-3/profile.json +++ b/src/main/resources/profiles/kernel-3/profile.json @@ -7,5 +7,7 @@ "ip": "9.30.137.220", "transport": "tcp", "signature_scheme": "hmac-sha256", - "key": "" + "key": "", + "py4j_java": 25337, + "py4j_python": 25338 } \ No newline at end of file diff --git a/src/main/scala/org/apache/toree/gateway/ToreeGateway.scala b/src/main/scala/org/apache/toree/gateway/ToreeGateway.scala index e40050f..22fbd4a 100644 --- a/src/main/scala/org/apache/toree/gateway/ToreeGateway.scala +++ b/src/main/scala/org/apache/toree/gateway/ToreeGateway.scala @@ -31,6 +31,8 @@ import scala.concurrent.{Await, Promise} import scala.concurrent.duration.Duration import org.slf4j.{Logger, LoggerFactory} +import play.api.libs.json._ + import scala.util.Try class ToreeGateway(client: SparkKernelClient) { @@ -124,6 +126,13 @@ object ToreeGatewayClient extends App { val toreeGateway = new ToreeGateway(client) - val gatewayServer: GatewayServer = new GatewayServer(toreeGateway) + val jsonValue = Json.parse(configFileContent) + val port = (jsonValue \ "py4j_java").as[Int] + + if(log.isDebugEnabled()) { + log.debug(">>> Starting GatewayServer with port " + port) + } + + val gatewayServer: GatewayServer = new GatewayServer(toreeGateway, port) gatewayServer.start() } -- cgit v1.2.3