[KYUUBI #6648] Support to show launch engine log for thrift http mode
# 🔍 Description ## Issue References 🔗 This PR is to return the launch engine operation handle for thrift http frontend service when opening session. So that, the kyuubi connection show the launch engine log. Refer https://github.com/apache/kyuubi/pull/1377 ## Describe Your Solution 🔧 Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. Just return the launch engine op handle for thrift http connection. ## Types of changes 🔖 - [ ] Bugfix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Test Plan 🧪 #### Behavior Without This Pull Request ⚰️ #### Behavior With This Pull Request 🎉 #### Related Unit Tests --- # Checklist 📝 - [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes #6648 from turboFei/engine_launch_log. Closes #6648 6a3540775 [Wang, Fei] nit 0bd08d208 [Wang, Fei] Support to show launch engine log for thrift http mode Authored-by: Wang, Fei <fwang12@ebay.com> Signed-off-by: Wang, Fei <fwang12@ebay.com>
This commit is contained in:
parent
c9b4512668
commit
353877b328
@ -18,6 +18,7 @@
|
||||
package org.apache.kyuubi.server
|
||||
|
||||
import java.net.ServerSocket
|
||||
import java.util.Base64
|
||||
import java.util.concurrent.{SynchronousQueue, ThreadPoolExecutor, TimeUnit}
|
||||
import javax.security.sasl.AuthenticationException
|
||||
import javax.servlet.{ServletContextEvent, ServletContextListener}
|
||||
@ -35,15 +36,19 @@ import org.eclipse.jetty.util.security.Constraint
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory
|
||||
import org.eclipse.jetty.util.thread.ExecutorThreadPool
|
||||
|
||||
import org.apache.kyuubi.KyuubiException
|
||||
import org.apache.kyuubi.{KyuubiException, KyuubiSQLException}
|
||||
import org.apache.kyuubi.cli.Handle
|
||||
import org.apache.kyuubi.config.KyuubiConf
|
||||
import org.apache.kyuubi.config.KyuubiConf._
|
||||
import org.apache.kyuubi.config.KyuubiReservedKeys.{KYUUBI_SESSION_ENGINE_LAUNCH_HANDLE_GUID, KYUUBI_SESSION_ENGINE_LAUNCH_HANDLE_SECRET, KYUUBI_SESSION_ENGINE_LAUNCH_SUPPORT_RESULT}
|
||||
import org.apache.kyuubi.metrics.MetricsConstants.{THRIFT_HTTP_CONN_FAIL, THRIFT_HTTP_CONN_OPEN, THRIFT_HTTP_CONN_TOTAL}
|
||||
import org.apache.kyuubi.metrics.MetricsSystem
|
||||
import org.apache.kyuubi.server.http.ThriftHttpServlet
|
||||
import org.apache.kyuubi.server.http.authentication.AuthenticationFilter
|
||||
import org.apache.kyuubi.service.{Serverable, Service, ServiceUtils, TFrontendService}
|
||||
import org.apache.kyuubi.shaded.hive.service.rpc.thrift.{TCLIService, TOpenSessionReq}
|
||||
import org.apache.kyuubi.service.TFrontendService.{CURRENT_SERVER_CONTEXT, OK_STATUS}
|
||||
import org.apache.kyuubi.session.KyuubiSessionImpl
|
||||
import org.apache.kyuubi.shaded.hive.service.rpc.thrift.{TCLIService, TOpenSessionReq, TOpenSessionResp}
|
||||
import org.apache.kyuubi.shaded.thrift.protocol.TBinaryProtocol
|
||||
import org.apache.kyuubi.util.NamedThreadFactory
|
||||
|
||||
@ -67,6 +72,8 @@ final class KyuubiTHttpFrontendService(
|
||||
|
||||
override protected def hadoopConf: Configuration = KyuubiServer.getHadoopConf()
|
||||
|
||||
private lazy val defaultFetchSize = conf.get(KYUUBI_SERVER_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE)
|
||||
|
||||
/**
|
||||
* Configure Jetty to serve http requests. Example of a client connection URL:
|
||||
* http://localhost:10000/servlets/thrifths2/ A gateway may cause actual target
|
||||
@ -221,6 +228,45 @@ final class KyuubiTHttpFrontendService(
|
||||
super.initialize(conf)
|
||||
}
|
||||
|
||||
/** Same as KyuubiTBinaryFrontendService, to return launch engine op handle. */
|
||||
override def OpenSession(req: TOpenSessionReq): TOpenSessionResp = {
|
||||
debug(req.toString)
|
||||
info("Client protocol version: " + req.getClient_protocol)
|
||||
val resp = new TOpenSessionResp
|
||||
try {
|
||||
val sessionHandle = getSessionHandle(req, resp)
|
||||
|
||||
val respConfiguration = new java.util.HashMap[String, String]()
|
||||
val launchEngineOp = be.sessionManager.getSession(sessionHandle)
|
||||
.asInstanceOf[KyuubiSessionImpl].launchEngineOp
|
||||
|
||||
val opHandleIdentifier = Handle.toTHandleIdentifier(launchEngineOp.getHandle.identifier)
|
||||
respConfiguration.put(
|
||||
KYUUBI_SESSION_ENGINE_LAUNCH_HANDLE_GUID,
|
||||
Base64.getEncoder.encodeToString(opHandleIdentifier.getGuid))
|
||||
respConfiguration.put(
|
||||
KYUUBI_SESSION_ENGINE_LAUNCH_HANDLE_SECRET,
|
||||
Base64.getEncoder.encodeToString(opHandleIdentifier.getSecret))
|
||||
|
||||
respConfiguration.put(KYUUBI_SESSION_ENGINE_LAUNCH_SUPPORT_RESULT, true.toString)
|
||||
|
||||
// HIVE-23005(4.0.0), Hive JDBC driver supposes that server always returns this conf
|
||||
respConfiguration.put(
|
||||
"hive.server2.thrift.resultset.default.fetch.size",
|
||||
defaultFetchSize.toString)
|
||||
|
||||
resp.setSessionHandle(sessionHandle.toTSessionHandle)
|
||||
resp.setConfiguration(respConfiguration)
|
||||
resp.setStatus(OK_STATUS)
|
||||
Option(CURRENT_SERVER_CONTEXT.get()).foreach(_.setSessionHandle(sessionHandle))
|
||||
} catch {
|
||||
case e: Exception =>
|
||||
error("Error opening session: ", e)
|
||||
resp.setStatus(KyuubiSQLException.toTStatus(e, verbose = true))
|
||||
}
|
||||
resp
|
||||
}
|
||||
|
||||
override def run(): Unit =
|
||||
try {
|
||||
if (isServer()) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user