zhouyifan279 commented on a change in pull request #1074:
URL: https://github.com/apache/incubator-kyuubi/pull/1074#discussion_r706095184
##########
File path:
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/SparkSQLBackendService.scala
##########
@@ -33,9 +38,40 @@ import org.apache.kyuubi.session.SessionManager
* that this backend service holds to run
[[org.apache.kyuubi.operation.Operation]]s.
*/
class SparkSQLBackendService(name: String, spark: SparkSession)
- extends AbstractBackendService(name) {
+ extends AbstractBackendService(name) with Logging {
def this(spark: SparkSession) =
this(classOf[SparkSQLBackendService].getSimpleName, spark)
override val sessionManager: SessionManager = new
SparkSQLSessionManager(spark)
+
+ override def renewDelegationToken(
+ sessionHandle: SessionHandle,
+ authFactory: KyuubiAuthenticationFactory,
+ tokenStr: String): Unit =
+ synchronized {
+ // We hacked `TCLIService.Iface.RenewDelegationToken` to transfer
Credentials from Kyuubi
+ // Server to Spark SQL engine
+ val newCreds = KyuubiHadoopUtils.decodeCredentials(tokenStr)
+ val currentUser = UserGroupInformation.getCurrentUser
+ val oldCreds = KyuubiHadoopUtils.getCredentialsInternal(currentUser)
+
+ val updateCreds = new Credentials()
+ KyuubiHadoopUtils.getTokenMap(newCreds).foreach { case (alias, newToken)
=>
+ val oldToken = oldCreds.getToken(alias)
+ if (oldToken == null) {
+ updateCreds.addToken(alias, newToken)
+ } else {
+ if (KyuubiHadoopUtils.getTokenIssueDate(newToken) >
+ KyuubiHadoopUtils.getTokenIssueDate(oldToken)) {
+ updateCreds.addToken(alias, newToken)
+ } else {
+ warn(s"Ignore token with earlier issue date: $newToken")
+ }
+ }
+ }
+ SparkContextHelper.updateDelegationTokens(
Review comment:
How about `updateCreds.numberOfTokens() > 0` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]