override protected def createSession()

in externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/session/HiveSessionManager.scala [82:170]


  override protected def createSession(
      protocol: TProtocolVersion,
      user: String,
      password: String,
      ipAddress: String,
      conf: Map[String, String]): Session = {
    conf.get(KYUUBI_SESSION_HANDLE_KEY).map(SessionHandle.fromUUID).flatMap(
      getSessionOption).getOrElse {
      val hiveProtocol = HiveRpcUtils.asHive(protocol)
      val sessionHandle =
        conf.get(KYUUBI_SESSION_HANDLE_KEY).map(SessionHandle.fromUUID).getOrElse(SessionHandle())
      val hiveTSessionHandle = HiveRpcUtils.asHive(sessionHandle.toTSessionHandle)
      val hive = if (internalSessionManager.doAsEnabled) {
        val sessionWithUGI = DynConstructors.builder()
          .impl( // for Hive 3.1
            classOf[ImportedHiveSessionImplwithUGI],
            classOf[ImportedSessionHandle],
            classOf[HiveTProtocolVersion],
            classOf[String],
            classOf[String],
            classOf[HiveConf],
            classOf[String],
            classOf[String],
            classOf[JList[String]])
          .impl( // for Hive 2.3
            classOf[ImportedHiveSessionImplwithUGI],
            classOf[ImportedSessionHandle],
            classOf[HiveTProtocolVersion],
            classOf[String],
            classOf[String],
            classOf[HiveConf],
            classOf[String],
            classOf[String])
          .build[ImportedHiveSessionImplwithUGI]()
          .newInstance(
            new ImportedSessionHandle(hiveTSessionHandle, hiveProtocol),
            hiveProtocol,
            user,
            password,
            HiveSQLEngine.hiveConf,
            ipAddress,
            null,
            Seq(ipAddress).asJava)
        val proxy = HiveSessionProxy.getProxy(sessionWithUGI, sessionWithUGI.getSessionUgi)
        sessionWithUGI.setProxySession(proxy)
        proxy
      } else {
        DynConstructors.builder()
          .impl( // for Hive 3.1
            classOf[ImportedHiveSessionImpl],
            classOf[ImportedSessionHandle],
            classOf[HiveTProtocolVersion],
            classOf[String],
            classOf[String],
            classOf[HiveConf],
            classOf[String],
            classOf[JList[String]])
          .impl( // for Hive 2.3
            classOf[ImportedHiveSessionImpl],
            classOf[ImportedSessionHandle],
            classOf[HiveTProtocolVersion],
            classOf[String],
            classOf[String],
            classOf[HiveConf],
            classOf[String])
          .build[ImportedHiveSessionImpl]()
          .newInstance(
            new ImportedSessionHandle(hiveTSessionHandle, hiveProtocol),
            hiveProtocol,
            user,
            password,
            HiveSQLEngine.hiveConf,
            ipAddress,
            Seq(ipAddress).asJava)
      }
      hive.setSessionManager(internalSessionManager)
      hive.setOperationManager(internalSessionManager.getOperationManager)
      operationLogRoot.foreach(dir => hive.setOperationLogSessionDir(new File(dir)))
      new HiveSessionImpl(
        protocol,
        user,
        password,
        ipAddress,
        conf,
        this,
        sessionHandle,
        hive)
    }
  }