public class EsServiceCredentialProvider extends Object implements org.apache.spark.deploy.yarn.security.ServiceCredentialProvider
When a job is submitted to a YARN cluster, the credential providers are constructed using a service loader. Each provider is queried for if its service requires a token, and if so, Spark requests that it obtains one.
In client deployment mode, these tokens are retrieved on the driver when the YARN application is first initialized and started by the main program.
In cluster deployment mode, these tokens are retrieved initially on the driver before submitting the application master that runs the main program.
If a principal and keytab are provided to a job, a credentials file is created, and a background thread is started on the application master that will obtain new tokens when they get close to expiring. Those tokens are written to an HDFS directory which the worker nodes will regularly poll to get updated tokens. If the job is launched in client mode, the client will also receive updated tokens.
Constructor and Description |
---|
EsServiceCredentialProvider() |
Modifier and Type | Method and Description |
---|---|
boolean |
credentialsRequired(Configuration hadoopConf)
Given a configuration, check to see if tokens would be required.
|
boolean |
credentialsRequired(SparkConf sparkConf,
Configuration hadoopConf)
Given a configuration, check to see if tokens would be required.
|
scala.Option<Object> |
obtainCredentials(Configuration hadoopConf,
SparkConf sparkConf,
Credentials creds)
Obtains api key tokens from Elasticsearch and stashes them in the given credentials object
|
String |
serviceName()
Name of the service for logging purposes and for the purpose of determining if the
service is disabled in the settings using the property
spark.security.credentials.
|
public boolean credentialsRequired(Configuration hadoopConf)
credentialsRequired
in interface org.apache.spark.deploy.yarn.security.ServiceCredentialProvider
hadoopConf
- the current Hadoop configurationpublic boolean credentialsRequired(SparkConf sparkConf, Configuration hadoopConf)
sparkConf
- the current Spark configuration - used by Cloudera's CDS Spark fork (#1301)hadoopConf
- the current Hadoop configurationpublic scala.Option<Object> obtainCredentials(Configuration hadoopConf, SparkConf sparkConf, Credentials creds)
obtainCredentials
in interface org.apache.spark.deploy.yarn.security.ServiceCredentialProvider
hadoopConf
- Hadoop configuration, picking up all Hadoop specific settingssparkConf
- All settings that exist in Sparkcreds
- The credentials object that will be shared between all workerspublic String serviceName()
serviceName
in interface org.apache.spark.deploy.yarn.security.ServiceCredentialProvider