zhouyifan279 commented on a change in pull request #1029: URL: https://github.com/apache/incubator-kyuubi/pull/1029#discussion_r702854477
########## File path: kyuubi-server/src/main/scala/org/apache/kyuubi/credentials/HadoopFsDelegationTokenProvider.scala ########## @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kyuubi.credentials + +import java.lang.reflect.UndeclaredThrowableException +import java.security.PrivilegedExceptionAction + +import org.apache.hadoop.conf.Configuration +import org.apache.hadoop.fs.{FileSystem, Path} +import org.apache.hadoop.security.{Credentials, UserGroupInformation} + +import org.apache.kyuubi.Logging +import org.apache.kyuubi.config.KyuubiConf +import org.apache.kyuubi.credentials.HadoopFsDelegationTokenProvider.{disableFsCache, doAsProxyUser} + +class HadoopFsDelegationTokenProvider extends HadoopDelegationTokenProvider with Logging { + + override val serviceName: String = "hadoopfs" + + private var internalConf: Configuration = _ + + override def delegationTokensRequired( + hadoopConf: Configuration, + kyuubiConf: KyuubiConf): Boolean = { + UserGroupInformation.isSecurityEnabled + } + + override def obtainDelegationTokens( + hadoopConf: Configuration, + kyuubiConf: KyuubiConf, + owner: String, + creds: Credentials): Unit = { + // A FileSystem object are cached in FileSystem.CACHE by a composite key. + // The UserGroupInformation object used to create it is part of that key. + // If cache is enabled, new FileSystem objects are cached at every method invocation. + if (internalConf == null) { + internalConf = disableFsCache(kyuubiConf, hadoopConf) Review comment: Number of cached FileSystem objects grows as kyuubi user number grows. To reduce memory usage under large number of users, FileSystem objects are closed after obtaining tokens. Besides, although cached FileSystem objects maitains connections to NameNodes, connections are closed in 10 seconds by default. Token renewal won't benefit from cached FileSystem objects. -- 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]
