org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab Scala Examples
The following examples show how to use org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: SapThriftServer.scala From HANAVora-Extensions with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver import org.apache.commons.logging.LogFactory import org.apache.spark.Logging import org.apache.spark.sql.hive.HiveContext import org.apache.spark.sql.hive.sap.thriftserver.SapSQLEnv import org.apache.spark.sql.hive.thriftserver.HiveThriftServer2._ import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab import org.apache.hive.service.server.HiveServerServerOptionsProcessor object SapThriftServer extends Logging { var LOG = LogFactory.getLog(classOf[SapThriftServer]) def main(args: Array[String]) { val optionsProcessor = new HiveServerServerOptionsProcessor("SapThriftServer") if (!optionsProcessor.process(args)) { System.exit(-1) } logInfo("Starting SparkContext") SapSQLEnv.init() org.apache.spark.util.ShutdownHookManager.addShutdownHook { () => SparkSQLEnv.stop() uiTab.foreach(_.detach()) } try { val server = new HiveThriftServer2(SparkSQLEnv.hiveContext) server.init(SparkSQLEnv.hiveContext.hiveconf) server.start() logInfo("SapThriftServer started") listener = new HiveThriftServer2Listener(server, SparkSQLEnv.hiveContext.conf) SparkSQLEnv.sparkContext.addSparkListener(listener) uiTab = if (SparkSQLEnv.sparkContext.getConf.getBoolean("spark.ui.enabled", true)) { Some(new ThriftServerTab(SparkSQLEnv.sparkContext)) } else { None } } catch { case e: Exception => logError("Error starting SapThriftServer", e) System.exit(-1) } } } private[hive] class SapThriftServer(val hiveContext: HiveContext) extends Logging{ def start: Unit = { logInfo("ThriftServer with SapSQLContext") logInfo("Starting SparkContext") HiveThriftServer2.startWithContext(hiveContext) } }
Example 2
Source File: ThriftServerMonitor.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver.monitor import scala.collection.mutable.HashMap import org.apache.spark.SparkException import org.apache.spark.internal.Logging import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab object ThriftServerMonitor extends Logging { private[this] val uiTabs = new HashMap[String, ThriftServerTab]() private[this] val listeners = new HashMap[String, ThriftServerListener]() def setListener(user: String, sparkListener: ThriftServerListener): Unit = { listeners.put(user, sparkListener) } def getListener(user: String): ThriftServerListener = { listeners.getOrElse(user, throw new SparkException(s"Listener does not init for user[$user]")) } def addUITab(user: String, ui: ThriftServerTab): Unit = { uiTabs.put(user, ui) } def detachUITab(user: String): Unit = { listeners.remove(user) uiTabs.get(user).foreach(_.detach()) } def detachAllUITabs(): Unit = { uiTabs.values.foreach(_.detach()) } }
Example 3
Source File: SequilaThriftServer.scala From bdg-sequila with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver import java.io.File import org.apache.spark.annotation.DeveloperApi import org.apache.spark.internal.Logging import org.apache.spark.sql.hive.HiveUtils import org.apache.spark.sql.hive.thriftserver.HiveThriftServer2.HiveThriftServer2Listener import org.apache.spark.sql.hive.thriftserver.HiveThriftServer2Seq.HiveThriftServer2ListenerSeq import org.apache.spark.sql.hive.thriftserver._ import org.apache.spark.sql.{SQLContext, SequilaSession, SparkSession} import org.biodatageeks.sequila.utils.{SequilaRegister, UDFRegister} import org.apache.spark.sql.hive.thriftserver.ui.{ThriftServerTab, ThriftServerTabSeq} object SequilaThriftServer extends Logging { var uiTab: Option[ThriftServerTabSeq] = None var listener: HiveThriftServer2ListenerSeq = _ @DeveloperApi def startWithContext(ss: SequilaSession): Unit = { //System.setSecurityManager(null) val server = new HiveThriftServer2Seq(ss) val executionHive = HiveUtils.newClientForExecution( ss.sqlContext.sparkContext.conf, ss.sparkContext.hadoopConfiguration) server.init(executionHive.conf) server.start() listener = new HiveThriftServer2ListenerSeq(server, ss.sqlContext.conf) ss.sqlContext.sparkContext.addSparkListener(listener) uiTab = if (ss.sqlContext.sparkContext.getConf.getBoolean("spark.ui.enabled", true)) { Some(new ThriftServerTabSeq(ss.sqlContext.sparkContext,listener)) } else { None } } def main(args: Array[String]): Unit = { //System.setSecurityManager(null) val spark = SparkSession .builder .config("spark.sql.hive.thriftServer.singleSession","true") .config("spark.sql.warehouse.dir",sys.env.getOrElse("SEQ_METASTORE_LOCATION",System.getProperty("user.dir")) ) // .config("spark.hadoop.hive.metastore.uris","thrift://localhost:9083") .enableHiveSupport() // .master("local[1]") .getOrCreate val ss = new SequilaSession(spark) UDFRegister.register(ss) SequilaRegister.register(ss) HiveThriftServer2Seq.startWithContext(ss) } }