Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14065#discussion_r69989547
  
    --- Diff: 
yarn/src/main/scala/org/apache/spark/deploy/yarn/token/ConfigurableTokenManager.scala
 ---
    @@ -0,0 +1,214 @@
    +/*
    + * 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.spark.deploy.yarn.token
    +
    +import scala.collection.mutable
    +import scala.util.control.NonFatal
    +
    +import org.apache.hadoop.conf.Configuration
    +import org.apache.hadoop.security.Credentials
    +import org.apache.hadoop.security.token.Token
    +
    +import org.apache.spark.{SparkConf, SparkException}
    +import org.apache.spark.internal.Logging
    +import org.apache.spark.util.Utils
    +
    +/**
    + * A [[ConfigurableTokenManager]] to manage all the token providers 
register in this class. Also
    + * it provides other modules the functionality to obtain tokens, get token 
renewal interval and
    + * calculate the time length till next renewal.
    + *
    + * By default ConfigurableTokenManager has 3 built-in token providers, 
HDFSTokenProvider,
    + * HiveTokenProvider and HBaseTokenProvider, and this 3 token providers 
can also be controlled
    + * by configuration spark.yarn.security.tokens.{service}.enabled, if it is 
set to false, this
    + * provider will not be loaded.
    + *
    + * For other token providers which need to be loaded in should:
    + * 1. Implement [[ServiceTokenProvider]] or [[ServiceTokenRenewable]] if 
token renewal is
    + * required for this service.
    + * 2. set spark.yarn.security.tokens.{service}.enabled to true
    + * 3. Specify the class name through 
spark.yarn.security.tokens.{service}.class
    + *
    + */
    +final class ConfigurableTokenManager private[yarn] (sparkConf: SparkConf) 
extends Logging {
    +  private val tokenProviderEnabledConfig = 
"spark\\.yarn\\.security\\.tokens\\.(.+)\\.enabled".r
    +  private val tokenProviderClsConfig = 
"spark.yarn.security.tokens.%s.class"
    +
    +  // Maintain all the registered token providers
    +  private val tokenProviders = mutable.HashMap[String, 
ServiceTokenProvider]()
    +
    +  private val defaultTokenProviders = Map(
    +    "hdfs" -> "org.apache.spark.deploy.yarn.token.HDFSTokenProvider",
    +    "hive" -> "org.apache.spark.deploy.yarn.token.HiveTokenProvider",
    +    "hbase" -> "org.apache.spark.deploy.yarn.token.HBaseTokenProvider"
    +  )
    +
    +  // AMDelegationTokenRenewer, this will only be create and started in the 
AM
    +  private var _delegationTokenRenewer: AMDelegationTokenRenewer = null
    +
    +  // ExecutorDelegationTokenUpdater, this will only be created and started 
in the driver and
    +  // executor side.
    +  private var _delegationTokenUpdater: ExecutorDelegationTokenUpdater = 
null
    +
    +  def initialize(): Unit = {
    --- End diff --
    
    A lot of this method would go away by using `java.util.ServiceLoader`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to