Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import scala.collection.JavaConverters._
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.{FileSystem, Path}
import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier
import org.apache.hadoop.ipc.RemoteException
import org.apache.hadoop.ipc.StandbyException
import org.apache.hadoop.mapred.Master
import org.apache.hadoop.security.Credentials

Expand All @@ -45,9 +47,16 @@ private[security] class HDFSCredentialProvider extends ServiceCredentialProvider
creds: Credentials): Option[Long] = {
// NameNode to access, used to get tokens from different FileSystems
nnsToAccess(hadoopConf, sparkConf).foreach { dst =>
val dstFs = dst.getFileSystem(hadoopConf)
logInfo("getting token for namenode: " + dst)
dstFs.addDelegationTokens(getTokenRenewer(hadoopConf), creds)
try {
val dstFs = dst.getFileSystem(hadoopConf)
logInfo("getting token for namenode: " + dst)
dstFs.addDelegationTokens(getTokenRenewer(hadoopConf), creds)
} catch {
case e: StandbyException =>
logWarning(s"Namenode ${dst} is in state standby", e)
case e: RemoteException =>
logWarning(s"Namenode ${dst} is in state standby", e)
}
}

// Get the token renewal interval if it is not set. It will only be called once.
Expand Down Expand Up @@ -75,8 +84,15 @@ private[security] class HDFSCredentialProvider extends ServiceCredentialProvider
sparkConf.get(PRINCIPAL).flatMap { renewer =>
val creds = new Credentials()
nnsToAccess(hadoopConf, sparkConf).foreach { dst =>
val dstFs = dst.getFileSystem(hadoopConf)
dstFs.addDelegationTokens(renewer, creds)
try {
val dstFs = dst.getFileSystem(hadoopConf)
dstFs.addDelegationTokens(renewer, creds)
} catch {
case e: StandbyException =>
logWarning(s"Namenode ${dst} is in state standby", e)
case e: RemoteException =>
logWarning(s"Namenode ${dst} is in state standby", e)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HADOOP-13372 implies that swift:// throws an UnknownHostException here; best to catch & log too, in case someone adds swift:// to the list of filesystems.

}
val hdfsToken = creds.getAllTokens.asScala
.find(_.getKind == DelegationTokenIdentifier.HDFS_DELEGATION_KIND)
Expand Down