From 4a0c01b124c3fa9495c5eb2d71af4c3f2e2ffe6e Mon Sep 17 00:00:00 2001 From: Luciano Resende Date: Sat, 14 Jan 2017 10:34:29 -0800 Subject: Enable logging --- src/main/scala/com/ibm/ToreeClient.scala | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/main/scala/com/ibm/ToreeClient.scala') diff --git a/src/main/scala/com/ibm/ToreeClient.scala b/src/main/scala/com/ibm/ToreeClient.scala index 4da2ca5..c9dedcf 100644 --- a/src/main/scala/com/ibm/ToreeClient.scala +++ b/src/main/scala/com/ibm/ToreeClient.scala @@ -13,6 +13,8 @@ import py4j.GatewayServer import scala.concurrent.{Await, Promise} import scala.concurrent.duration.Duration +import org.slf4j.LoggerFactory + class ToreeGateway(client: SparkKernelClient) { // Define our callback def printResult(result: ExecuteResult) = { @@ -31,6 +33,7 @@ class ToreeGateway(client: SparkKernelClient) { object ToreeClient extends App { + final val log = LoggerFactory.getLogger(this.getClass.getName.stripSuffix("$")) def getConfigurationFilePath: String = { var filePath = "/opt/toree_proxy/conf/profile.json" @@ -46,8 +49,19 @@ object ToreeClient extends App { filePath } + log.info("Application Initialized from " + new java.io.File(".").getCanonicalPath) + log.info("With the following parameters:" ) + if (args.length == 0 ) { + log.info(">>> NONE" ) + } else { + for (arg <- args) { + log.info(">>> Arg :" + arg ) + } + } + // Parse our configuration and create a client connecting to our kernel val configFileContent = scala.io.Source.fromFile(getConfigurationFilePath).mkString + log.info(">>> Configuration in use " + configFileContent) val config: Config = ConfigFactory.parseString(configFileContent) val client = (new ClientBootstrap(config) @@ -55,13 +69,6 @@ object ToreeClient extends App { with StandardHandlerInitialization).createClient() val toreeGateway = new ToreeGateway(client) - /* - val code: String = - """ - |sc.parallelize(List(1,2,3,4,5)).reduce((a, b) => a + b) - """.stripMargin - print(toreeGateway.eval(args(0))) - */ val gatewayServer: GatewayServer = new GatewayServer(toreeGateway) gatewayServer.start() -- cgit v1.2.3