aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuciano Resende <lresende@apache.org>2017-01-14 10:29:47 -0800
committerLuciano Resende <lresende@apache.org>2017-01-14 10:29:47 -0800
commit0493bbe9479b5acb9f93bc76f743e87749be9b3e (patch)
tree7cfe79c8367f41fcfed925ecef6f2c6d3bca01e3
parent46490c5830170f46df799e669d7f944646a8e5a0 (diff)
downloadtoree-gateway-0493bbe9479b5acb9f93bc76f743e87749be9b3e.tar.gz
toree-gateway-0493bbe9479b5acb9f93bc76f743e87749be9b3e.tar.bz2
toree-gateway-0493bbe9479b5acb9f93bc76f743e87749be9b3e.zip
Recieve configuration via command line option
-rw-r--r--src/main/resources/profile.json11
-rw-r--r--src/main/scala/com/ibm/ToreeClient.scala30
2 files changed, 27 insertions, 14 deletions
diff --git a/src/main/resources/profile.json b/src/main/resources/profile.json
new file mode 100644
index 0000000..19308cc
--- /dev/null
+++ b/src/main/resources/profile.json
@@ -0,0 +1,11 @@
+{
+ "stdin_port": 48601,
+ "control_port": 48602,
+ "hb_port": 48605,
+ "shell_port": 48603,
+ "iopub_port": 48604,
+ "ip": "9.125.72.72",
+ "transport": "tcp",
+ "signature_scheme": "hmac-sha256",
+ "key": ""
+} \ No newline at end of file
diff --git a/src/main/scala/com/ibm/ToreeClient.scala b/src/main/scala/com/ibm/ToreeClient.scala
index b644b02..4da2ca5 100644
--- a/src/main/scala/com/ibm/ToreeClient.scala
+++ b/src/main/scala/com/ibm/ToreeClient.scala
@@ -31,22 +31,24 @@ class ToreeGateway(client: SparkKernelClient) {
object ToreeClient extends App {
- val profileJSON: String = """
-{
- "stdin_port": 48691,
- "control_port": 44808,
- "hb_port": 49691,
- "shell_port": 40544,
- "iopub_port": 43462,
- "ip": "9.125.72.72",
- "transport": "tcp",
- "signature_scheme": "hmac-sha256",
- "key": ""
-}
-""".stripMargin
+
+ def getConfigurationFilePath: String = {
+ var filePath = "/opt/toree_proxy/conf/profile.json"
+
+ if (args.length == 0) {
+ for (arg <- args) {
+ if (arg.contains("json")) {
+ filePath = arg
+ }
+ }
+ }
+
+ filePath
+ }
// Parse our configuration and create a client connecting to our kernel
- val config: Config = ConfigFactory.parseString(profileJSON)
+ val configFileContent = scala.io.Source.fromFile(getConfigurationFilePath).mkString
+ val config: Config = ConfigFactory.parseString(configFileContent)
val client = (new ClientBootstrap(config)
with StandardSystemInitialization