From 482c08fd15bd24130bc34d33498557b86a242492 Mon Sep 17 00:00:00 2001 From: Alex Liu Date: Thu, 5 Feb 2015 14:23:11 -0800 Subject: [PATCH] [SPARK-5622][SQL] add connector configuration to thrift-server --- .../hive/thriftserver/HiveThriftServer2.scala | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala index 6e07df18b0e15..91ca9a167712b 100644 --- a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala +++ b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala @@ -17,6 +17,8 @@ package org.apache.spark.sql.hive.thriftserver +import scala.collection.JavaConversions._ + import org.apache.commons.logging.LogFactory import org.apache.hadoop.hive.conf.HiveConf import org.apache.hadoop.hive.conf.HiveConf.ConfVars @@ -35,7 +37,7 @@ import org.apache.spark.scheduler.{SparkListenerApplicationEnd, SparkListener} */ object HiveThriftServer2 extends Logging { var LOG = LogFactory.getLog(classOf[HiveServer2]) - + var connectors = Seq("cassandra") /** * :: DeveloperApi :: * Starts a new thrift server with the given context. @@ -48,6 +50,19 @@ object HiveThriftServer2 extends Logging { sqlContext.sparkContext.addSparkListener(new HiveThriftServer2Listener(server)) } + def setConnectorConf() { + for ((key, value) <- System.getProperties.toMap; if connectorConfKey(key)) { + SparkSQLEnv.hiveContext.hiveconf.set(key, value) + } + } + + def connectorConfKey(key: String): Boolean = { + for (connector <- connectors; if (key.startsWith(connector + "."))) { + return true + } + false + } + def main(args: Array[String]) { val optionsProcessor = new ServerOptionsProcessor("HiveThriftServer2") if (!optionsProcessor.process(args)) { @@ -67,6 +82,7 @@ object HiveThriftServer2 extends Logging { try { val server = new HiveThriftServer2(SparkSQLEnv.hiveContext) + setConnectorConf server.init(SparkSQLEnv.hiveContext.hiveconf) server.start() logInfo("HiveThriftServer2 started")