本文整理汇总了Scala中org.apache.hive.service.auth.HiveAuthFactory类的典型用法代码示例。如果您正苦于以下问题:Scala HiveAuthFactory类的具体用法?Scala HiveAuthFactory怎么用?Scala HiveAuthFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HiveAuthFactory类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: SharkCLIService
//设置package包名称以及导入依赖的类
package shark.server
import org.apache.hive.service.cli.CLIService
import org.apache.hadoop.hive.conf.HiveConf
import org.apache.hadoop.hive.shims.ShimLoader
import org.apache.hive.service.auth.HiveAuthFactory
import java.io.IOException
import org.apache.hive.service.ServiceException
import javax.security.auth.login.LoginException
import org.apache.spark.SparkEnv
import shark.{SharkServer, Utils}
class SharkCLIService extends CLIService {
override def init(hiveConf: HiveConf) {
this.synchronized {
Utils.setSuperField("hiveConf", hiveConf, this)
val sharkSM = new SharkSessionManager
Utils.setSuperField("sessionManager", sharkSM, this)
addService(sharkSM)
try {
HiveAuthFactory.loginFromKeytab(hiveConf)
val serverUserName = ShimLoader.getHadoopShims
.getShortUserName(ShimLoader.getHadoopShims.getUGIForConf(hiveConf))
Utils.setSuperField("serverUserName", serverUserName, this)
} catch {
case e: IOException => {
throw new ServiceException("Unable to login to kerberos with given principal/keytab", e)
}
case e: LoginException => {
throw new ServiceException("Unable to login to kerberos with given principal/keytab", e)
}
}
// Make sure the ThreadLocal SparkEnv reference is the same for all threads.
SparkEnv.set(SharkServer.sparkEnv)
sharkInit(hiveConf)
}
}
}